Exemple #1
0
 public JSDebugFunction(JSDebugFunctionDef def, JSEnvRec Scope) : base(JSContext.CurrentGlobalContext.FunctionPrototype, JSContext.CurrentGlobalContext.FunctionCtor)
 {
     this.def = def;
     base.SetDataProp("prototype", new JSObject(), true, false, false);
     this.Scope = Scope;
     base.SetDataProp("length", (double)def.param_names.Length, false, false, false);
 }
 public JSDebugFunction(JSDebugFunctionDef def, JSEnvRec Scope)
     : base(JSContext.CurrentGlobalContext.FunctionPrototype, JSContext.CurrentGlobalContext.FunctionCtor)
 {
     this.def = def;
     base.SetDataProp("prototype", new JSObject(), true, false, false);
     this.Scope = Scope;
     base.SetDataProp("length", (double) def.param_names.Length, false, false, false);
 }
 internal JSFunctionObject(functionExpressionNode def, JSEnvRec Scope)
     : base(JSContext.CurrentGlobalContext.FunctionPrototype, JSContext.CurrentGlobalContext.FunctionCtor)
 {
     this.FunctionDef = def;
     JSObject p = new JSObject();
     p.SetDataProp("constructor", this, true, false, true);
     base.SetDataProp("prototype", p, true, false, false);
     this.Scope = Scope;
 }
        internal JSFunctionObject(functionExpressionNode def, JSEnvRec Scope) : base(JSContext.CurrentGlobalContext.FunctionPrototype, JSContext.CurrentGlobalContext.FunctionCtor)
        {
            this.FunctionDef = def;
            JSObject p = new JSObject();

            p.SetDataProp("constructor", this, true, false, true);
            base.SetDataProp("prototype", p, true, false, false);
            this.Scope = Scope;
        }
Exemple #5
0
 public JSContext(JSContext Parent)
 {
     this.Parent = Parent;
     if (Parent != null)
     {
         this.LexicalEnv = Parent.LexicalEnv;
         this.VariableEnv = Parent.VariableEnv;
     }
 }
Exemple #6
0
 public JSContext(JSContext Parent)
 {
     this.Parent = Parent;
     if (Parent != null)
     {
         this.LexicalEnv  = Parent.LexicalEnv;
         this.VariableEnv = Parent.VariableEnv;
     }
 }
Exemple #7
0
 public override bool DeleteProperty(string Key, bool Throw)
 {
     for (JSEnvRec l = this.LexicalEnv; l != null; l = l.Parent)
     {
         if (l.HasBinding(Key))
         {
             return(l.DeleteBinding(Key, Throw));
         }
     }
     return(true);
 }
Exemple #8
0
 public bool HasBinding(string key)
 {
     for (JSEnvRec lex = this.LexicalEnv; lex != null; lex = lex.Parent)
     {
         if (lex.HasBinding(key))
         {
             return(true);
         }
     }
     return(false);
 }
Exemple #9
0
 public JSValue GetBindingValue(string key)
 {
     for (JSEnvRec lex = this.LexicalEnv; lex != null; lex = lex.Parent)
     {
         JSValue r;
         if (lex.TryGetBindingValue(key, out r))
         {
             return(r);
         }
     }
     throw new JSRuntimeException("ReferenceError", key + " is not defined");
 }
Exemple #10
0
        protected internal virtual JSValue GetFunctionReference(int key, JSEnvRec r)
        {
            JSContext ctx = this;

            if (ctx.Source == null)
            {
                return(this.Parent.GetFunctionReference(key, r));
            }
            functionExpressionNode fncNode = ctx.Source.FunctionList[key];
            JSFunctionObject       fnc     = new JSFunctionObject(fncNode, r);

            fnc.SetDataProp("length", (double)fncNode.ParameterList.Names.Length, false, false, false);
            return(fnc);
        }
Exemple #11
0
 internal virtual JSValue GetFunctionWithThis(string key, out JSValue lThisObj)
 {
     for (JSEnvRec lex = this.LexicalEnv; lex != null; lex = lex.Parent)
     {
         JSValue r;
         if (lex.TryGetBindingValue(key, out r))
         {
             if (lex is JSObjectScope)
             {
                 lThisObj = ((JSObjectScope)lex).ScopeObject;
                 return(r);
             }
             lThisObj = JSUndefined.Instance;
             return(r);
         }
     }
     throw new JSRuntimeException("ReferenceError", key + " is not defined");
 }
 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]);
     }
 }
Exemple #13
0
 public JSEnvRec(JSEnvRec Parent)
 {
     this.Parent = Parent;
 }
 public JSObjectScope(JSEnvRec Parent, JSObject ScopeObject)
     : base(Parent)
 {
     this.ScopeObject = ScopeObject;
 }
Exemple #15
0
 public JSEnvRec(JSEnvRec Parent)
 {
     this.Parent = Parent;
 }
Exemple #16
0
 protected internal virtual JSValue GetFunctionReference(int key, JSEnvRec r)
 {
     JSContext ctx = this;
     if (ctx.Source == null)
     {
         return this.Parent.GetFunctionReference(key, r);
     }
     functionExpressionNode fncNode = ctx.Source.FunctionList[key];
     JSFunctionObject fnc = new JSFunctionObject(fncNode, r);
     fnc.SetDataProp("length", (double) fncNode.ParameterList.Names.Length, false, false, false);
     return fnc;
 }
 public JSWithScope(JSEnvRec Parent, JSObject ScopeObject)
     : base(Parent, ScopeObject)
 {
 }
 public JSGlobalScope(JSEnvRec Parent, JSObject ScopeObject)
     : base(Parent, ScopeObject)
 {
 }
Exemple #19
0
 public JSDeclScope(JSEnvRec Parent) : base(Parent)
 {
     this.scopeValues = new Dictionary <string, JSValue>();
 }
Exemple #20
0
 public JSGlobalScope(JSEnvRec Parent, JSObject ScopeObject) : base(Parent, ScopeObject)
 {
 }
 public JSObjectScope(JSEnvRec Parent, JSObject ScopeObject) : base(Parent)
 {
     this.ScopeObject = ScopeObject;
 }
Exemple #22
0
 public JSWithScope(JSEnvRec Parent, JSObject ScopeObject) : base(Parent, ScopeObject)
 {
 }
 public JSDeclScope(JSEnvRec Parent)
     : base(Parent)
 {
     this.scopeValues = new Dictionary<string, JSValue>();
 }
Exemple #24
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]);
            }
        }