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));
 }
예제 #2
0
            public WaitFrameExecutor(EarleStackFrame parentFrame, float seconds)
                : base(EarleValue.Undefined)
            {
                if (parentFrame == null) throw new ArgumentNullException(nameof(parentFrame));
                Frame = parentFrame.SpawnChild(null, this, EarleStackFrame.SleepCallIP);

                _stopwatch = new Stopwatch();
                _stopwatch.Start();
                _miliseconds = (long) (seconds*1000);
            }
예제 #3
0
 public EarleStackFrame(EarleRuntime runtime, EarleFunction function, IEarleStackFrameExecutor executor,
     int callerIp,
     EarleStackFrame superFrame, EarleThread thread)
 {
     if (runtime == null)
         throw new ArgumentNullException(nameof(runtime));
     if (thread == null)
         throw new ArgumentNullException(nameof(thread));
     Runtime = runtime;
     ParentFrame = superFrame;
     Executor = executor;
     CallerIP = callerIp;
     Function = function;
     Thread = thread;
 }
예제 #4
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);
        }
예제 #5
0
        public EarleValue? Invoke(EarleCompletionHandler completionHandler, EarleValue target, params EarleValue[] args)
        {
            var thread = new EarleThread(completionHandler);
            var rootFrame = new EarleStackFrame(File.Runtime, null, null, EarleStackFrame.RootFrameIP, null, thread);
            var frame = CreateFrameExecutor(rootFrame, EarleStackFrame.RootCallIP, target,
                args?.ToArray() ?? new EarleValue[0]);
            thread.AttachExecutor(frame);

            return thread.Run();
        }
예제 #6
0
 private static void Wait(EarleStackFrame frame, float seconds)
 {
     if (seconds > 0)
         frame.ChildFrame = new WaitFrameExecutor(frame, seconds).Frame;
 }
예제 #7
0
 private static void SetActiveLanguage(EarleStackFrame frame, string key)
 {
     frame.Runtime.Localizer.Key = key;
 }
예제 #8
0
 public EarleStackTrace(EarleStackFrame[] frames)
 {
     Frames = frames;
 }