summaryrefslogtreecommitdiff
path: root/sources
diff options
context:
space:
mode:
authorpaltherr <paltherr@epfl.ch>2004-11-22 15:10:46 +0000
committerpaltherr <paltherr@epfl.ch>2004-11-22 15:10:46 +0000
commitc3d9d5ed529e823f6c8863a2b28a1f03f6aca84d (patch)
tree339f8d7251ed238c37bb9f4d349b21629dcedbef /sources
parentd8e3e31836bba7c14d57aaaff08dfdcc1420968b (diff)
downloadscala-c3d9d5ed529e823f6c8863a2b28a1f03f6aca84d.tar.gz
scala-c3d9d5ed529e823f6c8863a2b28a1f03f6aca84d.tar.bz2
scala-c3d9d5ed529e823f6c8863a2b28a1f03f6aca84d.zip
- Added a field "global" in TextTreePrinter
Diffstat (limited to 'sources')
-rw-r--r--sources/scala/tools/scalac/Global.scala4
-rw-r--r--sources/scala/tools/scalac/ast/printer/HTMLPrinter.scala5
-rw-r--r--sources/scala/tools/scalac/ast/printer/TextTreePrinter.scala31
-rw-r--r--sources/scala/tools/scalac/typechecker/DeSugarize.scala2
-rw-r--r--sources/scala/tools/scaladoc/ScalaSearch.java2
-rw-r--r--sources/scalac/transformer/matching/BerrySethi.java8
6 files changed, 26 insertions, 26 deletions
diff --git a/sources/scala/tools/scalac/Global.scala b/sources/scala/tools/scalac/Global.scala
index fb5028ed17..388663810d 100644
--- a/sources/scala/tools/scalac/Global.scala
+++ b/sources/scala/tools/scalac/Global.scala
@@ -25,9 +25,9 @@ class Global(args: CompilerCommand, interpret: boolean) extends scalac_Global(ar
override def newInfer(): Infer =
new Infer(this, treeGen, make);
override def newTextTreePrinter(writer: PrintWriter): TreePrinter =
- new TextTreePrinter(writer);
+ new TextTreePrinter(this, writer);
override def newHTMLTreePrinter(writer: PrintWriter): TreePrinter =
- new HTMLTreePrinter(writer);
+ new HTMLTreePrinter(this, writer);
override def newSwingTreePrinter(writer: PrintWriter): TreePrinter =
new SwingTreePrinter;
diff --git a/sources/scala/tools/scalac/ast/printer/HTMLPrinter.scala b/sources/scala/tools/scalac/ast/printer/HTMLPrinter.scala
index a40a71399e..0fd59ed2f1 100644
--- a/sources/scala/tools/scalac/ast/printer/HTMLPrinter.scala
+++ b/sources/scala/tools/scalac/ast/printer/HTMLPrinter.scala
@@ -10,6 +10,7 @@
import scalac.CompilationUnit;
import scalac.symtab._;
import scalac.ast.Tree;
+import scalac.{Global => scalac_Global, Phase};
package scala.tools.scalac.ast.printer {
@@ -26,7 +27,9 @@ import java.util.HashMap;
* @version 1.0
*/
-class HTMLTreePrinter(writer: PrintWriter) extends TextTreePrinter(writer) {
+class HTMLTreePrinter(global0: scalac_Global, out0: PrintWriter)
+ extends TextTreePrinter(global0, out0)
+{
protected var outSectionLevel = 1;
protected var started = false;
diff --git a/sources/scala/tools/scalac/ast/printer/TextTreePrinter.scala b/sources/scala/tools/scalac/ast/printer/TextTreePrinter.scala
index 8c71113613..9b8e0e28b6 100644
--- a/sources/scala/tools/scalac/ast/printer/TextTreePrinter.scala
+++ b/sources/scala/tools/scalac/ast/printer/TextTreePrinter.scala
@@ -27,18 +27,22 @@ import java.io._;
* @author Michel Schinz, Matthias Zenger
* @version 1.0
*/
-class TextTreePrinter(writer: PrintWriter) with TreePrinter {
-
- val out = writer;
-
- def this(writer: Writer) = this(new PrintWriter(writer));
- def this(stream: OutputStream) = this(new PrintWriter(stream));
- def this() = this(System.out);
+class TextTreePrinter(global0: scalac_Global, out0: PrintWriter)
+ with TreePrinter
+{
+ val global = global0;
+ val out = out0;
+
+ def this(global0: scalac_Global, out0: Writer) =
+ this(global0, new PrintWriter(out0));
+ def this(global0: scalac_Global, stream: OutputStream) =
+ this(global0, new PrintWriter(stream));
+ def this(global0: scalac_Global) =
+ this(global0, System.out);
protected var indentMargin = 0;
protected val INDENT_STEP = 2;
- protected var INDENT_STRING =
- " ";
+ protected var INDENT_STRING = " ";
protected val MAX_INDENT = INDENT_STRING.length();
def begin() = ();
@@ -110,7 +114,7 @@ class TextTreePrinter(writer: PrintWriter) with TreePrinter {
printString(sym.simpleName().toString());
else
printString(sym.name.toString());
- if (scalac_Global.instance.uniqid)
+ if (global.uniqid)
printString("#" + sym.id)
} else {
printString(name.toString());
@@ -495,7 +499,7 @@ class TextTreePrinter(writer: PrintWriter) with TreePrinter {
printType(tree);
case Tree$Select(qualifier, name) =>
- if (scalac_Global.instance.debug || qualifier.symbol() == null || !qualifier.symbol().isRoot()) {
+ if (global.debug || qualifier.symbol() == null || !qualifier.symbol().isRoot()) {
print(qualifier);
print(TXT_DOT);
}
@@ -584,7 +588,7 @@ class TextTreePrinter(writer: PrintWriter) with TreePrinter {
// Printing of trees
protected def printType(tree: Tree): unit =
- if (scalac_Global.instance.printtypes) {
+ if (global.printtypes) {
print(TXT_LEFT_BRACE);
print(if (tree.`type` != null) Simple(tree.`type`.toString())
else TXT_NULL);
@@ -643,7 +647,6 @@ class TextTreePrinter(writer: PrintWriter) with TreePrinter {
val types: java.util.List = new java.util.ArrayList();
if (symbol != null) {
- val global: scalac_Global = scalac_Global.instance;
if (global.currentPhase.id > global.PHASE.ADDACCESSORS.id()) {
val i: Scope$SymbolIterator = symbol.members().iterator();
while (i.hasNext()) {
@@ -725,7 +728,7 @@ class TextTreePrinter(writer: PrintWriter) with TreePrinter {
}
protected def printBounds(lobound: Tree, hibound: Tree, mods: int): unit = {
- val definitions: Definitions = scalac_Global.instance.definitions;
+ val definitions: Definitions = global.definitions;
val printLoBound: Boolean =
if (lobound.getType() != null)
lobound.getType().symbol() != definitions.ALL_CLASS
diff --git a/sources/scala/tools/scalac/typechecker/DeSugarize.scala b/sources/scala/tools/scalac/typechecker/DeSugarize.scala
index 41db26e4b1..3b983a6f1e 100644
--- a/sources/scala/tools/scalac/typechecker/DeSugarize.scala
+++ b/sources/scala/tools/scalac/typechecker/DeSugarize.scala
@@ -630,7 +630,7 @@ class DeSugarize(make: TreeFactory, copy: TreeCopier, gen: TreeGen, infer: scala
//debug
def print(tree: Tree, conv: String, result: Tree): unit = {
if (global.log()) {
- new TextTreePrinter()
+ new TextTreePrinter(global)
.print(tree).println()
.print(" --" + conv + "--> ").println()
.print(result).println().end();
diff --git a/sources/scala/tools/scaladoc/ScalaSearch.java b/sources/scala/tools/scaladoc/ScalaSearch.java
index c7cc9ced03..27575633ae 100644
--- a/sources/scala/tools/scaladoc/ScalaSearch.java
+++ b/sources/scala/tools/scaladoc/ScalaSearch.java
@@ -552,7 +552,7 @@ public class ScalaSearch {
SourceFile sourceFile = global.getSourceFile("tmp.scala", unitString);
CompilationUnit tmpUnit = new CompilationUnit(global, sourceFile, false);
tmpUnit.body = new Parser$class(tmpUnit).parse();
- //TreePrinter treePrinter = new TextTreePrinter(System.out);
+ //TreePrinter treePrinter = new TextTreePrinter(global, System.out);
//treePrinter.print(tmpUnit);
global.PHASE.ANALYZER.phase().apply(new CompilationUnit[]{ tmpUnit });
if (global.reporter.errors() == errorNumber) {
diff --git a/sources/scalac/transformer/matching/BerrySethi.java b/sources/scalac/transformer/matching/BerrySethi.java
index 589e147e87..a9a4abb851 100644
--- a/sources/scalac/transformer/matching/BerrySethi.java
+++ b/sources/scalac/transformer/matching/BerrySethi.java
@@ -11,7 +11,6 @@ import Tree.* ;
import java.util.* ;
-//import scala.compiler.printer.TextTreePrinter ;
//import scala.compiler.printer.XMLAutomPrinter ;
/** a Berry-Sethi style construction for nfas.
@@ -568,12 +567,7 @@ class BerrySethi {
this.finalTag = finalTag;
//System.out.println( "enter automatonFrom("+pat+","+finalTag+")"); // UNIT TEST
- //System.out.println( TextTreePrinter.toString(pat) );
- /*DEBUG = new TextTreePrinter( System.out );
- DEBUG.begin();
- DEBUG.print( pat );
- DEBUG.end();
- */
+ //System.out.println( pat );
//System.out.println( nullableSequence( pat )); // UNIT TEST
switch( pat ) {
case Sequence( Tree[] subexpr ):