internal void BuildGlobalEnv() { // // built in print function // if (SemanticAnalyser.print) { Enter(SemanticAnalyser.GlobalNamespace, Symbol.CreateSymbol("print"), new BuiltIn("print", false, true)); } /* value properties of the Global Object */ Enter(SemanticAnalyser.GlobalNamespace, Symbol.CreateSymbol("NaN"), new BuiltIn("NaN", false, false)); Enter(SemanticAnalyser.GlobalNamespace, Symbol.CreateSymbol("Infinity"), new BuiltIn("Infinity", false, false)); Enter(SemanticAnalyser.GlobalNamespace, Symbol.CreateSymbol("undefined"), new BuiltIn("undefined", false, false)); Enter(SemanticAnalyser.GlobalNamespace, Symbol.CreateSymbol("null"), new BuiltIn("null", false, false)); /* function properties of the Global Object */ object [] custom_attrs; Type global_object = typeof(GlobalObject); MethodInfo [] methods = global_object.GetMethods(BindingFlags.Public | BindingFlags.Static | BindingFlags.DeclaredOnly); foreach (MethodInfo mi in methods) { custom_attrs = mi.GetCustomAttributes(typeof(JSFunctionAttribute), false); foreach (JSFunctionAttribute attr in custom_attrs) { if (attr.IsBuiltIn) { Enter(SemanticAnalyser.GlobalNamespace, Symbol.CreateSymbol(mi.Name), new BuiltIn(SemanticAnalyser.ImplementationName(attr.BuiltIn.ToString()), false, true)); } } } /* built in objects */ Enter(SemanticAnalyser.GlobalNamespace, Symbol.CreateSymbol("Object"), new BuiltIn("Object", true, true)); Enter(SemanticAnalyser.GlobalNamespace, Symbol.CreateSymbol("Function"), new BuiltIn("Function", true, true)); Enter(SemanticAnalyser.GlobalNamespace, Symbol.CreateSymbol("Array"), new BuiltIn("Array", true, true)); Enter(SemanticAnalyser.GlobalNamespace, Symbol.CreateSymbol("String"), new BuiltIn("String", true, true)); Enter(SemanticAnalyser.GlobalNamespace, Symbol.CreateSymbol("Boolean"), new BuiltIn("Boolean", true, true)); Enter(SemanticAnalyser.GlobalNamespace, Symbol.CreateSymbol("Number"), new BuiltIn("Number", true, true)); Enter(SemanticAnalyser.GlobalNamespace, Symbol.CreateSymbol("Math"), new BuiltIn("Math", false, false)); Enter(SemanticAnalyser.GlobalNamespace, Symbol.CreateSymbol("Date"), new BuiltIn("Date", true, true)); Enter(SemanticAnalyser.GlobalNamespace, Symbol.CreateSymbol("RegExp"), new BuiltIn("RegExp", true, true)); /* built in Error objects */ Enter(SemanticAnalyser.GlobalNamespace, Symbol.CreateSymbol("Error"), new BuiltIn("Error", true, true)); Enter(SemanticAnalyser.GlobalNamespace, Symbol.CreateSymbol("EvalError"), new BuiltIn("EvalError", true, true)); Enter(SemanticAnalyser.GlobalNamespace, Symbol.CreateSymbol("RangeError"), new BuiltIn("RangeError", true, true)); Enter(SemanticAnalyser.GlobalNamespace, Symbol.CreateSymbol("ReferenceError"), new BuiltIn("ReferenceError", true, true)); Enter(SemanticAnalyser.GlobalNamespace, Symbol.CreateSymbol("SyntaxError"), new BuiltIn("SyntaxError", true, true)); Enter(SemanticAnalyser.GlobalNamespace, Symbol.CreateSymbol("TypeError"), new BuiltIn("TypeError", true, true)); Enter(SemanticAnalyser.GlobalNamespace, Symbol.CreateSymbol("URIError"), new BuiltIn("URIError", true, true)); }