コード例 #1
0
ファイル: JSContext.cs プロジェクト: BGCX261/zinj-svn-to-git
 public JSContext(JSContext Parent)
 {
     this.Parent = Parent;
     if (Parent != null)
     {
         this.LexicalEnv = Parent.LexicalEnv;
         this.VariableEnv = Parent.VariableEnv;
     }
 }
コード例 #2
0
 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);
 }
コード例 #3
0
 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);
 }
コード例 #4
0
 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);
 }
コード例 #5
0
 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();
     }
 }
コード例 #6
0
 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]);
     }
 }
コード例 #7
0
 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);
 }
コード例 #8
0
ファイル: JSContext.cs プロジェクト: BGCX261/zinj-svn-to-git
 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;
 }
コード例 #9
0
 public virtual JSValue Call(JSContext Scope, JSValue ThisObj, JSArgs Args)
 {
     return(JSUndefined.Instance);
 }
コード例 #10
0
ファイル: JSContext.cs プロジェクト: BGCX261/zinj-svn-to-git
 internal static void PushContext(JSContext Context)
 {
     if (Context is JSGlobalContext)
     {
         GlobalContextStack.Push(CurrentGlobalContext);
         CurrentGlobalContext = (JSGlobalContext) Context;
     }
     ContextStack.Push(CurrentContext);
     CurrentContext = Context;
 }
コード例 #11
0
ファイル: JSContext.cs プロジェクト: BGCX261/zinj-svn-to-git
 internal static void PopContext()
 {
     if (CurrentContext is JSGlobalContext)
     {
         CurrentGlobalContext = GlobalContextStack.Pop();
     }
     CurrentContext = ContextStack.Pop();
 }
コード例 #12
0
 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;
 }
コード例 #13
0
 public virtual JSValue Call(JSContext Scope, JSValue ThisObj, JSArgs Args)
 {
     return JSUndefined.Instance;
 }
コード例 #14
0
ファイル: Utilities.cs プロジェクト: BGCX261/zinj-svn-to-git
 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();
     }
 }
コード例 #15
0
ファイル: Utilities.cs プロジェクト: BGCX261/zinj-svn-to-git
 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);
 }
コード例 #16
0
 public override JSValue Construct(JSContext Scope, JSArgs Args)
 {
     return this._delegate(Scope, this, Args, true);
 }
コード例 #17
0
ファイル: JSContext.cs プロジェクト: BGCX261/zinj-svn-to-git
 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;
 }
コード例 #18
0
        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]);
            }
        }