Esempio n. 1
0
        public Scope(Context context, Scope parentScope)
        {
            ParentScope = parentScope;

            JsObject = context.CreateObject();
            JsObject.Prototype = null;
            JsObject.Class = ObjClass.Internal;
        }
Esempio n. 2
0
        public static Scope CreateCallScope(Scope closure, IFunction callee, IObj that, object[] args, string[] parms)
        {
            var callScope = new Scope(closure.JsObject.Context, closure);
            var argsObject = closure.JsObject.Context.ObjectConstructor.Construct();

            callScope.Local("this", that);
            callScope.Local("arguments", argsObject);

            argsObject.SetOwnProperty("length", args.Length);
            argsObject.SetOwnProperty("callee", callee);

            for (var i = 0; i < args.Length; ++i)
            {
                if (parms != null && i < parms.Length)
                    callScope.Local(parms[i], args[i]);

                argsObject.SetOwnProperty((double)i, args[i]);
            }

            return callScope;
        }
Esempio n. 3
0
 public static Scope CreateCallScope(Scope closure, IFunction callee, IObj that, object[] args)
 {
     return CreateCallScope(closure, callee, that, args, null);
 }
Esempio n. 4
0
 public Scope(Scope parentScope, IObj jsObject)
 {
     JsObject = jsObject;
     ParentScope = parentScope;
 }
Esempio n. 5
0
 public UserFunction(Scope scope, Lambda lambda)
 {
     Scope = scope;
     Lambda = lambda;
     SetOwnProperty("length", (double) lambda.Params.Length);
 }
Esempio n. 6
0
 public void SetupGlobals(Scope globals)
 {
     globals.Global("Object", ObjectConstructor);
     globals.Global("Function", FunctionConstructor);
     globals.Global("Array", ArrayConstructor);
     globals.Global("String", StringConstructor);
     globals.Global("Boolean", BooleanConstructor);
     globals.Global("Number", NumberConstructor);
     globals.Global("Math", MathObject);
     globals.Global("undefined", Js.Undefined.Instance);
     globals.Global("Infinity", double.PositiveInfinity);
     globals.Global("NaN", double.NaN);
     globals.Global("globals", globals.JsObject);
     globals.Global("eval", new Global_obj_eval(this));
     globals.Global("parseInt", new Global_obj_parseInt(this));
     globals.Global("parseFloat", new Global_obj_parseFloat(this));
     globals.Global("isNaN", new Global_obj_isNaN(this));
     globals.Global("isFinite", new Global_obj_isFinite(this));
     globals.Global("encodeURI", new Global_obj_encodeURI(this));
     globals.Global("decodeURI", new Global_obj_decodeURI(this));
     globals.Global("encodeURIComponent", new Global_obj_encodeURIComponent(this));
     globals.Global("decodeURIComponent", new Global_obj_decodeURIComponent(this));
 }
Esempio n. 7
0
        public UserFunction CreateFunction(Scope scope, Lambda lambda)
        {
            var obj = new UserFunction(scope, lambda);

            var protoObj = ObjectConstructor.Construct();
            protoObj.SetOwnProperty("constructor", obj);

            obj.Context = this;
            obj.Class = ObjClass.Function;
            obj.Prototype = FunctionConstructor.Function_prototype;
            obj.SetOwnProperty("prototype", protoObj);

            return obj;
        }