summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Zenger <mzenger@gmail.com>2003-07-02 12:40:42 +0000
committerMatthias Zenger <mzenger@gmail.com>2003-07-02 12:40:42 +0000
commit5bcdedd615aaa18c44b408db74776949f09e307d (patch)
treedffc1b3bbbe517a818c44cb19686fd0f5e6f876a
parent478c334b562ff810f424b8ac3cdfd7f9c868feab (diff)
downloadscala-5bcdedd615aaa18c44b408db74776949f09e307d.tar.gz
scala-5bcdedd615aaa18c44b408db74776949f09e307d.tar.bz2
scala-5bcdedd615aaa18c44b408db74776949f09e307d.zip
Added a new apply method to each phase which al...
Added a new apply method to each phase which allows to apply only a single compilation unit. For some phases this might probably not work as it is right now. At some stage, these phases have to be adapted accordingly.
-rw-r--r--sources/scalac/Global.java61
-rw-r--r--sources/scalac/PhaseDescriptor.java27
-rw-r--r--sources/scalac/backend/jvm/GenJVMPhase.java8
-rw-r--r--sources/scalac/backend/msil/GenMSILPhase.java3
-rw-r--r--sources/scalac/symtab/SourceCompleter.java38
-rw-r--r--sources/scalac/transformer/AddAccessorsPhase.java4
-rw-r--r--sources/scalac/transformer/AddConstructorsPhase.java19
-rw-r--r--sources/scalac/transformer/AddInterfacesPhase.java4
-rw-r--r--sources/scalac/transformer/ErasurePhase.java34
-rw-r--r--sources/scalac/transformer/ExpandMixinsPhase.java4
-rw-r--r--sources/scalac/transformer/ExplicitOuterClassesPhase.java4
-rw-r--r--sources/scalac/transformer/LambdaLiftPhase.java198
-rw-r--r--sources/scalac/transformer/TransMatchPhase.java4
-rw-r--r--sources/scalac/transformer/UnCurryPhase.java4
-rw-r--r--sources/scalac/typechecker/AnalyzerPhase.java54
-rw-r--r--sources/scalac/typechecker/RefCheckPhase.java8
16 files changed, 278 insertions, 196 deletions
diff --git a/sources/scalac/Global.java b/sources/scalac/Global.java
index d8c46c4df6..4a7a92e14a 100644
--- a/sources/scalac/Global.java
+++ b/sources/scalac/Global.java
@@ -148,7 +148,7 @@ public class Global {
//this.optimize = args.optimize.optimize;
this.debug = args.debug.value;
this.uniqid = args.uniqid.value;
- this.explaintypes = args.explaintypes.value;
+ this.explaintypes = args.explaintypes.value;
this.printtypes = args.types.value;
this.printtokens = args.print.tokens;
this.classPath = args.classpath();
@@ -183,7 +183,7 @@ public class Global {
phases.add(PHASE.ANALYZER);
phases.add(PHASE.REFCHECK);
phases.add(PHASE.UNCURRY);
- /*
+ /*
if (optimize) {
phases.add(PHASE.OPTIMIZE);
} */
@@ -194,7 +194,7 @@ public class Global {
phases.add(PHASE.ADDINTERFACES);
phases.add(PHASE.EXPANDMIXIN);
phases.add(PHASE.ERASURE);
- if (target == TARGET_INT || target == TARGET_MSIL || target == TARGET_JVM) {
+ if (target == TARGET_INT || target == TARGET_MSIL || target == TARGET_JVM) {
phases.add(PHASE.ADDCONSTRUCTORS);
}
if (target == TARGET_MSIL) phases.add(PHASE.GENMSIL);
@@ -208,20 +208,20 @@ public class Global {
phase.initialize(this, i);
assert phase.id == i;
}
- assert PHASE.PARSER.id == START_PHASE_ID;
- assert PHASE.ANALYZER.id + 1 == POST_ANALYZER_PHASE_ID;
+ assert PHASE.PARSER.id == START_PHASE_ID;
+ assert PHASE.ANALYZER.id + 1 == POST_ANALYZER_PHASE_ID;
}
/** Move to next phase
*/
public void nextPhase() {
- currentPhase = phases[currentPhase.id + 1];
+ currentPhase = phases[currentPhase.id + 1];
}
/** Move to previous phase
*/
public void prevPhase() {
- currentPhase = phases[currentPhase.id - 1];
+ currentPhase = phases[currentPhase.id - 1];
}
/** the top-level compilation process
@@ -282,16 +282,41 @@ public class Global {
if (currentPhase == PHASE.ANALYZER) fix2();
}
if (reporter.errors() != 0) {
- imports.clear();
- for (Iterator it = compiledNow.keySet().iterator(); it.hasNext();) {
- Symbol sym = (Symbol) it.next();
- SourceFile f = (SourceFile) compiledNow.get(sym);
- sym.reset(new SourceCompleter(this, f.name()));
- }
- }
- compiledNow.clear();
+ imports.clear();
+ for (Iterator it = compiledNow.keySet().iterator(); it.hasNext();) {
+ Symbol sym = (Symbol) it.next();
+ SourceFile f = (SourceFile) compiledNow.get(sym);
+ sym.reset(new SourceCompleter(this, f.name()));
+ }
+ }
+ compiledNow.clear();
printer.end();
}
+
+ /** transform a unit and stop at the current compilation phase
+ */
+ public void transformUnit(Unit unit) {
+ PhaseDescriptor oldCurrentPhase = currentPhase;
+ int i = PHASE.REFCHECK.id; // or PHASE.UNCURRY.id?
+ while ((i < oldCurrentPhase.id) && (reporter.errors() == 0)) {
+ currentPhase = phases[i];
+ if ((currentPhase.flags & PhaseDescriptor.SKIP) != 0) {
+ operation("skipping phase " + currentPhase.name());
+ } else {
+ start();
+ currentPhase.apply(unit);
+ stop(currentPhase.taskDescription());
+ }
+ if ((currentPhase.flags & PhaseDescriptor.PRINT) != 0)
+ currentPhase.print(this);
+ if ((currentPhase.flags & PhaseDescriptor.GRAPH) != 0)
+ currentPhase.graph(this);
+ if ((currentPhase.flags & PhaseDescriptor.CHECK) != 0)
+ currentPhase.check(this);
+ }
+ currentPhase = oldCurrentPhase;
+ }
+
// !!! <<< Interpreter stuff
public static final String CONSOLE_S = "$console$";
private static final Name
@@ -515,8 +540,8 @@ public class Global {
*/
// the boolean return value is here to let one write "assert log( ... )"
public boolean log(String message) {
- if (log()) {
- reporter.report("[log " + currentPhase.name() + "] " + message);
+ if (log()) {
+ reporter.report("[log " + currentPhase.name() + "] " + message);
}
return true;
}
@@ -524,7 +549,7 @@ public class Global {
/** return true if logging is switched on for the current phase
*/
public boolean log() {
- return (currentPhase.flags & PhaseDescriptor.LOG) != 0;
+ return (currentPhase.flags & PhaseDescriptor.LOG) != 0;
}
/** start a new timer
diff --git a/sources/scalac/PhaseDescriptor.java b/sources/scalac/PhaseDescriptor.java
index 6597dc9e5e..e555383fac 100644
--- a/sources/scalac/PhaseDescriptor.java
+++ b/sources/scalac/PhaseDescriptor.java
@@ -33,9 +33,11 @@ public abstract class PhaseDescriptor {
return "initializing compiler";
}
- /** apply phase to all compilation units
- */
- public void apply(Global global) {}
+ /** apply phase to all compilation units
+ */
+ public void apply(Global global) {}
+
+ public void apply(Unit unit) {}
}
private static class TerminalPhaseDescriptor extends PhaseDescriptor {
@@ -48,9 +50,11 @@ public abstract class PhaseDescriptor {
return "compilation terminated ";
}
- /** apply phase to all compilation units
- */
- public void apply(Global global) {}
+ /** apply phase to all compilation units
+ */
+ public void apply(Global global) {}
+
+ public void apply(Unit unit) {}
}
public static PhaseDescriptor INITIAL = new InitialPhaseDescriptor();
@@ -93,13 +97,17 @@ public abstract class PhaseDescriptor {
* Return the info of `sym' after the phase.
*/
public Type transformInfo(Symbol sym, Type tp) {
- return tp;
+ return tp;
}
/** apply phase to all compilation units
*/
public abstract void apply(Global global);
+ /** apply this phase to a compilation unit
+ */
+ public abstract void apply(Unit unit);
+
/** check all compilation units
*/
public void check(Global global) {
@@ -111,7 +119,6 @@ public abstract class PhaseDescriptor {
*/
public void print(Global global) {
TreePrinter printer = global.printer;
-
printer.beginSection(1, "Trees after phase " + name());
for (int i = 0; i < global.units.length; i++)
printer.print(global.units[i]);
@@ -141,10 +148,10 @@ public abstract class PhaseDescriptor {
/** graph the result of this phase for the given compilation unit
*/
public void graph(Unit unit) {
- /* todo: uncomment
+ /* todo: uncomment
new scala.compiler.gdl.TreePrinter().printInFile(
unit, unit.source + "-" + name() + ".gdl");
- */
+ */
}
public String toString() {
diff --git a/sources/scalac/backend/jvm/GenJVMPhase.java b/sources/scalac/backend/jvm/GenJVMPhase.java
index 26e89581ef..c45e2935c6 100644
--- a/sources/scalac/backend/jvm/GenJVMPhase.java
+++ b/sources/scalac/backend/jvm/GenJVMPhase.java
@@ -30,9 +30,11 @@ public class GenJVMPhase extends PhaseDescriptor {
}
public void apply(Global global) {
- for (int i = 0; i < global.units.length; i++) {
- new GenJVM(global).translate(global.units[i]);
- }
+ for (int i = 0; i < global.units.length; i++)
+ apply(global.units[i]);
}
+ public void apply(Unit unit) {
+ new GenJVM(unit.global).translate(unit);
+ }
}
diff --git a/sources/scalac/backend/msil/GenMSILPhase.java b/sources/scalac/backend/msil/GenMSILPhase.java
index aa931a693b..0e814e2346 100644
--- a/sources/scalac/backend/msil/GenMSILPhase.java
+++ b/sources/scalac/backend/msil/GenMSILPhase.java
@@ -40,4 +40,7 @@ public class GenMSILPhase extends PhaseDescriptor {
new GenMSIL(global, this).apply();
}
+ public void apply(Unit unit) {
+ new GenMSIL(unit.global, this).apply(unit);
+ }
}
diff --git a/sources/scalac/symtab/SourceCompleter.java b/sources/scalac/symtab/SourceCompleter.java
index b315733922..9475e79ffe 100644
--- a/sources/scalac/symtab/SourceCompleter.java
+++ b/sources/scalac/symtab/SourceCompleter.java
@@ -32,24 +32,24 @@ public class SourceCompleter extends Type.LazyType {
/** complete class symbol c by loading the class
*/
public void complete(Symbol c) {
- if (completed) {
- c.setInfo(Type.ErrorType);
- } else if (filename != null) {
- try {
- String fname = filename;
- long msec = System.currentTimeMillis();
- Unit unit = new Unit(global, new SourceFile(filename), false);
- filename = null;
- global.PHASE.PARSER.apply(unit);
- global.PHASE.ANALYZER.lateEnter(global, unit, c);
- global.operation("added " + fname + " in " +
- (System.currentTimeMillis() - msec) + "ms");
- } catch (IOException e) {
- e.printStackTrace();
- global.error("i/o error while loading " + c);
- c.setInfo(Type.ErrorType);
- }
- completed = true;
- }
+ if (completed) {
+ c.setInfo(Type.ErrorType);
+ } else if (filename != null) {
+ try {
+ String fname = filename;
+ long msec = System.currentTimeMillis();
+ Unit unit = new Unit(global, new SourceFile(filename), false);
+ filename = null;
+ global.PHASE.PARSER.apply(unit);
+ global.PHASE.ANALYZER.lateEnter(global, unit, c);
+ global.operation("added " + fname + " in " +
+ (System.currentTimeMillis() - msec) + "ms");
+ } catch (IOException e) {
+ e.printStackTrace();
+ global.error("i/o error while loading " + c);
+ c.setInfo(Type.ErrorType);
+ }
+ completed = true;
+ }
}
}
diff --git a/sources/scalac/transformer/AddAccessorsPhase.java b/sources/scalac/transformer/AddAccessorsPhase.java
index 646b2c5216..61bb92c912 100644
--- a/sources/scalac/transformer/AddAccessorsPhase.java
+++ b/sources/scalac/transformer/AddAccessorsPhase.java
@@ -31,6 +31,10 @@ public class AddAccessorsPhase extends PhaseDescriptor {
new AddAccessors(global).apply();
}
+ public void apply(Unit unit) {
+ new AddAccessors(unit.global).apply(unit);
+ }
+
public Checker[] postCheckers(Global global) {
return new Checker[] {
new CheckSymbols(global),
diff --git a/sources/scalac/transformer/AddConstructorsPhase.java b/sources/scalac/transformer/AddConstructorsPhase.java
index cdec3707d0..81a74b9d58 100644
--- a/sources/scalac/transformer/AddConstructorsPhase.java
+++ b/sources/scalac/transformer/AddConstructorsPhase.java
@@ -10,10 +10,9 @@
package scalac.transformer;
import java.util.HashMap;
-
+import scalac.*;
import scalac.checkers.*;
-import scalac.Global;
-import scalac.PhaseDescriptor;
+
public class AddConstructorsPhase extends PhaseDescriptor {
@@ -22,19 +21,23 @@ public class AddConstructorsPhase extends PhaseDescriptor {
HashMap constructors = new HashMap();
public String name() {
- return "addconstructors";
+ return "addconstructors";
}
public String description() {
- return "add explicit constructor for each class";
+ return "add explicit constructor for each class";
}
public String taskDescription() {
- return "added constructors";
+ return "added constructors";
}
public void apply(Global global) {
- new AddConstructors(global, constructors).apply();
+ new AddConstructors(global, constructors).apply();
+ }
+
+ public void apply(Unit unit) {
+ new AddConstructors(unit.global, constructors).apply(unit);
}
public Checker[] postCheckers(Global global) {
@@ -42,7 +45,7 @@ public class AddConstructorsPhase extends PhaseDescriptor {
new CheckSymbols(global),
new CheckTypes(global),
new CheckOwners(global),
- new CheckNames(global)
+ new CheckNames(global)
};
}
}
diff --git a/sources/scalac/transformer/AddInterfacesPhase.java b/sources/scalac/transformer/AddInterfacesPhase.java
index d2037118bc..fbe91662b0 100644
--- a/sources/scalac/transformer/AddInterfacesPhase.java
+++ b/sources/scalac/transformer/AddInterfacesPhase.java
@@ -35,6 +35,10 @@ public class AddInterfacesPhase extends PhaseDescriptor {
new AddInterfaces(global, this).apply();
}
+ public void apply(Unit unit) {
+ new AddInterfaces(unit.global, this).apply(unit);
+ }
+
public Type transformInfo(Symbol sym, Type tp) {
if (sym.isConstructor()
&& needInterface(sym.primaryConstructorClass())) {
diff --git a/sources/scalac/transformer/ErasurePhase.java b/sources/scalac/transformer/ErasurePhase.java
index 4347d01c6c..8accd1ed9a 100644
--- a/sources/scalac/transformer/ErasurePhase.java
+++ b/sources/scalac/transformer/ErasurePhase.java
@@ -10,7 +10,7 @@
package scalac.transformer;
import scalac.Global;
-import scalac.PhaseDescriptor;
+import scalac.*;
import scalac.backend.Primitive;
import scalac.backend.Primitives;
import scalac.checkers.Checker;
@@ -41,22 +41,28 @@ public class ErasurePhase extends PhaseDescriptor {
}
public void apply(Global global) {
- this.definitions = global.definitions;
- this.primitives = global.primitives;
+ this.definitions = global.definitions;
+ this.primitives = global.primitives;
new Erasure(global).apply();
}
- private Type eraseParams(Type tp) {
- switch (tp) {
- case PolyType(_, Type result):
- return eraseParams(result);
- case MethodType(Symbol[] params, Type result):
- Symbol[] params1 = Type.erasureMap.map(params);
- if (params1 == params) return tp;
- else return Type.MethodType(params1, result);
- default:
- return tp;
+ public void apply(Unit unit) {
+ this.definitions = unit.global.definitions;
+ this.primitives = unit.global.primitives;
+ new Erasure(unit.global).apply(unit);
}
+
+ private Type eraseParams(Type tp) {
+ switch (tp) {
+ case PolyType(_, Type result):
+ return eraseParams(result);
+ case MethodType(Symbol[] params, Type result):
+ Symbol[] params1 = Type.erasureMap.map(params);
+ if (params1 == params) return tp;
+ else return Type.MethodType(params1, result);
+ default:
+ return tp;
+ }
}
public Type transformInfo(Symbol sym, Type tp) {
@@ -76,7 +82,7 @@ public class ErasurePhase extends PhaseDescriptor {
new CheckSymbols(global),
new CheckTypes(global),
new CheckOwners(global),
- new CheckNames(global)
+ new CheckNames(global)
};
}
}
diff --git a/sources/scalac/transformer/ExpandMixinsPhase.java b/sources/scalac/transformer/ExpandMixinsPhase.java
index 3d637dbf10..768e7e6d0b 100644
--- a/sources/scalac/transformer/ExpandMixinsPhase.java
+++ b/sources/scalac/transformer/ExpandMixinsPhase.java
@@ -34,6 +34,10 @@ public class ExpandMixinsPhase extends PhaseDescriptor {
new ExpandMixins(global, this).apply();
}
+ public void apply(Unit unit) {
+ new ExpandMixins(unit.global, this).apply(unit);
+ }
+
public Checker[] postCheckers(Global global) {
return new Checker[] {
new CheckSymbols(global),
diff --git a/sources/scalac/transformer/ExplicitOuterClassesPhase.java b/sources/scalac/transformer/ExplicitOuterClassesPhase.java
index c7db77f0ff..92125339a6 100644
--- a/sources/scalac/transformer/ExplicitOuterClassesPhase.java
+++ b/sources/scalac/transformer/ExplicitOuterClassesPhase.java
@@ -33,6 +33,10 @@ public class ExplicitOuterClassesPhase extends PhaseDescriptor {
new ExplicitOuterClasses(global).apply();
}
+ public void apply(Unit unit) {
+ new ExplicitOuterClasses(unit.global).apply(unit);
+ }
+
public Checker[] postCheckers(Global global) {
return new Checker[] {
new CheckSymbols(global),
diff --git a/sources/scalac/transformer/LambdaLiftPhase.java b/sources/scalac/transformer/LambdaLiftPhase.java
index df31745da5..73e26e7986 100644
--- a/sources/scalac/transformer/LambdaLiftPhase.java
+++ b/sources/scalac/transformer/LambdaLiftPhase.java
@@ -22,8 +22,8 @@ public class LambdaLiftPhase extends PhaseDescriptor implements Kinds, Modifiers
public void initialize(Global global, int id) {
super.initialize(global, id);
- this.global = global;
- this.nextPhase = id + 1;
+ this.global = global;
+ this.nextPhase = id + 1;
}
public String name () {
@@ -42,88 +42,92 @@ public class LambdaLiftPhase extends PhaseDescriptor implements Kinds, Modifiers
new LambdaLift(global, this).apply();
}
- public Type transformInfo(Symbol sym, Type tp) {
- if (global.debug)
- global.log("transform info for " + sym + ":" + tp + sym.locationString());
- Type tp1 = tp;
- if (sym != Symbol.NONE) {
- switch (tp) {
- case MethodType(_, _):
- case PolyType(_, _):
- tp1 = transform(tp, sym);
- break;
- default:
- if (sym.kind == CLASS)
- tp1 = transform(tp, sym);
- else
- tp1 = transform(tp, sym.owner());
- }
+ public void apply(Unit unit) {
+ new LambdaLift(unit.global, this).apply(unit);
}
- if ((sym.flags & Modifiers.CAPTURED) != 0) return refType(tp1);
- else return tp1;
+
+ public Type transformInfo(Symbol sym, Type tp) {
+ if (global.debug)
+ global.log("transform info for " + sym + ":" + tp + sym.locationString());
+ Type tp1 = tp;
+ if (sym != Symbol.NONE) {
+ switch (tp) {
+ case MethodType(_, _):
+ case PolyType(_, _):
+ tp1 = transform(tp, sym);
+ break;
+ default:
+ if (sym.kind == CLASS)
+ tp1 = transform(tp, sym);
+ else
+ tp1 = transform(tp, sym.owner());
+ }
+ }
+ if ((sym.flags & Modifiers.CAPTURED) != 0) return refType(tp1);
+ else return tp1;
}
/** Add proxies as type arguments for propagated type parameters.
*/
Type transform(Type tp, Symbol owner) {
- return transformTypeMap.setOwner(owner).apply(tp);
+ return transformTypeMap.setOwner(owner).apply(tp);
}
private class TransformTypeMap extends Type.MapOnlyTypes {
- Symbol owner;
-// ArrayList/*<Symbol>*/ excluded = new ArrayList();
+ Symbol owner;
+// ArrayList/*<Symbol>*/ excluded = new ArrayList();
Type.Map setOwner(Symbol owner) { this.owner = owner; return this; }
- public Type apply(Type tp) {
- switch (tp) {
- case TypeRef(Type pre, Symbol sym, Type[] targs):
- switch (pre) {
- case ThisType(_):
- if (sym.kind == CLASS && sym.constructor().isUpdated(nextPhase)) {
- Symbol[] tparams =
- sym.constructor().infoAt(nextPhase).typeParams();
- int i = tparams.length;
- while (i > 0 && (tparams[i-1].flags & SYNTHETIC) != 0)
- i--;
- if (i < tparams.length) {
- if (global.debug)
- global.log("adding proxies for " + sym + ": " + ArrayApply.toString(tparams));
-
- Type[] targs1 = new Type[tparams.length];
- System.arraycopy(map(targs), 0, targs1, 0, targs.length);
- while (i < tparams.length) {
- targs1[i] = proxy(tparams[i], owner).type();
- i++;
- }
- return Type.TypeRef(pre, sym, targs1);
- }
- } else if (sym.isLocal()) {
- assert targs.length == 0;
- return proxy(sym, owner).type();
- }
- }
- break;
+ public Type apply(Type tp) {
+ switch (tp) {
+ case TypeRef(Type pre, Symbol sym, Type[] targs):
+ switch (pre) {
+ case ThisType(_):
+ if (sym.kind == CLASS && sym.constructor().isUpdated(nextPhase)) {
+ Symbol[] tparams =
+ sym.constructor().infoAt(nextPhase).typeParams();
+ int i = tparams.length;
+ while (i > 0 && (tparams[i-1].flags & SYNTHETIC) != 0)
+ i--;
+ if (i < tparams.length) {
+ if (global.debug)
+ global.log("adding proxies for " + sym + ": " + ArrayApply.toString(tparams));
+
+ Type[] targs1 = new Type[tparams.length];
+ System.arraycopy(map(targs), 0, targs1, 0, targs.length);
+ while (i < tparams.length) {
+ targs1[i] = proxy(tparams[i], owner).type();
+ i++;
+ }
+ return Type.TypeRef(pre, sym, targs1);
+ }
+ } else if (sym.isLocal()) {
+ assert targs.length == 0;
+ return proxy(sym, owner).type();
+ }
+ }
+ break;
/*
- case PolyType(Symbol[] tparams, _):
- if (tparams.length != 0) {
- int len = excluded.size();
- for (int i = 0; i < tparams.length; i++)
- excluded.add(tparams[i]);
- Type tp1 = map(tp);
- for (int i = 0; i < tparams.length; i++)
- excluded.remove(excluded.size() - 1);
- return tp1;
- }
+ case PolyType(Symbol[] tparams, _):
+ if (tparams.length != 0) {
+ int len = excluded.size();
+ for (int i = 0; i < tparams.length; i++)
+ excluded.add(tparams[i]);
+ Type tp1 = map(tp);
+ for (int i = 0; i < tparams.length; i++)
+ excluded.remove(excluded.size() - 1);
+ return tp1;
+ }
*/
- }
- return map(tp);
- }
-
- /** All symbols are mapped to themselves.
- */
- public Scope map(Scope s) { return s; }
- public Symbol map(Symbol s) { return s; }
- public Symbol[] map(Symbol[] ss) { return ss; }
+ }
+ return map(tp);
+ }
+
+ /** All symbols are mapped to themselves.
+ */
+ public Scope map(Scope s) { return s; }
+ public Symbol map(Symbol s) { return s; }
+ public Symbol[] map(Symbol[] ss) { return ss; }
}
private TransformTypeMap transformTypeMap = new TransformTypeMap();
@@ -132,36 +136,36 @@ public class LambdaLiftPhase extends PhaseDescriptor implements Kinds, Modifiers
* or `fv' itself if this is the closest definition.
*/
Symbol proxy(Symbol fv, Symbol owner) {
- if (global.debug)
- global.log("proxy " + fv + " of " + fv.owner() + " in " + LambdaLift.asFunction(owner));
- Symbol o = owner;
- while (o.kind != NONE) {
- if (global.debug)
- global.log("looking in " + LambdaLift.asFunction(o) + " " +
- ArrayApply.toString(o.typeParams()));
- Symbol fowner = LambdaLift.asFunction(o);
- if (fv.owner() == fowner) return fv;
- Type ft = (fowner.isUpdated(nextPhase)) ? fowner.typeAt(nextPhase)
- : fowner.type();
- Symbol[] ownerparams = fv.isType() ? ft.typeParams()
- : ft.firstParams();
- for (int i = 0; i < ownerparams.length; i++) {
- if (ownerparams[i].name == fv.name)
- return ownerparams[i];
- }
- assert o.owner() != o;
- o = o.owner();
- }
- return fv;
- //throw new ApplicationError("proxy " + fv + " in " + owner);
+ if (global.debug)
+ global.log("proxy " + fv + " of " + fv.owner() + " in " + LambdaLift.asFunction(owner));
+ Symbol o = owner;
+ while (o.kind != NONE) {
+ if (global.debug)
+ global.log("looking in " + LambdaLift.asFunction(o) + " " +
+ ArrayApply.toString(o.typeParams()));
+ Symbol fowner = LambdaLift.asFunction(o);
+ if (fv.owner() == fowner) return fv;
+ Type ft = (fowner.isUpdated(nextPhase)) ? fowner.typeAt(nextPhase)
+ : fowner.type();
+ Symbol[] ownerparams = fv.isType() ? ft.typeParams()
+ : ft.firstParams();
+ for (int i = 0; i < ownerparams.length; i++) {
+ if (ownerparams[i].name == fv.name)
+ return ownerparams[i];
+ }
+ assert o.owner() != o;
+ o = o.owner();
+ }
+ return fv;
+ //throw new ApplicationError("proxy " + fv + " in " + owner);
}
/** The type scala.Ref[tp]
*/
Type refType(Type tp) {
- Symbol refClass = global.definitions.getClass(Names.scala_Ref);
- assert refClass.kind == Kinds.CLASS;
- return Type.TypeRef(global.definitions.SCALA_TYPE, refClass, new Type[]{tp});
+ Symbol refClass = global.definitions.getClass(Names.scala_Ref);
+ assert refClass.kind == Kinds.CLASS;
+ return Type.TypeRef(global.definitions.SCALA_TYPE, refClass, new Type[]{tp});
}
public Checker[] postCheckers(Global global) {
@@ -169,7 +173,7 @@ public class LambdaLiftPhase extends PhaseDescriptor implements Kinds, Modifiers
new CheckSymbols(global),
new CheckTypes(global),
new CheckOwners(global),
- new CheckNames(global)
+ new CheckNames(global)
};
}
}
diff --git a/sources/scalac/transformer/TransMatchPhase.java b/sources/scalac/transformer/TransMatchPhase.java
index f599033efb..4781ad0cf9 100644
--- a/sources/scalac/transformer/TransMatchPhase.java
+++ b/sources/scalac/transformer/TransMatchPhase.java
@@ -29,6 +29,10 @@ public class TransMatchPhase extends PhaseDescriptor {
new TransMatch(global).apply();
}
+ public void apply(Unit unit) {
+ new TransMatch(unit.global).apply(unit);
+ }
+
public Checker[] postCheckers(Global global) {
return new Checker[] {
new CheckSymbols(global),
diff --git a/sources/scalac/transformer/UnCurryPhase.java b/sources/scalac/transformer/UnCurryPhase.java
index 3cf87f7ef0..d9ae38ba4e 100644
--- a/sources/scalac/transformer/UnCurryPhase.java
+++ b/sources/scalac/transformer/UnCurryPhase.java
@@ -39,6 +39,10 @@ public class UnCurryPhase extends PhaseDescriptor implements Modifiers {
new UnCurry(global, this).apply();
}
+ public void apply(Unit unit) {
+ new UnCurry(unit.global, this).apply(unit);
+ }
+
/** - return symbol's transformed type,
* - if symbol is a def parameter with transformed type T, return () => T
*/
diff --git a/sources/scalac/typechecker/AnalyzerPhase.java b/sources/scalac/typechecker/AnalyzerPhase.java
index 6d61ba3d01..158b7dd530 100644
--- a/sources/scalac/typechecker/AnalyzerPhase.java
+++ b/sources/scalac/typechecker/AnalyzerPhase.java
@@ -28,11 +28,11 @@ public class AnalyzerPhase extends PhaseDescriptor {
super.initialize(global, id);
Definitions definitions = global.definitions;
this.startContext = new Context(
- Tree.Empty,
- definitions.ROOT_CLASS,
- definitions.ROOT_CLASS.members(),
- Context.NONE);
- this.startContext.enclClass = this.startContext;
+ Tree.Empty,
+ definitions.ROOT_CLASS,
+ definitions.ROOT_CLASS.members(),
+ Context.NONE);
+ this.startContext.enclClass = this.startContext;
if (!global.noimports) {
TreeFactory make = global.make;
@@ -43,47 +43,47 @@ public class AnalyzerPhase extends PhaseDescriptor {
.setSymbol(definitions.JAVALANG)
.setType(Type.singleType(java.type, definitions.JAVALANG));
Tree importjavalang = make.Import(
- Position.NOPOS, javalang, new Name[]{Names.WILDCARD})
+ Position.NOPOS, javalang, new Name[]{Names.WILDCARD})
.setSymbol(definitions.JAVALANG)
.setType(definitions.UNIT_TYPE);
startContext.imports = new ImportList(
- importjavalang, startContext.scope, startContext.imports);
+ importjavalang, startContext.scope, startContext.imports);
Tree scala = make.Ident(Position.NOPOS, Names.scala)
.setSymbol(definitions.SCALA)
.setType(Type.singleType(definitions.ROOT_TYPE, definitions.SCALA));
Tree importscala = make.Import(
- Position.NOPOS, scala, new Name[]{Names.WILDCARD})
+ Position.NOPOS, scala, new Name[]{Names.WILDCARD})
.setSymbol(definitions.SCALA)
.setType(definitions.UNIT_TYPE);
startContext.imports = new ImportList(
- importscala, new Scope(), startContext.imports);
+ importscala, new Scope(), startContext.imports);
}
if (!global.noimports && !global.nopredefs) {
TreeFactory make = global.make;
- Tree scala = make.Ident(Position.NOPOS, Names.scala)
+ Tree scala = make.Ident(Position.NOPOS, Names.scala)
.setSymbol(definitions.SCALA)
.setType(Type.singleType(definitions.ROOT_TYPE, definitions.SCALA));
- Symbol scalaPredefSym = definitions.getModule(Names.scala_Predef);
- Tree scalaPredef = make.Select(Position.NOPOS, scala, Names.Predef)
- .setSymbol(scalaPredefSym)
- .setType(Type.singleType(scala.type, scalaPredefSym));
-
- Tree importscalaPredef = make.Import(
- Position.NOPOS, scalaPredef, new Name[]{Names.WILDCARD})
- .setSymbol(scalaPredefSym)
+ Symbol scalaPredefSym = definitions.getModule(Names.scala_Predef);
+ Tree scalaPredef = make.Select(Position.NOPOS, scala, Names.Predef)
+ .setSymbol(scalaPredefSym)
+ .setType(Type.singleType(scala.type, scalaPredefSym));
+
+ Tree importscalaPredef = make.Import(
+ Position.NOPOS, scalaPredef, new Name[]{Names.WILDCARD})
+ .setSymbol(scalaPredefSym)
.setType(definitions.UNIT_TYPE);
startContext.imports = new ImportList(
- importscalaPredef, new Scope(), startContext.imports);
+ importscalaPredef, new Scope(), startContext.imports);
}
this.consoleContext = new Context(
- Tree.Empty,
- definitions.ROOT_CLASS,
- definitions.ROOT_CLASS.members(),
- startContext);
+ Tree.Empty,
+ definitions.ROOT_CLASS,
+ definitions.ROOT_CLASS.members(),
+ startContext);
}
public void addConsoleImport(Global global, Symbol module) {
@@ -115,7 +115,11 @@ public class AnalyzerPhase extends PhaseDescriptor {
}
public void apply(Global global) {
- new Analyzer(global, this).apply();
+ new Analyzer(global, this).apply();
+ }
+
+ public void apply(Unit unit) {
+ new Analyzer(unit.global, this).apply(unit);
}
public void lateEnter(Global global, Unit unit, Symbol symbol) {
@@ -127,7 +131,7 @@ public class AnalyzerPhase extends PhaseDescriptor {
new CheckSymbols(global),
new CheckTypes(global),
new CheckOwners(global),
- new CheckNames(global)
+ new CheckNames(global)
};
}
}
diff --git a/sources/scalac/typechecker/RefCheckPhase.java b/sources/scalac/typechecker/RefCheckPhase.java
index d1d93501e9..bfaa1e4fc4 100644
--- a/sources/scalac/typechecker/RefCheckPhase.java
+++ b/sources/scalac/typechecker/RefCheckPhase.java
@@ -27,7 +27,11 @@ public class RefCheckPhase extends PhaseDescriptor {
}
public void apply(Global global) {
- new RefCheck(global).apply();
+ new RefCheck(global).apply();
+ }
+
+ public void apply(Unit unit) {
+ new RefCheck(unit.global).apply(unit);
}
public Checker[] postCheckers(Global global) {
@@ -35,7 +39,7 @@ public class RefCheckPhase extends PhaseDescriptor {
new CheckSymbols(global),
new CheckTypes(global),
new CheckOwners(global),
- new CheckNames(global)
+ new CheckNames(global)
};
}
}