Ejemplo n.º 1
0
        public JSValue Execute(CompiledFunction globalFunction, JSValue[] globalArguments = null)
        {
            var thread = NewThread(globalFunction, globalArguments);

            for (;;)
            {
                var isTerminated = thread.ExecuteStep();
                if (isTerminated)
                {
                    break;
                }
            }
            return(thread.Result);
        }
Ejemplo n.º 2
0
        public JSFunction NewFunction(VariableScope outerScope, CompiledFunction compiledFunction)
        {
            Contract.Requires <ArgumentNullException>(outerScope != null, "outerScope");
            Contract.Requires <ArgumentNullException>(compiledFunction != null, "compiledFunction");
            if (string.IsNullOrEmpty(compiledFunction.Name))
            {
                return(new JSManagedFunction(this, outerScope, compiledFunction, Function));
            }
            var functionScope = new NamedFunctionVariableScope(outerScope);
            var function      = new JSManagedFunction(this, functionScope, compiledFunction, Function);

            functionScope.Bind(function);
            return(function);
        }
Ejemplo n.º 3
0
 internal ExecutionThread(VirtualMachine vm, CompiledFunction globalFunction, JSValue[] globalArguments)
 {
     Contract.Requires(vm != null);
     Contract.Requires(globalFunction != null);
     VM             = vm;
     GlobalScope    = new GlobalVariableScope(vm.GlobalObject);
     GlobalFunction = new JSManagedFunction(VM, GlobalScope, globalFunction, VM.Function);
     CurrentFrame   = new CallStackFrame(
         null,
         VM,
         GlobalFunction,
         vm.GlobalObject,
         GlobalScope,
         globalArguments ?? JSFunction.EmptyArgumentList);
 }
Ejemplo n.º 4
0
 public ExecutionThread NewThread(CompiledFunction globalFunction, JSValue[] globalArguments = null)
 {
     Contract.Requires <ArgumentNullException>(globalFunction != null, "globalFunction");
     return(new ExecutionThread(this, globalFunction, globalArguments));
 }