예제 #1
0
        // Add a builtin function to the global object.
        private void AddBuiltin(EngineInstance inst, string name)
        {
            MethodInfo method = typeof(GlobalObject).GetMethod(name);

            globalObject.Put(name, new BuiltinFunction
                                 (inst.GetFunctionPrototype(), name, method),
                             PropertyAttributes.None);
        }
예제 #2
0
	public override Object Eval(VsaEngine engine)
#line 62 "./Nodes/JExpr.tc"
	{
		// Create a new instance of "Object".
		JSObject value = new JSObject(EngineInstance.GetEngineInstance(engine)
											.GetObjectPrototype());
	
		// Evaluate and add the properties.
		JExprListElem elem = first;
		while(elem != null)
		{
			value.Put(Convert.ToString(elem.name), elem.expr.Eval(engine));
			elem = elem.next;
		}
	
		// Return the object to the caller.
		return value;
	}
예제 #3
0
        // Constructor.
        internal GlobalObject(VsaEngine engine)
        {
            // Record the engine for later.
            this.engine = engine;

            // Create the actual storage value, with no prototype.
            globalObject = new JSObject(null, engine);

            // Get the instance object for the engine.
            EngineInstance inst = EngineInstance.GetEngineInstance(engine);

            // Add all of the properties to the global object.
            AddBuiltin(inst, "CollectGarbage");
            AddBuiltin(inst, "decodeURI");
            AddBuiltin(inst, "decodeURIComponent");
            AddBuiltin(inst, "encodeURI");
            AddBuiltin(inst, "encodeURIComponent");
            AddBuiltin(inst, "escape");
            AddBuiltin(inst, "eval");
            AddBuiltin(inst, "GetObject");
            AddBuiltin(inst, "isFinite");
            AddBuiltin(inst, "isNaN");
            AddBuiltin(inst, "parseFloat");
            AddBuiltin(inst, "parseInt");
            AddBuiltin(inst, "ScriptEngine");
            AddBuiltin(inst, "ScriptEngineBuildVersion");
            AddBuiltin(inst, "ScriptEngineMajorVersion");
            AddBuiltin(inst, "ScriptEngineMinorVersion");
            AddBuiltin(inst, "unescape");
            globalObject.Put("Infinity", Double.PositiveInfinity,
                             PropertyAttributes.DontEnum |
                             PropertyAttributes.DontDelete);
            globalObject.Put("NaN", Double.NaN,
                             PropertyAttributes.DontEnum |
                             PropertyAttributes.DontDelete);
            globalObject.Put("undefined", null,
                             PropertyAttributes.DontEnum |
                             PropertyAttributes.DontDelete);
#if false
            AddProperty("ActiveXObject", ActiveXObject);
#endif
            AddProperty("Array", Array);
#if false
            AddProperty("Boolean", Boolean);
            AddProperty("Date", Date);
            AddProperty("Enumerator", Enumerator);
            AddProperty("Error", Error);
            AddProperty("EvalError", EvalError);
#endif
            AddProperty("Function", Function);
            AddProperty("Math", Math);
            AddProperty("Number", Number);
            AddProperty("Object", Object);
#if false
            AddProperty("RangeError", RangeError);
            AddProperty("ReferenceError", ReferenceError);
            AddProperty("RegExp", RegExp);
#endif
            AddProperty("String", String);
#if false
            AddProperty("SyntaxError", SyntaxError);
            AddProperty("TypeError", TypeError);
            AddProperty("URIError", URIError);
            AddProperty("VBArray", VBArray);
#endif
        }
예제 #4
0
	// Constructor.
	internal GlobalObject(VsaEngine engine)
			{
				// Record the engine for later.
				this.engine = engine;

				// Create the actual storage value, with no prototype.
				globalObject = new JSObject(null, engine);

				// Get the instance object for the engine.
				EngineInstance inst = EngineInstance.GetEngineInstance(engine);

				// Add all of the properties to the global object.
				AddBuiltin(inst, "CollectGarbage");
				AddBuiltin(inst, "decodeURI");
				AddBuiltin(inst, "decodeURIComponent");
				AddBuiltin(inst, "encodeURI");
				AddBuiltin(inst, "encodeURIComponent");
				AddBuiltin(inst, "escape");
				AddBuiltin(inst, "eval");
				AddBuiltin(inst, "GetObject");
				AddBuiltin(inst, "isFinite");
				AddBuiltin(inst, "isNaN");
				AddBuiltin(inst, "parseFloat");
				AddBuiltin(inst, "parseInt");
				AddBuiltin(inst, "ScriptEngine");
				AddBuiltin(inst, "ScriptEngineBuildVersion");
				AddBuiltin(inst, "ScriptEngineMajorVersion");
				AddBuiltin(inst, "ScriptEngineMinorVersion");
				AddBuiltin(inst, "unescape");
				globalObject.Put("Infinity", Double.PositiveInfinity,
								 PropertyAttributes.DontEnum |
								 PropertyAttributes.DontDelete);
				globalObject.Put("NaN", Double.NaN,
								 PropertyAttributes.DontEnum |
								 PropertyAttributes.DontDelete);
				globalObject.Put("undefined", null,
								 PropertyAttributes.DontEnum |
								 PropertyAttributes.DontDelete);
#if false
				AddProperty("ActiveXObject", ActiveXObject);
#endif
				AddProperty("Array", Array);
#if false
				AddProperty("Boolean", Boolean);
				AddProperty("Date", Date);
				AddProperty("Enumerator", Enumerator);
				AddProperty("Error", Error);
				AddProperty("EvalError", EvalError);
#endif
				AddProperty("Function", Function);
				AddProperty("Math", Math);
				AddProperty("Number", Number);
				AddProperty("Object", Object);
#if false
				AddProperty("RangeError", RangeError);
				AddProperty("ReferenceError", ReferenceError);
				AddProperty("RegExp", RegExp);
#endif
				AddProperty("String", String);
#if false
				AddProperty("SyntaxError", SyntaxError);
				AddProperty("TypeError", TypeError);
				AddProperty("URIError", URIError);
				AddProperty("VBArray", VBArray);
#endif
			}