public JsGlobal(ExecutionVisitor visitor, Options options) : base(JsNull.Instance) { this.Options = options; this.Visitor = visitor; this["null"] = JsNull.Instance; JsObject objectProrotype = new JsObject(JsNull.Instance); JsFunction functionPrototype = new JsFunctionWrapper( delegate(JsInstance[] arguments) { return(JsUndefined.Instance); }, objectProrotype ); Marshaller = new Marshaller(this); #region Global Classes this["Function"] = FunctionClass = new JsFunctionConstructor(this, functionPrototype); this["Object"] = ObjectClass = new JsObjectConstructor(this, functionPrototype, objectProrotype); ObjectClass.InitPrototype(this); this["Array"] = ArrayClass = new JsArrayConstructor(this); this["Boolean"] = BooleanClass = new JsBooleanConstructor(this); this["Date"] = DateClass = new JsDateConstructor(this); this["Error"] = ErrorClass = new JsErrorConstructor(this, "Error"); this["EvalError"] = EvalErrorClass = new JsErrorConstructor(this, "EvalError"); this["RangeError"] = RangeErrorClass = new JsErrorConstructor(this, "RangeError"); this["ReferenceError"] = ReferenceErrorClass = new JsErrorConstructor(this, "ReferenceError"); this["SyntaxError"] = SyntaxErrorClass = new JsErrorConstructor(this, "SyntaxError"); this["TypeError"] = TypeErrorClass = new JsErrorConstructor(this, "TypeError"); this["URIError"] = URIErrorClass = new JsErrorConstructor(this, "URIError"); this["Number"] = NumberClass = new JsNumberConstructor(this); this["RegExp"] = RegExpClass = new JsRegExpConstructor(this); this["String"] = StringClass = new JsStringConstructor(this); this["Math"] = MathClass = new JsMathConstructor(this); // 15.1 prototype of the global object varies on the implementation //this.Prototype = ObjectClass.PrototypeProperty; #endregion foreach (JsInstance c in this.GetValues()) { if (c is JsConstructor) { ((JsConstructor)c).InitPrototype(this); } } #region Global Properties this["NaN"] = NumberClass["NaN"]; // 15.1.1.1 this["Infinity"] = NumberClass["POSITIVE_INFINITY"]; // // 15.1.1.2 this["undefined"] = JsUndefined.Instance; // 15.1.1.3 this[JsScope.THIS] = this; #endregion #region Global Functions // every embed function should have a prototype FunctionClass.PrototypeProperty - 15. this["eval"] = new JsFunctionWrapper(Eval, FunctionClass.PrototypeProperty); // 15.1.2.1 this["parseInt"] = new JsFunctionWrapper(ParseInt, FunctionClass.PrototypeProperty); // 15.1.2.2 this["parseFloat"] = new JsFunctionWrapper(ParseFloat, FunctionClass.PrototypeProperty); // 15.1.2.3 this["isNaN"] = new JsFunctionWrapper(IsNaN, FunctionClass.PrototypeProperty); this["isFinite"] = new JsFunctionWrapper(isFinite, FunctionClass.PrototypeProperty); this["decodeURI"] = new JsFunctionWrapper(DecodeURI, FunctionClass.PrototypeProperty); this["encodeURI"] = new JsFunctionWrapper(EncodeURI, FunctionClass.PrototypeProperty); this["decodeURIComponent"] = new JsFunctionWrapper(DecodeURIComponent, FunctionClass.PrototypeProperty); this["encodeURIComponent"] = new JsFunctionWrapper(EncodeURIComponent, FunctionClass.PrototypeProperty); #endregion Marshaller.InitTypes(); }
public JsGlobal(ExecutionVisitor visitor, Options options) : base(JsNull.Instance) { this.Options = options; this.Visitor = visitor; this["null"] = JsNull.Instance; JsObject objectProrotype = new JsObject(JsNull.Instance); JsFunction functionPrototype = new JsFunctionWrapper( delegate(JsInstance[] arguments) { return JsUndefined.Instance; }, objectProrotype ); Marshaller = new Marshaller(this); #region Global Classes this["Function"] = FunctionClass = new JsFunctionConstructor(this, functionPrototype); this["Object"] = ObjectClass = new JsObjectConstructor(this, functionPrototype, objectProrotype); ObjectClass.InitPrototype(this); this["Array"] = ArrayClass = new JsArrayConstructor(this); this["Boolean"] = BooleanClass = new JsBooleanConstructor(this); this["Date"] = DateClass = new JsDateConstructor(this); this["Error"] = ErrorClass = new JsErrorConstructor(this, "Error"); this["EvalError"] = EvalErrorClass = new JsErrorConstructor(this, "EvalError"); this["RangeError"] = RangeErrorClass = new JsErrorConstructor(this, "RangeError"); this["ReferenceError"] = ReferenceErrorClass = new JsErrorConstructor(this, "ReferenceError"); this["SyntaxError"] = SyntaxErrorClass = new JsErrorConstructor(this, "SyntaxError"); this["TypeError"] = TypeErrorClass = new JsErrorConstructor(this, "TypeError"); this["URIError"] = URIErrorClass = new JsErrorConstructor(this, "URIError"); this["Number"] = NumberClass = new JsNumberConstructor(this); this["RegExp"] = RegExpClass = new JsRegExpConstructor(this); this["String"] = StringClass = new JsStringConstructor(this); this["Math"] = MathClass = new JsMathConstructor(this); // 15.1 prototype of the global object varies on the implementation //this.Prototype = ObjectClass.PrototypeProperty; #endregion foreach (JsInstance c in this.GetValues()) { if (c is JsConstructor) { ((JsConstructor)c).InitPrototype(this); } } #region Global Properties this["NaN"] = NumberClass["NaN"]; // 15.1.1.1 this["Infinity"] = NumberClass["POSITIVE_INFINITY"]; // // 15.1.1.2 this["undefined"] = JsUndefined.Instance; // 15.1.1.3 this[JsScope.THIS] = this; #endregion #region Global Functions // every embed function should have a prototype FunctionClass.PrototypeProperty - 15. this["eval"] = new JsFunctionWrapper(Eval, FunctionClass.PrototypeProperty); // 15.1.2.1 this["parseInt"] = new JsFunctionWrapper(ParseInt, FunctionClass.PrototypeProperty); // 15.1.2.2 this["parseFloat"] = new JsFunctionWrapper(ParseFloat, FunctionClass.PrototypeProperty); // 15.1.2.3 this["isNaN"] = new JsFunctionWrapper(IsNaN, FunctionClass.PrototypeProperty); this["isFinite"] = new JsFunctionWrapper(isFinite, FunctionClass.PrototypeProperty); this["decodeURI"] = new JsFunctionWrapper(DecodeURI, FunctionClass.PrototypeProperty); this["encodeURI"] = new JsFunctionWrapper(EncodeURI, FunctionClass.PrototypeProperty); this["decodeURIComponent"] = new JsFunctionWrapper(DecodeURIComponent, FunctionClass.PrototypeProperty); this["encodeURIComponent"] = new JsFunctionWrapper(EncodeURIComponent, FunctionClass.PrototypeProperty); #endregion Marshaller.InitTypes(); }