diff options
author | Martin Odersky <odersky@gmail.com> | 2004-07-01 14:03:41 +0000 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2004-07-01 14:03:41 +0000 |
commit | cffaae565155f3ffa95865dc469c1a1d7cbe0498 (patch) | |
tree | 4db08d4a30af008e2deeb4ee2ea45f0d69aa7654 /sources/scalac | |
parent | c8065927475a558d9ad4580dedcc1b91296f9da4 (diff) | |
download | scala-cffaae565155f3ffa95865dc469c1a1d7cbe0498.tar.gz scala-cffaae565155f3ffa95865dc469c1a1d7cbe0498.tar.bz2 scala-cffaae565155f3ffa95865dc469c1a1d7cbe0498.zip |
*** empty log message ***
Diffstat (limited to 'sources/scalac')
47 files changed, 152 insertions, 126 deletions
diff --git a/sources/scalac/Global.java b/sources/scalac/Global.java index 9252c96c67..9b50265f06 100644 --- a/sources/scalac/Global.java +++ b/sources/scalac/Global.java @@ -92,7 +92,7 @@ public abstract class Global { /** all compilation units */ - public Unit[] units; + public CompilationUnit[] units; /** the class path */ @@ -342,13 +342,13 @@ public abstract class Global { for (int i = 0; i < files.length; i++) { try { SourceFile source = getSourceFile(files[i]); - units.add(new Unit(this, source, console)); + units.add(new CompilationUnit(this, source, console)); compiledUnits.add(source); } catch (IOException exception) { error(exception.getMessage()); } } - this.units = (Unit[])units.toArray(new Unit[units.size()]); + this.units = (CompilationUnit[])units.toArray(new CompilationUnit[units.size()]); compile(); } @@ -363,7 +363,7 @@ public abstract class Global { reporter.resetCounters(); SourceFile source = getSourceFile(filename, input); compiledUnits.add(source); - units = new Unit[]{new Unit(this, source, console)}; + units = new CompilationUnit[]{new CompilationUnit(this, source, console)}; compile(); } @@ -406,11 +406,11 @@ public abstract class Global { public void compileLate(SourceFile source, boolean mixinOnly) { if (!compiledUnits.contains(source)) { compiledUnits.add(source); - Unit unit = new Unit(this, source, false, mixinOnly); + CompilationUnit unit = new CompilationUnit(this, source, false, mixinOnly); Phase backup = currentPhase; // !!! add code to print/skip/graph as in compile currentPhase = PHASE.PARSER.phase(); - PHASE.PARSER.phase().apply(new Unit[] {unit}); + PHASE.PARSER.phase().apply(new CompilationUnit[] {unit}); currentPhase = PHASE.ANALYZER.phase(); ((AnalyzerPhase)PHASE.ANALYZER.phase()).lateEnter(unit); // !!! add code for later phases? @@ -499,7 +499,7 @@ public abstract class Global { prevPhase(); } - private void fix1(Unit unit) { + private void fix1(CompilationUnit unit) { unit.body = new Tree[] { make.ModuleDef(Position.FIRSTPOS, 0, Name.fromString(CONSOLE_S+module), Tree.Empty, @@ -519,7 +519,7 @@ public abstract class Global { } } - private void fix2(Unit unit) { + private void fix2(CompilationUnit unit) { imports.clear(); for (int i = 0; i < unit.body.length; i++) { switch (unit.body[i]) { diff --git a/sources/scalac/Phase.java b/sources/scalac/Phase.java index bd748a876e..778ea7ca26 100644 --- a/sources/scalac/Phase.java +++ b/sources/scalac/Phase.java @@ -64,7 +64,7 @@ public abstract class Phase { } /** Applies this phase to the given compilation units. */ - public abstract void apply(Unit[] units); + public abstract void apply(CompilationUnit[] units); /** Graphs all compilation units. */ public void graph(Global global) { @@ -72,7 +72,7 @@ public abstract class Phase { } /** Graphs the result of this phase for the given compilation unit. */ - public void graph(Unit unit) { + public void graph(CompilationUnit unit) { // !!! new scala.compiler.gdl.TreePrinter().printInFile( // !!! unit, unit.source + "-" + name() + ".gdl"); } @@ -83,7 +83,7 @@ public abstract class Phase { } /** Check the result of this phase for the given compilation unit. */ - public void check(Unit unit) { + public void check(CompilationUnit unit) { Checker[] checkers = postCheckers(unit.global); for (int i = 0; i < checkers.length; i++) checkers[i].traverse(unit); } diff --git a/sources/scalac/Unit.java b/sources/scalac/Unit.java index fd3c77a086..44e131bed7 100644 --- a/sources/scalac/Unit.java +++ b/sources/scalac/Unit.java @@ -22,7 +22,7 @@ import java.util.HashMap; * @author Matthias Zenger * @version 1.0 */ -public class Unit { +public class CompilationUnit { /** the global compilation environment */ @@ -49,7 +49,7 @@ public class Unit { public Tree[] body; public ARepository repository; - public Unit(Global global, SourceFile source, + public CompilationUnit(Global global, SourceFile source, boolean console, boolean mixinOnly) { this.global = global; this.source = source; @@ -58,7 +58,7 @@ public class Unit { this.fresh = new FreshNameCreator(); } - public Unit(Global global, SourceFile source, boolean console) { + public CompilationUnit(Global global, SourceFile source, boolean console) { this(global, source, console, false); } diff --git a/sources/scalac/ast/Transformer.java.tmpl b/sources/scalac/ast/Transformer.java.tmpl index c13ad02a1d..189a8a8d6d 100644 --- a/sources/scalac/ast/Transformer.java.tmpl +++ b/sources/scalac/ast/Transformer.java.tmpl @@ -9,7 +9,7 @@ package scalac.ast; import scalac.Global; -import scalac.Unit; +import scalac.CompilationUnit; import scalac.symtab.Type; {#Imports#} @@ -55,11 +55,11 @@ public class Transformer { //######################################################################## // Public Methods - public void apply(Unit[] units) { + public void apply(CompilationUnit[] units) { for (int i = 0; i < units.length; i++) apply(units[i]); } - public void apply(Unit unit) { + public void apply(CompilationUnit unit) { unit.global.log("transforming " + unit); unit.body = transform(unit.body); } @@ -111,12 +111,12 @@ public class GenTransformer { // Public Methods /** Transforms the given units. */ - public void apply(Unit[] units) { + public void apply(CompilationUnit[] units) { for (int i = 0; i < units.length; i++) apply(units[i]); } /** Transforms the given unit. */ - public void apply(Unit unit) { + public void apply(CompilationUnit unit) { unit.global.log("transforming " + unit); unit.body = transform(unit.body); } diff --git a/sources/scalac/ast/Traverser.java.tmpl b/sources/scalac/ast/Traverser.java.tmpl index 1266e39f5c..a17768e2b4 100644 --- a/sources/scalac/ast/Traverser.java.tmpl +++ b/sources/scalac/ast/Traverser.java.tmpl @@ -8,7 +8,7 @@ package scalac.ast; -import scalac.Unit; +import scalac.CompilationUnit; {#Imports#} /** Class to traverse a tree without modifying it. */ @@ -17,11 +17,11 @@ public class Traverser { //######################################################################## // Public Methods - public void traverse(Unit[] units) { + public void traverse(CompilationUnit[] units) { for (int i = 0; i < units.length; i++) traverse(units[i]); } - public void traverse(Unit unit) { + public void traverse(CompilationUnit unit) { traverse(unit.body); } diff --git a/sources/scalac/ast/printer/TreePrinter.java b/sources/scalac/ast/printer/TreePrinter.java index 53ce4bd3cb..ce6ae2bd18 100644 --- a/sources/scalac/ast/printer/TreePrinter.java +++ b/sources/scalac/ast/printer/TreePrinter.java @@ -9,7 +9,7 @@ package scalac.ast.printer; import scalac.Global; -import scalac.Unit; +import scalac.CompilationUnit; import scalac.ast.Tree; /** @@ -24,7 +24,7 @@ public interface TreePrinter { public void flush(); public void print(Global global); - public void print(Unit unit); + public void print(CompilationUnit unit); public TreePrinter print(Tree tree); public TreePrinter print(String str); diff --git a/sources/scalac/atree/ATreeFromSTree.java b/sources/scalac/atree/ATreeFromSTree.java index 5cd902c7dc..ba5cb03155 100644 --- a/sources/scalac/atree/ATreeFromSTree.java +++ b/sources/scalac/atree/ATreeFromSTree.java @@ -13,7 +13,7 @@ import java.util.ArrayList; import java.util.Map; import java.util.HashMap; -import scalac.Unit; +import scalac.CompilationUnit; import scalac.ast.Tree; import scalac.ast.Tree.Ident; import scalac.ast.Tree.Template; @@ -74,7 +74,7 @@ public class ATreeFromSTree { // Public Methods - Translating units /** Translates the unit's body and stores the result in it. */ - public void translate(Unit unit) { + public void translate(CompilationUnit unit) { template(unit.repository = new ARepository(), unit.body); } diff --git a/sources/scalac/atree/ATreePrinter.java b/sources/scalac/atree/ATreePrinter.java index f68df2e09f..44098d3332 100644 --- a/sources/scalac/atree/ATreePrinter.java +++ b/sources/scalac/atree/ATreePrinter.java @@ -12,7 +12,7 @@ import ch.epfl.lamp.util.CodePrinter; import scalac.Global; import scalac.Phase; -import scalac.Unit; +import scalac.CompilationUnit; import scalac.symtab.Type; import scalac.symtab.Symbol; import scalac.symtab.SymbolTablePrinter; @@ -247,13 +247,13 @@ public class ATreePrinter { } /** Prints the units. */ - public ATreePrinter printUnits(Unit[] units) { + public ATreePrinter printUnits(CompilationUnit[] units) { for (int i = 0; i < units.length; i++) printUnit(units[i]); return this; } /** Prints the unit. */ - public ATreePrinter printUnit(Unit unit) { + public ATreePrinter printUnit(CompilationUnit unit) { println("// Scala source: " + unit.source); return printRepository(unit.repository); } diff --git a/sources/scalac/backend/jvm/GenJVM.java b/sources/scalac/backend/jvm/GenJVM.java index d71dd912bd..d9dc030646 100644 --- a/sources/scalac/backend/jvm/GenJVM.java +++ b/sources/scalac/backend/jvm/GenJVM.java @@ -115,7 +115,7 @@ class GenJVM { /** * Generate code for the given unit. */ - public void translate(Unit unit) { + public void translate(CompilationUnit unit) { try { for (int i = 0; i < unit.body.length; ++i) gen(Context.EMPTY.withSourceFileName(unit.source.getFile().getName()), diff --git a/sources/scalac/backend/jvm/GenJVMPhase.java b/sources/scalac/backend/jvm/GenJVMPhase.java index 9fb1c72e89..eb02e0645c 100644 --- a/sources/scalac/backend/jvm/GenJVMPhase.java +++ b/sources/scalac/backend/jvm/GenJVMPhase.java @@ -11,7 +11,7 @@ package scalac.backend.jvm; import scalac.Global; import scalac.Phase; import scalac.PhaseDescriptor; -import scalac.Unit; +import scalac.CompilationUnit; /** * Phase to generate Java bytecodes using the FJBG library. @@ -41,7 +41,7 @@ public class GenJVMPhase extends Phase { // Public Methods /** Applies this phase to the given compilation units. */ - public void apply(Unit[] units) { + public void apply(CompilationUnit[] units) { for (int i = 0; i < units.length; i++) translator.translate(units[i]); } diff --git a/sources/scalac/backend/msil/GenMSIL.java b/sources/scalac/backend/msil/GenMSIL.java index 867f175209..c1c890442a 100644 --- a/sources/scalac/backend/msil/GenMSIL.java +++ b/sources/scalac/backend/msil/GenMSIL.java @@ -9,7 +9,7 @@ package scalac.backend.msil; import scalac.Global; -import scalac.Unit; +import scalac.CompilationUnit; import scalac.util.Debug; @@ -92,13 +92,13 @@ public final class GenMSIL { } // keeps track of the current compilation unit for better error reporting - private Unit currUnit; + private CompilationUnit currUnit; /** * The main entry point into the code generator. Called from GenMSILPhase * for every compilation unit. */ - public void apply(Unit unit) { + public void apply(CompilationUnit unit) { currUnit = unit; // try { for (int i = 0; i < unit.body.length; i++) { diff --git a/sources/scalac/backend/msil/GenMSILPhase.java b/sources/scalac/backend/msil/GenMSILPhase.java index 86d0b63307..a12a0c2d52 100644 --- a/sources/scalac/backend/msil/GenMSILPhase.java +++ b/sources/scalac/backend/msil/GenMSILPhase.java @@ -11,7 +11,7 @@ package scalac.backend.msil; import scalac.Global; import scalac.Phase; import scalac.PhaseDescriptor; -import scalac.Unit; +import scalac.CompilationUnit; import java.util.HashMap; @@ -45,7 +45,7 @@ public class GenMSILPhase extends Phase { // Public Methods /** Applies this phase to the given compilation units. */ - public void apply(Unit[] units) { + public void apply(CompilationUnit[] units) { tc.init(); tc.collectSymbols(units); tc.initAssembly(); diff --git a/sources/scalac/backend/msil/TypeCreator.java b/sources/scalac/backend/msil/TypeCreator.java index 1e8cd25384..35c01d4615 100644 --- a/sources/scalac/backend/msil/TypeCreator.java +++ b/sources/scalac/backend/msil/TypeCreator.java @@ -9,7 +9,7 @@ package scalac.backend.msil; import scalac.Global; -import scalac.Unit; +import scalac.CompilationUnit; import scalac.ApplicationError; import scalac.ast.Tree; import scalac.ast.Traverser; @@ -442,7 +442,7 @@ final class TypeCreator { return moreThanOneEntryPoint; } - private Unit entryPointUnit; + private CompilationUnit entryPointUnit; private int entryPointPos; @@ -450,7 +450,7 @@ final class TypeCreator { * - collects all entry points * - gives the name of the new assembly */ - public void collectSymbols(Unit[] units) { + public void collectSymbols(CompilationUnit[] units) { types2create.clear(); entryPoint = null; new CollectSymbols().traverse(units); @@ -491,8 +491,8 @@ final class TypeCreator { * in the program and all entry points. */ private final class CollectSymbols extends Traverser { - private Unit currUnit; - public void traverse(Unit unit) { + private CompilationUnit currUnit; + public void traverse(CompilationUnit unit) { currUnit = unit; if (entryPointUnit == null) entryPointUnit = unit; diff --git a/sources/scalac/checkers/TreeChecker.java b/sources/scalac/checkers/TreeChecker.java index 3b140293a5..bc38e3eafb 100644 --- a/sources/scalac/checkers/TreeChecker.java +++ b/sources/scalac/checkers/TreeChecker.java @@ -15,7 +15,7 @@ import java.util.Stack; import scala.tools.util.Position; -import scalac.Unit; +import scalac.CompilationUnit; import scalac.ast.Tree; import scalac.ast.Tree.AbsTypeDef; import scalac.ast.Tree.Ident; @@ -41,7 +41,7 @@ public class TreeChecker { private final Definitions definitions; /** The stack of current units */ - private final Stack/*<Unit>*/ units = new Stack(); + private final Stack/*<CompilationUnit>*/ units = new Stack(); /** The stack of current classes */ private final Stack/*<Symbol>*/ classes = new Stack(); @@ -76,7 +76,7 @@ public class TreeChecker { // Public Methods - Checking units /** Checks the unit. Returns true. */ - public boolean check(Unit unit) { + public boolean check(CompilationUnit unit) { pushUnit(unit); template(unit.body); popUnit(); @@ -507,8 +507,8 @@ public class TreeChecker { // Private Methods - Managing current context /** Returns the current unit. */ - private Unit currentUnit() { - return units.size() > 0 ? (Unit)units.peek() : null; + private CompilationUnit currentUnit() { + return units.size() > 0 ? (CompilationUnit)units.peek() : null; } /** Returns the current class. */ @@ -527,7 +527,7 @@ public class TreeChecker { } /** Sets the current unit to the given one. */ - private void pushUnit(Unit unit) { + private void pushUnit(CompilationUnit unit) { assert units.size() == 0: showPush(unit); assert classes.size() == 0: showPush(unit); assert members.size() == 0: showPush(unit); diff --git a/sources/scalac/symtab/Symbol.java b/sources/scalac/symtab/Symbol.java index 899aee8749..6c5ef821d0 100644 --- a/sources/scalac/symtab/Symbol.java +++ b/sources/scalac/symtab/Symbol.java @@ -1227,6 +1227,7 @@ public abstract class Symbol implements Modifiers, Kinds { private Type transformInfo(Phase phase, Type info) { Global global = phase.global; Phase current = global.currentPhase; + boolean keepInheritedOverloaded = current.id <= global.PHASE.REFCHECK.id(); switch (info) { case ErrorType: case NoType: @@ -1237,7 +1238,8 @@ public abstract class Symbol implements Modifiers, Kinds { boolean altChanged = false; for (int i = 0; i < alts.length; i++) { Type type = alts[i].info(); - if (alts[i].owner() == owner()) n++; + if (keepInheritedOverloaded || + alts[i].owner() == owner()) n++; if (alts[i].info() != alttypes[i]) altChanged = true; } Type result; @@ -1246,7 +1248,8 @@ public abstract class Symbol implements Modifiers, Kinds { Type[] types = new Type[n]; int j = 0; for (int i = 0; i < alts.length; i++) { - if (alts[i].owner() == owner()) { + if (keepInheritedOverloaded || + alts[i].owner() == owner()) { symbols[j] = alts[i]; types[j] = alts[i].info(); j++; @@ -1663,24 +1666,21 @@ public abstract class Symbol implements Modifiers, Kinds { } public void addInheritedOverloaded(Type owntype) { - if (owner().kind == CLASS && !isConstructor() && owner().lookup(name) == this) { - // it's a class member which is not an overloaded alternative - Symbol sym = Type.lookupNonPrivate(owner().parents(), name); - if (sym.kind == VAL) { - Type symtype = owner.thisType().memberType(sym); - switch (symtype) { - case OverloadedType(Symbol[] alts, Type[] alttypes): - for (int i = 0; i < alts.length; i++) - addInheritedOverloaded(owntype, alts[i], alttypes[i]); - break; - default: - addInheritedOverloaded(owntype, sym, symtype); - } - } - } + Symbol sym = Type.lookupNonPrivate(owner.parents(), name); + if (sym.kind == VAL) { + Type symtype = owner.thisType().memberType(sym); + switch (symtype) { + case OverloadedType(Symbol[] alts, Type[] alttypes): + for (int i = 0; i < alts.length; i++) + addInheritedOverloaded(owntype, alts[i], alttypes[i]); + break; + default: + addInheritedOverloaded(owntype, sym, symtype); + } + } } - private void addInheritedOverloaded(Type owntype, Symbol sym, Type symtype) { + public void addInheritedOverloaded(Type owntype, Symbol sym, Type symtype) { if (!owntype.overrides(symtype)) { if (Global.instance.debug) Global.instance.log(owner() + " inherits overloaded: " + sym + ":" + symtype + sym.locationString());//debug owner().members().lookupEntry(name).setSymbol(overloadWith(sym)); diff --git a/sources/scalac/symtab/classfile/ClassfileParser.java b/sources/scalac/symtab/classfile/ClassfileParser.java index 5220e7d69a..a3470f4964 100644 --- a/sources/scalac/symtab/classfile/ClassfileParser.java +++ b/sources/scalac/symtab/classfile/ClassfileParser.java @@ -144,7 +144,23 @@ public class ClassfileParser implements ClassfileConstants { //System.out.println("module: " + m); //System.out.println("modules class: " + m.type().symbol()); + int savedFlags = c.flags; + c.flags |= Modifiers.INITIALIZED; + // hack to make memberType in addInheritedOverloaded work + addInheritedOverloaded(); + + //if (global.debug) { + // Symbol[] elems = c.members().elements(); + // global.log(c + " defines: "); + // for (int i = 0; i < elems.length; i++) { + // global.log(elems[i] + ":" + elems[i].type()); + // } + //} + + c.flags = savedFlags; + // Add static members of superclass + // todo: remove Symbol superclass = supertpe.symbol(); if (m.isJava() && superclass.isJava()) { Symbol mclass = m.moduleClass(); @@ -172,6 +188,18 @@ public class ClassfileParser implements ClassfileConstants { } } + private void addInheritedOverloaded() { + Symbol[] elems = c.members().elements(); + for (int i = 0; i < elems.length; i++) + addInheritedOverloaded(elems[i]); + } + + private void addInheritedOverloaded(Symbol sym) { + if (sym.isMethod() && !sym.isConstructor()) { + sym.addInheritedOverloaded(sym.type()); + } + } + /** convert Java modifiers into Scala flags */ public int transFlags(int flags) { @@ -253,7 +281,6 @@ public class ClassfileParser implements ClassfileConstants { symbol = owner.newTerm(Position.NOPOS, sflags, name); } setParamOwners(type, symbol); - symbol.addInheritedOverloaded(type); symbol.setInfo(type); attrib.readAttributes(symbol, type, METH_ATTR); if (name != CONSTR_N) { diff --git a/sources/scalac/symtab/classfile/UnPickle.java b/sources/scalac/symtab/classfile/UnPickle.java index 1c41932a6d..fe11fced85 100644 --- a/sources/scalac/symtab/classfile/UnPickle.java +++ b/sources/scalac/symtab/classfile/UnPickle.java @@ -307,7 +307,6 @@ public class UnPickle implements Kinds, Modifiers, EntryTags, TypeTags { assert clasz == sym.moduleClass(): Debug.show(sym); } Type owntype = getType(inforef, sym); - sym.addInheritedOverloaded(owntype); sym.setInfo(owntype); break; diff --git a/sources/scalac/transformer/AddAccessorsPhase.java b/sources/scalac/transformer/AddAccessorsPhase.java index c33c405c25..e1a4e4e278 100644 --- a/sources/scalac/transformer/AddAccessorsPhase.java +++ b/sources/scalac/transformer/AddAccessorsPhase.java @@ -15,7 +15,7 @@ import java.util.HashMap; import scalac.Global; import scalac.Phase; import scalac.PhaseDescriptor; -import scalac.Unit; +import scalac.CompilationUnit; import scalac.ast.Transformer; import scalac.ast.Tree; import scalac.ast.Tree.Template; @@ -46,7 +46,7 @@ public class AddAccessorsPhase extends Phase { // Public Methods /** Applies this phase to the given compilation units. */ - public void apply(Unit[] units) { + public void apply(CompilationUnit[] units) { treeTransformer.apply(units); } diff --git a/sources/scalac/transformer/AddConstructorsPhase.java b/sources/scalac/transformer/AddConstructorsPhase.java index 0e72320509..a60842da9f 100644 --- a/sources/scalac/transformer/AddConstructorsPhase.java +++ b/sources/scalac/transformer/AddConstructorsPhase.java @@ -14,7 +14,7 @@ import java.util.HashMap; import scalac.Global; import scalac.Phase; import scalac.PhaseDescriptor; -import scalac.Unit; +import scalac.CompilationUnit; import scalac.symtab.Symbol; import scalac.symtab.Type; import scalac.util.Debug; @@ -55,7 +55,7 @@ public class AddConstructorsPhase extends Phase { } /** Applies this phase to the given compilation units. */ - public void apply(Unit[] units) { + public void apply(CompilationUnit[] units) { for (int i = 0; i < units.length; i++) new AddConstructors(global, constructors).apply(units[i]); } diff --git a/sources/scalac/transformer/AddInterfacesPhase.java b/sources/scalac/transformer/AddInterfacesPhase.java index 396d3cf238..9b7ebf6675 100644 --- a/sources/scalac/transformer/AddInterfacesPhase.java +++ b/sources/scalac/transformer/AddInterfacesPhase.java @@ -25,7 +25,7 @@ public class AddInterfacesPhase extends Phase { } /** Applies this phase to the given compilation units. */ - public void apply(Unit[] units) { + public void apply(CompilationUnit[] units) { for (int i = 0; i < units.length; i++) new AddInterfaces(global, this).apply(units[i]); } diff --git a/sources/scalac/transformer/Erasure.java b/sources/scalac/transformer/Erasure.java index e78de5d343..4189834d1b 100644 --- a/sources/scalac/transformer/Erasure.java +++ b/sources/scalac/transformer/Erasure.java @@ -17,7 +17,7 @@ import java.util.HashSet; import scalac.Global; import scalac.Phase; -import scalac.Unit; +import scalac.CompilationUnit; import scalac.ast.Tree; import scalac.ast.Tree.Ident; import scalac.ast.Tree.Template; @@ -82,7 +82,7 @@ public class Erasure extends GenTransformer implements Modifiers { private final Primitives primitives; /** The current unit */ - private Unit unit; + private CompilationUnit unit; private final boolean forMSIL; @@ -101,7 +101,7 @@ public class Erasure extends GenTransformer implements Modifiers { // Public Methods /** Transforms the given unit. */ - public void apply(Unit unit) { + public void apply(CompilationUnit unit) { this.unit = unit; super.apply(unit); } diff --git a/sources/scalac/transformer/ErasurePhase.java b/sources/scalac/transformer/ErasurePhase.java index 5fccaf4659..0f114aa771 100644 --- a/sources/scalac/transformer/ErasurePhase.java +++ b/sources/scalac/transformer/ErasurePhase.java @@ -12,7 +12,7 @@ package scalac.transformer; import scalac.Global; import scalac.Phase; import scalac.PhaseDescriptor; -import scalac.Unit; +import scalac.CompilationUnit; import scalac.backend.Primitive; import scalac.backend.Primitives; import scalac.checkers.Checker; @@ -48,7 +48,7 @@ public class ErasurePhase extends Phase { //######################################################################## // Public Methods - public void apply(Unit[] units) { + public void apply(CompilationUnit[] units) { erasure.apply(units); } diff --git a/sources/scalac/transformer/ExpandMixinsPhase.java b/sources/scalac/transformer/ExpandMixinsPhase.java index 410a19f56a..e43ed7b975 100644 --- a/sources/scalac/transformer/ExpandMixinsPhase.java +++ b/sources/scalac/transformer/ExpandMixinsPhase.java @@ -20,7 +20,7 @@ import java.util.LinkedList; import scalac.Global; import scalac.Phase; import scalac.PhaseDescriptor; -import scalac.Unit; +import scalac.CompilationUnit; import scalac.ast.Tree; import scalac.ast.Tree.Template; import scalac.ast.TreeGen; @@ -93,7 +93,7 @@ public class ExpandMixinsPhase extends Phase { // Public Methods /** Applies this phase to the given compilation units. */ - public void apply(Unit[] units) { + public void apply(CompilationUnit[] units) { collector.traverse(units); expander.apply(units); } @@ -146,7 +146,7 @@ public class ExpandMixinsPhase extends Phase { public TreeExpander(Global global) { super(global); } - public void apply(Unit unit) { + public void apply(CompilationUnit unit) { if (unit.mixinOnly) { assert Debug.log("removing unit " + unit); unit.body = Tree.EMPTY_ARRAY; diff --git a/sources/scalac/transformer/ExplicitOuterClassesPhase.java b/sources/scalac/transformer/ExplicitOuterClassesPhase.java index 4f0ed688f5..c79ff1ae29 100644 --- a/sources/scalac/transformer/ExplicitOuterClassesPhase.java +++ b/sources/scalac/transformer/ExplicitOuterClassesPhase.java @@ -15,7 +15,7 @@ import java.util.Iterator; import scalac.Global; import scalac.Phase; import scalac.PhaseDescriptor; -import scalac.Unit; +import scalac.CompilationUnit; import scalac.ast.GenTransformer; import scalac.ast.Tree; import scalac.ast.Tree.Ident; @@ -69,7 +69,7 @@ public class ExplicitOuterClassesPhase extends Phase { // Public Methods /** Applies this phase to the given compilation units. */ - public void apply(Unit[] units) { + public void apply(CompilationUnit[] units) { treeTransformer.apply(units); } diff --git a/sources/scalac/transformer/ICodePhase.java b/sources/scalac/transformer/ICodePhase.java index d47e518374..cc1e065389 100644 --- a/sources/scalac/transformer/ICodePhase.java +++ b/sources/scalac/transformer/ICodePhase.java @@ -11,7 +11,7 @@ package scalac.transformer; import scalac.Global; import scalac.Phase; import scalac.PhaseDescriptor; -import scalac.Unit; +import scalac.CompilationUnit; import scalac.checkers.TreeChecker; import scalac.symtab.Definitions; @@ -46,7 +46,7 @@ public class ICodePhase extends Phase { // Public Methods /** Applies this phase to the given compilation units. */ - public void apply(Unit[] units) { + public void apply(CompilationUnit[] units) { // This java version doesn't make anything } diff --git a/sources/scalac/transformer/LambdaLift.java b/sources/scalac/transformer/LambdaLift.java index ea4080a0ef..f1f0949146 100644 --- a/sources/scalac/transformer/LambdaLift.java +++ b/sources/scalac/transformer/LambdaLift.java @@ -38,7 +38,7 @@ public class LambdaLift extends OwnerTransformer final Definitions definitions; final FreeVars free; final LambdaLiftPhase descr; - private Unit unit; + private CompilationUnit unit; public LambdaLift(Global global, LambdaLiftPhase descr) { super(global); @@ -48,7 +48,7 @@ public class LambdaLift extends OwnerTransformer this.descr = descr; } - public void apply(Unit unit) { + public void apply(CompilationUnit unit) { this.unit = unit; global.log(unit.source.toString()); free.initialize(unit); @@ -108,7 +108,7 @@ public class LambdaLift extends OwnerTransformer */ static class FreeVars extends OwnerTransformer { - private Unit unit; + private CompilationUnit unit; public FreeVars(Global global) { super(global); @@ -305,7 +305,7 @@ public class LambdaLift extends OwnerTransformer /** Compute a mapping from symbols to their free variables * in hashtable `fvs'. Also rename all variables that need it. */ - public void initialize(Unit unit) { + public void initialize(CompilationUnit unit) { this.unit = unit; fvs = new HashMap(); ftvs = new HashMap(); diff --git a/sources/scalac/transformer/LambdaLiftPhase.java b/sources/scalac/transformer/LambdaLiftPhase.java index a60285dd99..01ee98bbda 100644 --- a/sources/scalac/transformer/LambdaLiftPhase.java +++ b/sources/scalac/transformer/LambdaLiftPhase.java @@ -23,7 +23,7 @@ public class LambdaLiftPhase extends Phase implements Kinds, Modifiers { } /** Applies this phase to the given compilation units. */ - public void apply(Unit[] units) { + public void apply(CompilationUnit[] units) { for (int i = 0; i < units.length; i++) new LambdaLift(global, this).apply(units[i]); } diff --git a/sources/scalac/transformer/MakeBoxingExplicitPhase.java b/sources/scalac/transformer/MakeBoxingExplicitPhase.java index 4639dd65ea..e4d6f956b1 100644 --- a/sources/scalac/transformer/MakeBoxingExplicitPhase.java +++ b/sources/scalac/transformer/MakeBoxingExplicitPhase.java @@ -11,7 +11,7 @@ package scalac.transformer; import scalac.Global; import scalac.Phase; import scalac.PhaseDescriptor; -import scalac.Unit; +import scalac.CompilationUnit; import scalac.checkers.TreeChecker; import scalac.symtab.Definitions; @@ -41,7 +41,7 @@ public class MakeBoxingExplicitPhase extends Phase { // Public Methods /** Applies this phase to the given compilation units. */ - public void apply(Unit[] units) { + public void apply(CompilationUnit[] units) { for (int i = 0; i < units.length; i++) { assert checker.check(units[i]); new scalac.atree.ATreeFromSTree(global.definitions) diff --git a/sources/scalac/transformer/OwnerTransformer.java b/sources/scalac/transformer/OwnerTransformer.java index 7a6663f613..e8f0355ffb 100644 --- a/sources/scalac/transformer/OwnerTransformer.java +++ b/sources/scalac/transformer/OwnerTransformer.java @@ -30,7 +30,7 @@ public class OwnerTransformer extends Transformer { super(global); } - public void apply(Unit unit) { + public void apply(CompilationUnit unit) { currentOwner = global.definitions.ROOT_CLASS; unit.body = transform(unit.body); } diff --git a/sources/scalac/transformer/TailCallPhase.java b/sources/scalac/transformer/TailCallPhase.java index 57857bc3c4..667e906112 100644 --- a/sources/scalac/transformer/TailCallPhase.java +++ b/sources/scalac/transformer/TailCallPhase.java @@ -11,7 +11,7 @@ package scalac.transformer; import scalac.Global; import scalac.Phase; import scalac.PhaseDescriptor; -import scalac.Unit; +import scalac.CompilationUnit; import scalac.ast.Tree; import scalac.ast.GenTransformer; import scalac.symtab.Symbol; @@ -61,7 +61,7 @@ public class TailCallPhase extends Phase { // Public Methods /** Applies this phase to the given compilation units. */ - public void apply(Unit[] units) { + public void apply(CompilationUnit[] units) { treeTransformer.apply(units); } diff --git a/sources/scalac/transformer/TypesAsValuesPhase.java b/sources/scalac/transformer/TypesAsValuesPhase.java index 5f672841f2..d3147ad981 100644 --- a/sources/scalac/transformer/TypesAsValuesPhase.java +++ b/sources/scalac/transformer/TypesAsValuesPhase.java @@ -15,7 +15,7 @@ import java.util.Iterator; import scalac.Global; import scalac.Phase; import scalac.PhaseDescriptor; -import scalac.Unit; +import scalac.CompilationUnit; import scalac.symtab.Definitions; import scalac.symtab.Scope; import scalac.symtab.Symbol; @@ -194,7 +194,7 @@ public class TypesAsValuesPhase extends Phase { throw new Error(); // TODO } - public void apply(Unit[] units) { + public void apply(CompilationUnit[] units) { transformer.apply(units); } diff --git a/sources/scalac/transformer/UnCurry.java b/sources/scalac/transformer/UnCurry.java index 9eadc4d85f..cf2cc46afc 100644 --- a/sources/scalac/transformer/UnCurry.java +++ b/sources/scalac/transformer/UnCurry.java @@ -35,14 +35,14 @@ public class UnCurry extends OwnerTransformer implements Modifiers { UnCurryPhase descr; - Unit unit; + CompilationUnit unit; public UnCurry(Global global, UnCurryPhase descr) { super(global); this.descr = descr; } - public void apply(Unit unit) { + public void apply(CompilationUnit unit) { this.unit = unit; super.apply(unit); } diff --git a/sources/scalac/transformer/UnCurryPhase.java b/sources/scalac/transformer/UnCurryPhase.java index 79b96f0094..44988064de 100644 --- a/sources/scalac/transformer/UnCurryPhase.java +++ b/sources/scalac/transformer/UnCurryPhase.java @@ -21,7 +21,7 @@ public class UnCurryPhase extends Phase implements Modifiers { } /** Applies this phase to the given compilation units. */ - public void apply(Unit[] units) { + public void apply(CompilationUnit[] units) { for (int i = 0; i < units.length; i++) new UnCurry(global, this).apply(units[i]); } diff --git a/sources/scalac/transformer/matching/AlgebraicMatcher.java b/sources/scalac/transformer/matching/AlgebraicMatcher.java index 044767558c..957d2d3933 100644 --- a/sources/scalac/transformer/matching/AlgebraicMatcher.java +++ b/sources/scalac/transformer/matching/AlgebraicMatcher.java @@ -33,7 +33,7 @@ public class AlgebraicMatcher extends PatternMatcher { /** constructor */ - public AlgebraicMatcher( Unit unit ) { + public AlgebraicMatcher( CompilationUnit unit ) { super( unit ); this.delegateSequenceMatching = true; this.optimize = false; diff --git a/sources/scalac/transformer/matching/BerrySethi.java b/sources/scalac/transformer/matching/BerrySethi.java index 9e9186e1f8..e56fc548c3 100644 --- a/sources/scalac/transformer/matching/BerrySethi.java +++ b/sources/scalac/transformer/matching/BerrySethi.java @@ -2,7 +2,7 @@ package scalac.transformer.matching ; -import scalac.Unit ; +import scalac.CompilationUnit ; import scalac.ApplicationError ; import scalac.ast.Tree ; import scalac.ast.TreeInfo ; @@ -20,9 +20,9 @@ import java.util.* ; class BerrySethi { - Unit unit; + CompilationUnit unit; - public BerrySethi(Unit unit) { + public BerrySethi(CompilationUnit unit) { this.unit = unit; } diff --git a/sources/scalac/transformer/matching/BindingBerrySethi.java b/sources/scalac/transformer/matching/BindingBerrySethi.java index e68bef1eaf..69383fcbfa 100644 --- a/sources/scalac/transformer/matching/BindingBerrySethi.java +++ b/sources/scalac/transformer/matching/BindingBerrySethi.java @@ -1,6 +1,6 @@ package scalac.transformer.matching ; -import scalac.Unit; +import scalac.CompilationUnit; import scalac.Global ; import scalac.ApplicationError ; import scalac.ast.Tree ; @@ -20,7 +20,7 @@ import java.util.* ; public class BindingBerrySethi extends BerrySethi { - public BindingBerrySethi(Unit unit) { + public BindingBerrySethi(CompilationUnit unit) { super(unit); } diff --git a/sources/scalac/transformer/matching/CaseEnv.java b/sources/scalac/transformer/matching/CaseEnv.java index cfeb1f9b74..cc59ec052b 100644 --- a/sources/scalac/transformer/matching/CaseEnv.java +++ b/sources/scalac/transformer/matching/CaseEnv.java @@ -33,7 +33,7 @@ class CaseEnv { /** constructor */ - CaseEnv( Symbol owner, Unit unit ) { + CaseEnv( Symbol owner, CompilationUnit unit ) { this.owner = owner; this.defs = unit.global.definitions; this.gen = unit.global.treeGen; diff --git a/sources/scalac/transformer/matching/CodeFactory.java b/sources/scalac/transformer/matching/CodeFactory.java index 0f17b5d2b4..a74d2e50d7 100644 --- a/sources/scalac/transformer/matching/CodeFactory.java +++ b/sources/scalac/transformer/matching/CodeFactory.java @@ -21,7 +21,7 @@ class CodeFactory extends PatternTool { public int pos = Position.FIRSTPOS ; - public CodeFactory( Unit unit, int pos ) { + public CodeFactory( CompilationUnit unit, int pos ) { super( unit ); this.pos = pos; } diff --git a/sources/scalac/transformer/matching/PatternMatcher.java b/sources/scalac/transformer/matching/PatternMatcher.java index f5a0eda18f..4dd59ea4ea 100644 --- a/sources/scalac/transformer/matching/PatternMatcher.java +++ b/sources/scalac/transformer/matching/PatternMatcher.java @@ -50,7 +50,7 @@ public class PatternMatcher extends PatternTool { /** constructor */ - public PatternMatcher(Unit unit, Tree selector, + public PatternMatcher(CompilationUnit unit, Tree selector, Symbol owner, Type resultType) { super(unit); initialize(selector, owner, resultType, true); @@ -58,7 +58,7 @@ public class PatternMatcher extends PatternTool { /** constructor, used in subclass AlgebraicMatcher */ - protected PatternMatcher(Unit unit) { + protected PatternMatcher(CompilationUnit unit) { super(unit); } diff --git a/sources/scalac/transformer/matching/PatternNodeCreator.java b/sources/scalac/transformer/matching/PatternNodeCreator.java index 7d69c8f3e6..a1e6b27da0 100644 --- a/sources/scalac/transformer/matching/PatternNodeCreator.java +++ b/sources/scalac/transformer/matching/PatternNodeCreator.java @@ -21,7 +21,7 @@ public class PatternNodeCreator extends PatternTool { /** the owner of the variable symbols that might be created */ Symbol owner; - public PatternNodeCreator(Unit unit, Symbol owner) { + public PatternNodeCreator(CompilationUnit unit, Symbol owner) { super(unit); assert owner != null; this.owner = owner; diff --git a/sources/scalac/transformer/matching/PatternTool.java b/sources/scalac/transformer/matching/PatternTool.java index 91772a0332..8673e040dc 100644 --- a/sources/scalac/transformer/matching/PatternTool.java +++ b/sources/scalac/transformer/matching/PatternTool.java @@ -9,7 +9,7 @@ package scalac.transformer.matching; -import scalac.Unit; +import scalac.CompilationUnit; import scalac.ast.TreeGen; import scalac.util.*; import scalac.symtab.*; @@ -23,7 +23,7 @@ abstract class PatternTool { /** the current compilation unit */ - final Unit unit; + final CompilationUnit unit; /** the global fresh name creator */ @@ -38,7 +38,7 @@ abstract class PatternTool { final TreeGen gen; // constructor - public PatternTool( Unit unit ) { + public PatternTool( CompilationUnit unit ) { this.unit = unit; this.fresh = unit.fresh; this.gen = unit.global.treeGen; diff --git a/sources/scalac/transformer/matching/RightTracerInScala.java b/sources/scalac/transformer/matching/RightTracerInScala.java index b7ac716183..0a8ea356ca 100644 --- a/sources/scalac/transformer/matching/RightTracerInScala.java +++ b/sources/scalac/transformer/matching/RightTracerInScala.java @@ -425,7 +425,7 @@ System.out.println("RightTracerInScala - the seqVars"+seqVars); /* returns statements that do the work of the right-transducer */ - Tree getStms( Tree trace, Unit unit, Tree body ) { + Tree getStms( Tree trace, CompilationUnit unit, Tree body ) { TreeList stms = new TreeList(); Tree loopbody = code_body_NEW(); diff --git a/sources/scalac/transformer/matching/SequenceMatcher.java b/sources/scalac/transformer/matching/SequenceMatcher.java index fb8dfd8027..682320dce3 100644 --- a/sources/scalac/transformer/matching/SequenceMatcher.java +++ b/sources/scalac/transformer/matching/SequenceMatcher.java @@ -154,7 +154,7 @@ public class SequenceMatcher extends PatternTool { /** constructor, invoked by AlgebraicMatcher */ - SequenceMatcher( Unit unit ) { + SequenceMatcher( CompilationUnit unit ) { super( unit ); } } // class SequenceMatcher diff --git a/sources/scalac/typechecker/AnalyzerPhase.java b/sources/scalac/typechecker/AnalyzerPhase.java index 1c972e6cab..7104adfd03 100644 --- a/sources/scalac/typechecker/AnalyzerPhase.java +++ b/sources/scalac/typechecker/AnalyzerPhase.java @@ -11,7 +11,7 @@ package scalac.typechecker; import scalac.Global; import scalac.Phase; import scalac.PhaseDescriptor; -import scalac.Unit; +import scalac.CompilationUnit; import scalac.ast.TreeGen; import scalac.symtab.Definitions; import scalac.symtab.Symbol; @@ -29,6 +29,6 @@ public abstract class AnalyzerPhase extends Phase { public abstract void addConsoleImport(Symbol module); - public abstract void lateEnter(Unit unit); + public abstract void lateEnter(CompilationUnit unit); } diff --git a/sources/scalac/typechecker/RefCheck.java b/sources/scalac/typechecker/RefCheck.java index 4a8f1d78e4..797d38fc08 100644 --- a/sources/scalac/typechecker/RefCheck.java +++ b/sources/scalac/typechecker/RefCheck.java @@ -43,12 +43,12 @@ public class RefCheck extends Transformer implements Modifiers, Kinds { super(global); } - private Unit unit; + private CompilationUnit unit; private Definitions defs = global.definitions; private Infer infer = global.newInfer(); private Symbol enclClass; - public void apply(Unit unit) { + public void apply(CompilationUnit unit) { this.unit = unit; level = 0; scopes[0] = new Scope(); @@ -120,8 +120,8 @@ public class RefCheck extends Transformer implements Modifiers, Kinds { switch (member1.info()) { case OverloadedType(Symbol[] alts, _): for (int i = 0; i < alts.length; i++) { - if (normalizedInfo(self, alts[i]).isSubType(template) && - alts[i].owner() == member1.owner()) { + if (normalizedInfo(self, alts[i]).isSubType(template) /*&& + alts[i].owner() == member1.owner()*/) { if (member == other) member = alts[i]; else @@ -159,7 +159,7 @@ public class RefCheck extends Transformer implements Modifiers, Kinds { } abstractClassError( clazz, - member.toString() + member.type() + member.locationString() + " is not defined" + + member.toString() + member.locationString() + " is not defined" + (((member.flags & MUTABLE) == 0) ? "" : "\n(Note that variables need to be initialized to be defined)")); } else if (member.isAbstractOverride()) { diff --git a/sources/scalac/typechecker/RefCheckPhase.java b/sources/scalac/typechecker/RefCheckPhase.java index ca73d37d6d..3f783650f4 100644 --- a/sources/scalac/typechecker/RefCheckPhase.java +++ b/sources/scalac/typechecker/RefCheckPhase.java @@ -21,7 +21,7 @@ public class RefCheckPhase extends Phase { } /** Applies this phase to the given compilation units. */ - public void apply(Unit[] units) { + public void apply(CompilationUnit[] units) { for (int i = 0; i < units.length; i++) new RefCheck(global).apply(units[i]); } diff --git a/sources/scalac/util/EmptyPhase.java b/sources/scalac/util/EmptyPhase.java index 84ffe81adf..003983f4e0 100644 --- a/sources/scalac/util/EmptyPhase.java +++ b/sources/scalac/util/EmptyPhase.java @@ -11,7 +11,7 @@ package scalac.util; import scalac.Global; import scalac.Phase; import scalac.PhaseDescriptor; -import scalac.Unit; +import scalac.CompilationUnit; /** This class implements a phase that does nothing. */ public class EmptyPhase extends Phase { @@ -28,7 +28,7 @@ public class EmptyPhase extends Phase { // Public Methods /** Applies this phase to the given compilation units. */ - public void apply(Unit[] units) { + public void apply(CompilationUnit[] units) { // do nothing } |