public JSContext(JSContext Parent) { this.Parent = Parent; if (Parent != null) { this.LexicalEnv = Parent.LexicalEnv; this.VariableEnv = Parent.VariableEnv; } }
internal JSValue Call(JSContext Scope, JSValue ThisObj, JSValue fncObject, JSArgs Args) { JSFunctionContext ctx = new JSFunctionContext(ThisObj, Args, this.ParameterList, Scope, ((JSFunctionObject) fncObject).Scope); ctx.Source = this.Source; if (this.Name != "[function]") { ctx.LexicalEnv.CreateMutableBinding(this.Name); ctx.LexicalEnv.SetMutableBinding(this.Name, fncObject); } return this._delegate(ctx); }
public override JSValue Call(JSContext Scope, JSValue ThisObj, JSArgs Args) { if (ThisObj.CheckCoercible()) { ThisObj = ThisObj.ToJSObject(); } else { ThisObj = JSContext.CurrentGlobalContext.Global; } return this.FunctionDef.Call(Scope, ThisObj, this, Args); }
public override JSValue Call(JSContext Scope, JSValue ThisObj, JSArgs Args) { if (ThisObj.CheckCoercible()) { ThisObj = ThisObj.ToJSObject(); } else { ThisObj = JSContext.CurrentGlobalContext.Global; } JSFunctionContext ctx = new JSFunctionContext(ThisObj, Args, new ParameterList(this.def.param_names), Scope, this.Scope); return this.def.del(ctx); }
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(); } }
public JSFunctionContext(JSValue ThisObj, JSArgs Args, ParameterList parameterList, JSContext context, JSEnvRec Scope) : base(context) { if (!((ThisObj is JSNull) || (ThisObj is JSUndefined))) { this.ThisObj = ThisObj; } this.Args = Args; this.parameterList = parameterList; base.LexicalEnv = new JSDeclScope(Scope); base.VariableEnv = base.LexicalEnv; base.CreateMutableBinding("arguments"); base.SetMutableBinding("arguments", Args); int m = parameterList.Names.Length; for (int i = 0; i < m; i++) { base.CreateMutableBinding(parameterList.Names[i]); base.SetMutableBinding(parameterList.Names[i], Args[i]); } }
public override JSValue Call(JSContext Scope, JSValue ThisObj, JSArgs Args) { if (ThisObj.CheckCoercible()) { ThisObj = ThisObj.ToJSObject(); } else { ThisObj = JSContext.CurrentGlobalContext.Global; } return this._delegate(Scope, ThisObj, Args, false); }
internal JSContext CreateWithScope(JSValue v) { JSObject obj = v.ToJSObject(); JSContext ctx = new JSContext(this); JSEnvRec r = new JSWithScope(this.LexicalEnv, obj); ctx.LexicalEnv = r; return ctx; }
public virtual JSValue Call(JSContext Scope, JSValue ThisObj, JSArgs Args) { return(JSUndefined.Instance); }
internal static void PushContext(JSContext Context) { if (Context is JSGlobalContext) { GlobalContextStack.Push(CurrentGlobalContext); CurrentGlobalContext = (JSGlobalContext) Context; } ContextStack.Push(CurrentContext); CurrentContext = Context; }
internal static void PopContext() { if (CurrentContext is JSGlobalContext) { CurrentGlobalContext = GlobalContextStack.Pop(); } CurrentContext = ContextStack.Pop(); }
public virtual JSValue Construct(JSContext Scope, JSArgs Args) { JSObject o = new JSObject(this["prototype"], this); JSValue r = this.Call(Scope, o, Args); if (r is JSObject) { return r; } return o; }
public virtual JSValue Call(JSContext Scope, JSValue ThisObj, JSArgs Args) { return JSUndefined.Instance; }
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(); } }
internal static JSValue DirectEvalCall(JSFunctionBase fnc, JSContext Scope, JSValue ThisObj, JSArgs Args) { if (fnc == JSContext.CurrentGlobalContext.GlobalEval) { return _Eval(Scope, Args, false); } return fnc.Call(JSContext.CurrentGlobalContext, ThisObj, Args); }
public override JSValue Construct(JSContext Scope, JSArgs Args) { return this._delegate(Scope, this, Args, true); }
internal JSContext CreateCatchScope(JSRuntimeException ex, string varname) { JSContext ctx = new JSContext(this); JSEnvRec r = new JSDeclScope(this.LexicalEnv); r.CreateMutableBinding(varname); r.SetMutableBinding(varname, ex.value); ctx.LexicalEnv = r; return ctx; }