summaryrefslogtreecommitdiff
path: root/sources/scalac/ast
diff options
context:
space:
mode:
authorpaltherr <paltherr@epfl.ch>2003-12-11 10:20:12 +0000
committerpaltherr <paltherr@epfl.ch>2003-12-11 10:20:12 +0000
commit9b0529c56f667fb6cec884b4542d88a5b8462380 (patch)
tree8849d614f1456cb381999baec6af26e38b4945e1 /sources/scalac/ast
parentf36f1385f404bf92e2c3bcf62cccec3dcdba27bc (diff)
downloadscala-9b0529c56f667fb6cec884b4542d88a5b8462380.tar.gz
scala-9b0529c56f667fb6cec884b4542d88a5b8462380.tar.bz2
scala-9b0529c56f667fb6cec884b4542d88a5b8462380.zip
- Redesigned the tree printing scheme to enable...
- Redesigned the tree printing scheme to enable printing of attributed trees
Diffstat (limited to 'sources/scalac/ast')
-rw-r--r--sources/scalac/ast/printer/HTMLTreePrinter.java5
-rw-r--r--sources/scalac/ast/printer/TextTreePrinter.java34
-rw-r--r--sources/scalac/ast/printer/TreePrinter.java6
3 files changed, 18 insertions, 27 deletions
diff --git a/sources/scalac/ast/printer/HTMLTreePrinter.java b/sources/scalac/ast/printer/HTMLTreePrinter.java
index 034ae42fb9..a4e6bb4f18 100644
--- a/sources/scalac/ast/printer/HTMLTreePrinter.java
+++ b/sources/scalac/ast/printer/HTMLTreePrinter.java
@@ -13,7 +13,6 @@ import scalac.Unit;
import scalac.symtab.Symbol;
import scalac.util.Name;
-import java.io.OutputStream;
import java.io.PrintWriter;
import java.lang.Math;
import java.util.HashMap;
@@ -29,8 +28,8 @@ public class HTMLTreePrinter extends TextTreePrinter {
protected int outSectionLevel = 1;
protected boolean started = false;
- public HTMLTreePrinter(OutputStream stream) {
- super(stream);
+ public HTMLTreePrinter(PrintWriter writer) {
+ super(writer);
}
public void begin() {
diff --git a/sources/scalac/ast/printer/TextTreePrinter.java b/sources/scalac/ast/printer/TextTreePrinter.java
index 9e71518f23..730c53fe06 100644
--- a/sources/scalac/ast/printer/TextTreePrinter.java
+++ b/sources/scalac/ast/printer/TextTreePrinter.java
@@ -13,6 +13,7 @@ import scalac.ast.*;
import scalac.symtab.*;
import scalac.util.Debug;
import scalac.Global;
+import scalac.Phase;
import scalac.Unit;
import scalac.util.Name;
import scalac.util.TypeNames;
@@ -27,8 +28,7 @@ import java.util.*;
* @version 1.0
*/
public class TextTreePrinter implements TreePrinter {
- protected PrintWriter out;
- protected final boolean autoFlush;
+ protected final PrintWriter out;
protected int indent = 0;
protected final int INDENT_STEP = 2;
@@ -36,22 +36,16 @@ public class TextTreePrinter implements TreePrinter {
" ";
protected final int MAX_INDENT = INDENT_STRING.length();
- public TextTreePrinter(OutputStream stream) {
- this(stream, false);
- }
-
- public TextTreePrinter(OutputStream stream, boolean autoFlush) {
- this.autoFlush = autoFlush;
- this.out = new PrintWriter(stream);
+ public TextTreePrinter(PrintWriter writer) {
+ this.out = writer;
}
- public TextTreePrinter(Writer stream) {
- this(stream, false);
+ public TextTreePrinter(Writer writer) {
+ this(new PrintWriter(writer));
}
- public TextTreePrinter(Writer stream, boolean autoFlush) {
- this.autoFlush = autoFlush;
- this.out = new PrintWriter(stream);
+ public TextTreePrinter(OutputStream stream) {
+ this(new PrintWriter(stream));
}
public TextTreePrinter() {
@@ -70,13 +64,11 @@ public class TextTreePrinter implements TreePrinter {
public TreePrinter print(String str) {
out.print(str);
- if (autoFlush) flush();
return this;
}
public TreePrinter println() {
out.println();
- if (autoFlush) flush();
return this;
}
@@ -95,7 +87,6 @@ public class TextTreePrinter implements TreePrinter {
protected void printString(String str) {
out.print(str);
- if (autoFlush) flush();
}
protected void printNewLine() {
@@ -105,7 +96,6 @@ public class TextTreePrinter implements TreePrinter {
}
if (indent > 0)
out.write(INDENT_STRING, 0, indent);
- if (autoFlush) flush();
}
public static class SymbolUsage {
@@ -226,6 +216,12 @@ public class TextTreePrinter implements TreePrinter {
protected static final Text TXT_BAR_SP =
Text.Sequence(new Text[]{ Text.Space, TXT_BAR, Text.Space });
+ public void print(Global global) {
+ Phase phase = global.currentPhase;
+ beginSection(1, "syntax trees at "+phase+" (after "+phase.prev+")");
+ for (int i = 0; i < global.units.length; i++) print(global.units[i]);
+ }
+
public void print(Unit unit) {
printUnitHeader(unit);
if (unit.body != null) {
@@ -621,8 +617,6 @@ public class TextTreePrinter implements TreePrinter {
break;
}
//print("{" + tree.type + "}");//DEBUG
- if (autoFlush)
- flush();
return this;
}
diff --git a/sources/scalac/ast/printer/TreePrinter.java b/sources/scalac/ast/printer/TreePrinter.java
index 059b335c72..53ce4bd3cb 100644
--- a/sources/scalac/ast/printer/TreePrinter.java
+++ b/sources/scalac/ast/printer/TreePrinter.java
@@ -8,8 +8,7 @@
package scalac.ast.printer;
-import java.io.OutputStream;
-
+import scalac.Global;
import scalac.Unit;
import scalac.ast.Tree;
@@ -24,8 +23,7 @@ public interface TreePrinter {
public void end();
public void flush();
- public void beginSection(int level, String title);
-
+ public void print(Global global);
public void print(Unit unit);
public TreePrinter print(Tree tree);