using System.Collections.Generic; using NTERA.Engine.Compiler; namespace NTERA.Engine.Runtime { public class StackFrame { public Dictionary Variables { get; set; } public List Parameters { get; set; } public FunctionDefinition SelfDefinition { get; set; } public bool IsAnonymous { get; set; } public int ExecutionIndex { get; set; } public IList ExecutionNodes { get; set; } public StackFrame Clone(IList nodes, bool anonymous = true) { return new StackFrame { Variables = Variables, Parameters = Parameters, SelfDefinition = SelfDefinition, IsAnonymous = anonymous, ExecutionIndex = 0, ExecutionNodes = nodes }; } } public enum ExecutionResultType { None, AnonymousCall, FunctionReturn } public class ExecutionResult { public static ExecutionResult None { get; } = new ExecutionResult(ExecutionResultType.None); public static ExecutionResult AnonymousCall { get; } = new ExecutionResult(ExecutionResultType.AnonymousCall); public ExecutionResultType Type { get; } public Value? Result { get; } public ExecutionResult(ExecutionResultType type, Value? value = null) { Type = type; Result = value; } } public class Parameter { public Value Value { get; } public Variable BackingVariable { get; } public int[] BackingVariableIndex { get; } public Parameter(Value value, Variable backingVariable = null, int[] variableIndex = null) { Value = value; BackingVariable = backingVariable; BackingVariableIndex = variableIndex ?? new[] { 0 }; } public static implicit operator Value(Parameter parameter) { return parameter.Value; } } }