summaryrefslogtreecommitdiff
path: root/sources/scalac/typechecker
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 /sources/scalac/typechecker
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.
Diffstat (limited to 'sources/scalac/typechecker')
-rw-r--r--sources/scalac/typechecker/AnalyzerPhase.java54
-rw-r--r--sources/scalac/typechecker/RefCheckPhase.java8
2 files changed, 35 insertions, 27 deletions
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)
};
}
}