internal static CompiledScript Compile(string script, bool isGlobal)
 {
     CommonTokenStream tokens = new CommonTokenStream();
     JavaScriptLexer lexer = new JavaScriptLexer(new ANTLRStringStream(script));
     tokens.TokenSource = lexer;
     ScriptSource Source = new ScriptSource(script);
     JavaScriptParser parser = new JavaScriptParser(tokens);
     TopStatementList r = (TopStatementList) parser.program().Tree;
     r.ConstructionComplete();
     if (JSContext.DebugOutput)
     {
         DumpTree(r, 0);
     }
     if (JSContext.OutputAssembly && isGlobal)
     {
         GenerateExternalAssembly(r);
         r.Reset();
     }
     return GenerateMethod(r, Source);
 }
 internal void GenFunctionRef(CompileContext compileContext)
 {
     if (this.FunctionID == -1)
     {
         if (compileContext.Source != null)
         {
             this.Source = compileContext.Source;
         }
         bool WasGlobal = compileContext.TrackImplicitReturnValue;
         compileContext.TrackImplicitReturnValue = false;
         this.FunctionID = compileContext.GenerateFunction(this, this.Name, (StatementNode) base.Children[1], out this._delegate);
         compileContext.TrackImplicitReturnValue = WasGlobal;
     }
     compileContext.GenFunctionRef(this.FunctionID);
 }
 private static CompiledScript GenerateMethod(StatementNode r, ScriptSource Source)
 {
     DynamicMethod method = new DynamicMethod("GlobalCode", MethodAttributes.Static | MethodAttributes.Public, CallingConventions.Standard, typeof(JSValue), new Type[] { typeof(JSContext) }, typeof(JSContext), false);
     DMCompileContext ctx = new DMCompileContext(method.GetILGenerator());
     ctx.Source = Source;
     ctx.GenerateGlobalCode(r);
     GlobalCodeDelegate _delegate = (GlobalCodeDelegate) method.CreateDelegate(typeof(GlobalCodeDelegate));
     CompiledScript cs = new CompiledScript(_delegate);
     cs.Source = Source;
     return cs;
 }