예제 #1
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;
 }
예제 #2
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();
        }