public EarleStackFrameExecutor(EarleFunction function, EarleStackFrame parentFrame, int callerIp,
     EarleValue target,
     IEarleRuntimeScope superScope, EarleDictionary locals)
     : base(target)
 {
     Frame = parentFrame.SpawnChild(function, this, callerIp);
     Scopes.Push(new EarleRuntimeScope(superScope, locals));
 }
Exemplo n.º 2
0
        public virtual IEarleStackFrameExecutor CreateFrameExecutor(EarleStackFrame parentFrame, int callerIp,
            EarleValue target, EarleValue[] arguments)
        {
            if (arguments == null) throw new ArgumentNullException(nameof(arguments));
            var locals = new EarleDictionary();

            var index = 0;

            if (Parameters == null)
            {
                throw new Exception("Parameters cannot be null in order for a EarleStackFrameExecutor to be created.");
            }
            foreach (var parameter in Parameters)
            {
                locals[parameter] = index >= arguments.Length ? EarleValue.Undefined : arguments[index];
                index++;
            }

            return new EarleStackFrameExecutor(this, parentFrame, callerIp, target, File, locals);
        }
Exemplo n.º 3
0
 public EarleRuntimeScope(IEarleRuntimeScope superScope, EarleDictionary locals)
 {
     _superScope = superScope;
     _locals = locals ?? new EarleDictionary();
 }