public JSValue Run()
        {
            JSContext ctx = new JSContext(JSContext.CurrentContext);

            ctx.Source = this.Source;
            JSContext.PushContext(ctx);
            try
            {
                return(this._delegate(JSContext.CurrentContext));
            }
            finally
            {
                JSContext.PopContext();
            }
        }
Example #2
0
        internal static JSValue _Eval(JSContext Scope, JSArgs args, bool AsConstructor)
        {
            if (AsConstructor)
            {
                throw new JSRuntimeException("TypeError", "eval called as constructor");
            }
            JSValue arg = args[0];

            if (!(arg is JSString))
            {
                return(arg);
            }
            JSContext EvalContext = new JSContext(Scope);

            JSContext.PushContext(EvalContext);
            try
            {
                return(CompiledScript.Compile(arg.StringValue(), false).Run());
            }
            finally
            {
                JSContext.PopContext();
            }
        }