private static void toStringTreeHelper(ScriptOrFnNode treeTop, Node n, ObjToIntMap printIds, int level, System.Text.StringBuilder sb) { if (Token.printTrees) { if (printIds == null) { printIds = new ObjToIntMap(); generatePrintIds(treeTop, printIds); } for (int i = 0; i != level; ++i) { sb.Append(" "); } n.toString(printIds, sb); sb.Append('\n'); for (Node cursor = n.FirstChild; cursor != null; cursor = cursor.Next) { if (cursor.Type == Token.FUNCTION) { int fnIndex = cursor.getExistingIntProp(Node.FUNCTION_PROP); FunctionNode fn = treeTop.getFunctionNode(fnIndex); toStringTreeHelper(fn, fn, null, level + 1, sb); } else { toStringTreeHelper(treeTop, cursor, printIds, level + 1, sb); } } } }
public void transform (ScriptOrFnNode tree) { transformCompilationUnit (tree); for (int i = 0; i != tree.FunctionCount; ++i) { FunctionNode fn = tree.getFunctionNode (i); transform (fn); } }
public void transform(ScriptOrFnNode tree) { transformCompilationUnit(tree); for (int i = 0; i != tree.FunctionCount; ++i) { FunctionNode fn = tree.getFunctionNode(i); transform(fn); } }
private static void toStringTreeHelper(ScriptOrFnNode treeTop, Node n, ObjToIntMap printIds, int level, System.Text.StringBuilder sb) { if (Token.printTrees) { if (printIds == null) { printIds = new ObjToIntMap (); generatePrintIds (treeTop, printIds); } for (int i = 0; i != level; ++i) { sb.Append (" "); } n.toString (printIds, sb); sb.Append ('\n'); for (Node cursor = n.FirstChild; cursor != null; cursor = cursor.Next) { if (cursor.Type == Token.FUNCTION) { int fnIndex = cursor.getExistingIntProp (Node.FUNCTION_PROP); FunctionNode fn = treeTop.getFunctionNode (fnIndex); toStringTreeHelper (fn, fn, null, level + 1, sb); } else { toStringTreeHelper (treeTop, cursor, printIds, level + 1, sb); } } } }
public virtual object Compile (CompilerEnvirons compilerEnv, ScriptOrFnNode tree, string encodedSource, bool returnFunction) { this.compilerEnv = compilerEnv; new NodeTransformer ().transform (tree); if (Token.printTrees) { System.Console.Out.WriteLine (tree.toStringTree (tree)); } if (returnFunction) { tree = tree.getFunctionNode (0); } scriptOrFn = tree; itsData = new InterpreterData (compilerEnv.LanguageVersion, scriptOrFn.SourceName, encodedSource); itsData.topLevel = true; if (returnFunction) { generateFunctionICode (); } else { generateICodeFromTree (scriptOrFn); } return itsData; }