Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(803)

Unified Diff: compiler/java/com/google/dart/compiler/DartCompiler.java

Issue 8566019: Added support for dumping AST to console, text file or dot file (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: '' Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: compiler/java/com/google/dart/compiler/DartCompiler.java
===================================================================
--- compiler/java/com/google/dart/compiler/DartCompiler.java (revision 1522)
+++ compiler/java/com/google/dart/compiler/DartCompiler.java (working copy)
@@ -18,6 +18,10 @@
import com.google.dart.compiler.ast.LibraryNode;
import com.google.dart.compiler.ast.LibraryUnit;
import com.google.dart.compiler.ast.Modifiers;
+import com.google.dart.compiler.ast.viz.BaseASTWriter;
+import com.google.dart.compiler.ast.viz.ConsoleWriter;
+import com.google.dart.compiler.ast.viz.DotWriter;
+import com.google.dart.compiler.ast.viz.TextWriter;
import com.google.dart.compiler.common.SourceInfo;
import com.google.dart.compiler.metrics.CompilerMetrics;
import com.google.dart.compiler.metrics.DartEventType;
@@ -664,6 +668,19 @@
try {
// Set entry point
setEntryPoint();
+
+ //Dump the compiler parse tree if dump format is set in arguments
+ String astFormat = config.getCompilerOptions().dumpAST();
+ String outDir = config.getCompilerOptions()
+ .getWorkDirectory().getAbsolutePath();
+ BaseASTWriter astWriter = null;
zundel 2011/11/15 14:49:54 One way you could do this without intruding into t
shauvik 2011/11/15 23:53:14 I moved most of the code in the factory. i.e. pass
+ if("console".equals(astFormat)) {
zundel 2011/11/15 14:49:54 add space between if and ( (here and elsewhere)
shauvik 2011/11/15 23:53:14 Ctrl+Shift+F fixed it. Thanks. On 2011/11/15 14:4
+ astWriter = new ConsoleWriter(outDir);
+ }else if("text".equals(astFormat)) {
zundel 2011/11/15 14:49:54 add space between } and else (here and elsewhere)
shauvik 2011/11/15 23:53:14 Fixed. Thanks. On 2011/11/15 14:49:54, zundel wrot
+ astWriter = new TextWriter(outDir);
+ }else if("dot".equals(astFormat)) {
+ astWriter = new DotWriter(outDir);
+ }
// The two following for loops can be parallelized.
for (LibraryUnit lib : libraries.values()) {
@@ -671,6 +688,9 @@
// Compile all the units in this library.
for (DartUnit unit : lib.getUnits()) {
+
+ if(astWriter != null) astWriter.process(unit);
zundel 2011/11/15 14:49:54 style: in Java, we always surround the if block wi
shauvik 2011/11/15 23:53:14 Okay, Done! On 2011/11/15 14:49:54, zundel wrote:
+
// Don't compile api-only units.
if (unit.isDiet()) {
continue;

Powered by Google App Engine
This is Rietveld 408576698