summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sources/scala/tools/scalac/typechecker/AnalyzerPhase.scala2
-rw-r--r--sources/scalac/Global.java10
-rw-r--r--sources/scalac/Phase.java1
-rw-r--r--sources/scalac/PhaseDescriptor.java16
-rw-r--r--sources/scalac/symtab/classfile/ClassParser.java2
-rw-r--r--sources/scalac/symtab/classfile/MetadataParser.java2
-rw-r--r--sources/scalac/typechecker/AnalyzerPhase.java6
7 files changed, 30 insertions, 9 deletions
diff --git a/sources/scala/tools/scalac/typechecker/AnalyzerPhase.scala b/sources/scala/tools/scalac/typechecker/AnalyzerPhase.scala
index e1d686edc3..02426298eb 100644
--- a/sources/scala/tools/scalac/typechecker/AnalyzerPhase.scala
+++ b/sources/scala/tools/scalac/typechecker/AnalyzerPhase.scala
@@ -52,7 +52,7 @@ class AnalyzerPhase(global: scalac_Global, descriptor: PhaseDescriptor) extends
private def addImport(context: Context, module: Symbol): unit = {
global.prevPhase();
- val tree = global.treeGen.mkImportAll(Position.NOPOS, module);
+ val tree = gen.mkImportAll(Position.NOPOS, module);
global.nextPhase();
context.imports = new ImportList(tree, new Scope(), context.imports);
}
diff --git a/sources/scalac/Global.java b/sources/scalac/Global.java
index 88c36fcbb6..f581dac326 100644
--- a/sources/scalac/Global.java
+++ b/sources/scalac/Global.java
@@ -29,6 +29,7 @@ import scalac.backend.Primitives;
import scalac.symtab.*;
// !!! >>> Interpreter stuff
import scalac.symtab.Definitions;
+import scalac.typechecker.AnalyzerPhase;
import scalac.typechecker.Infer;
import scalac.util.*;
@@ -126,7 +127,7 @@ public abstract class Global {
/** the global primitives
*/
- public Primitives primitives;
+ public final Primitives primitives;
/** compilation phases.
*/
@@ -234,11 +235,12 @@ public abstract class Global {
PHASE.freeze();
PhaseDescriptor[] descriptors = PHASE.phases();
this.firstPhase = descriptors[0].create(this);
- this.definitions = new Definitions(this);
+ for (int i = 1; i <= PHASE.ANALYZER.id(); i++)
+ if (!descriptors[i].hasSkipFlag()) descriptors[i].create(this);
+ this.treeGen = ((AnalyzerPhase)PHASE.ANALYZER.phase()).gen;
this.primitives = new Primitives(this);
- this.treeGen = new TreeGen(this, make);
assert !descriptors[0].hasSkipFlag();
- for (int i = 1; i < descriptors.length; i++)
+ for (int i = PHASE.ANALYZER.id() + 1; i < descriptors.length; i++)
if (!descriptors[i].hasSkipFlag()) descriptors[i].create(this);
this.currentPhase = firstPhase;
}
diff --git a/sources/scalac/Phase.java b/sources/scalac/Phase.java
index 8ce7fd5c53..bd748a876e 100644
--- a/sources/scalac/Phase.java
+++ b/sources/scalac/Phase.java
@@ -43,6 +43,7 @@ public abstract class Phase {
this.id = descriptor.id();
this.prev = global.currentPhase;
if (prev != null) prev.next = this;
+ descriptor.initialize(this);
global.currentPhase = this;
}
diff --git a/sources/scalac/PhaseDescriptor.java b/sources/scalac/PhaseDescriptor.java
index 4bdb89ae92..21f2e6a72e 100644
--- a/sources/scalac/PhaseDescriptor.java
+++ b/sources/scalac/PhaseDescriptor.java
@@ -119,8 +119,9 @@ public final class PhaseDescriptor {
try {
Class[] params = { Global.class, PhaseDescriptor.class };
Object[] args = { global, this };
- Constructor constructor = clasz.getConstructor(params);
- return phase = (Phase)constructor.newInstance(args);
+ Object phase = clasz.getConstructor(params).newInstance(args);
+ assert this.phase == phase: this.phase + " != " + phase;
+ return this.phase;
} catch (NoSuchMethodException exception) {
throw Debug.abort(exception);
} catch (IllegalAccessException exception) {
@@ -216,4 +217,15 @@ public final class PhaseDescriptor {
}
//########################################################################
+ // Protected Methods
+
+ /** Initializes this descriptor with given phase. */
+ protected void initialize(Phase phase) {
+ assert phase != null: "illegal null phase";
+ assert phase.descriptor == this: phase.descriptor.name + " != " + name;
+ assert this.phase == null: "phase " + name + " already initialized";
+ this.phase = phase;
+ }
+
+ //########################################################################
}
diff --git a/sources/scalac/symtab/classfile/ClassParser.java b/sources/scalac/symtab/classfile/ClassParser.java
index b6ee8eb3b2..9c1cf4873b 100644
--- a/sources/scalac/symtab/classfile/ClassParser.java
+++ b/sources/scalac/symtab/classfile/ClassParser.java
@@ -78,7 +78,7 @@ public class ClassParser extends MetadataParser {
public void complete(Symbol c) {
Phase phase = global.currentPhase;
- global.currentPhase = global.getFirstPhase();
+ global.currentPhase = global.PHASE.ANALYZER.phase();
try {
long msec = System.currentTimeMillis();
String filename = SourceRepresentation.externalizeFileName(
diff --git a/sources/scalac/symtab/classfile/MetadataParser.java b/sources/scalac/symtab/classfile/MetadataParser.java
index 7ea907c6f3..8024b7dfc0 100644
--- a/sources/scalac/symtab/classfile/MetadataParser.java
+++ b/sources/scalac/symtab/classfile/MetadataParser.java
@@ -30,7 +30,7 @@ public abstract class MetadataParser extends Type.LazyType {
*/
public final void complete(Symbol sym) {
Phase phase = global.currentPhase;
- global.currentPhase = global.getFirstPhase();
+ global.currentPhase = global.PHASE.ANALYZER.phase();
doComplete(sym);
global.currentPhase = phase;
}
diff --git a/sources/scalac/typechecker/AnalyzerPhase.java b/sources/scalac/typechecker/AnalyzerPhase.java
index d64a99d896..34ff998cb3 100644
--- a/sources/scalac/typechecker/AnalyzerPhase.java
+++ b/sources/scalac/typechecker/AnalyzerPhase.java
@@ -12,13 +12,19 @@ import scalac.Global;
import scalac.Phase;
import scalac.PhaseDescriptor;
import scalac.Unit;
+import scalac.ast.TreeGen;
+import scalac.symtab.Definitions;
import scalac.symtab.Symbol;
public abstract class AnalyzerPhase extends Phase {
+ public final TreeGen gen;
+
/** Initializes this instance. */
public AnalyzerPhase(Global global, PhaseDescriptor descriptor) {
super(global, descriptor);
+ global.definitions = new Definitions(global);
+ this.gen = new TreeGen(global, global.make);
}
public abstract void addConsoleImport(Symbol module);