summaryrefslogtreecommitdiff
path: root/sources
diff options
context:
space:
mode:
authorpaltherr <paltherr@epfl.ch>2003-08-18 22:24:07 +0000
committerpaltherr <paltherr@epfl.ch>2003-08-18 22:24:07 +0000
commit1832dd1036e31de1de2e6d14c57444ac696746cd (patch)
tree85eb82f1366cf04cb13524ef3a1fdd0fbe1f0427 /sources
parenteae9ff36d8080e8f769d354153b275b8a6b0b128 (diff)
downloadscala-1832dd1036e31de1de2e6d14c57444ac696746cd.tar.gz
scala-1832dd1036e31de1de2e6d14c57444ac696746cd.tar.bz2
scala-1832dd1036e31de1de2e6d14c57444ac696746cd.zip
- Removed constant Global.POST_ANALYZER_PHASE_ID.
- Removed constant Symbol.FIRST_ID. - Added method Symbol.setFirstInfo(Type). - Added method Symbol.rawFirstInfo(). - Renamed Symbol.setInfo(Type,int) into Symbol.setInfoAt(Type,int). - Made Symbol.setInfoAt(Type,int) and Symbol.rawInfoAt(int) private. - Changed Symbol.currentPhaseId() to always return id of current phase.
Diffstat (limited to 'sources')
-rw-r--r--sources/scalac/Global.java4
-rw-r--r--sources/scalac/symtab/Symbol.java25
-rw-r--r--sources/scalac/symtab/SymbolTablePrinter.java2
-rw-r--r--sources/scalac/symtab/classfile/AttributeParser.java22
-rw-r--r--sources/scalac/symtab/classfile/ClassfileParser.java14
-rw-r--r--sources/scalac/symtab/classfile/UnPickle.java12
-rw-r--r--sources/scalac/typechecker/Analyzer.java2
7 files changed, 42 insertions, 39 deletions
diff --git a/sources/scalac/Global.java b/sources/scalac/Global.java
index 2ec3f0e877..6fc72587a5 100644
--- a/sources/scalac/Global.java
+++ b/sources/scalac/Global.java
@@ -124,8 +124,6 @@ public class Global {
public final CompilerPhases PHASE;
public final Phase[] phases;
- public static final int POST_ANALYZER_PHASE_ID = 3;
-
/** compilation targets
*/
public static final String TARGET_INT;
@@ -211,8 +209,6 @@ public class Global {
for (int i = 1; i < descriptors.length; i++)
this.currentPhase = phases[i] = descriptors[i].create(this);
this.currentPhase = phases[0];
-
- assert PHASE.ANALYZER.id() + 1 == POST_ANALYZER_PHASE_ID;
}
/** Move to next phase
diff --git a/sources/scalac/symtab/Symbol.java b/sources/scalac/symtab/Symbol.java
index 5abc022439..00161b7745 100644
--- a/sources/scalac/symtab/Symbol.java
+++ b/sources/scalac/symtab/Symbol.java
@@ -56,8 +56,6 @@ public abstract class Symbol implements Modifiers, Kinds {
/** The infos of the symbol */
private TypeIntervalList infos = TypeIntervalList.EMPTY;
- static public int FIRST_ID = Global.POST_ANALYZER_PHASE_ID;
-
// Constructors -----------------------------------------------------------
/** Generic symbol constructor */
@@ -135,10 +133,14 @@ public abstract class Symbol implements Modifiers, Kinds {
/** Set information, except if symbol is both initialized and locked.
*/
public Symbol setInfo(Type info) {
- return setInfo(info, currentPhaseId());
+ return setInfoAt(info, currentPhaseId());
+ }
+
+ public Symbol setFirstInfo(Type info) {
+ return setInfoAt(info, 0);
}
- public Symbol setInfo(Type info, int limit) {
+ private Symbol setInfoAt(Type info, int limit) {
assert !isConstructor()
|| info instanceof Type.LazyType
|| info == Type.NoType
@@ -587,8 +589,7 @@ public abstract class Symbol implements Modifiers, Kinds {
/** the current phase id, or the id after analysis, whichever is larger.
*/
static int currentPhaseId() {
- int id = Global.instance.currentPhase.id;
- return id < FIRST_ID ? FIRST_ID : id;
+ return Global.instance.currentPhase.id;
}
public int definedPhaseId() {
@@ -629,7 +630,7 @@ public abstract class Symbol implements Modifiers, Kinds {
//if (isModule()) moduleClass().initialize();
int id = currentPhaseId();
if ((flags & INITIALIZED) == 0) {
- Type info = rawInfoAt(FIRST_ID);
+ Type info = rawFirstInfo();
assert info != null : this;
if ((flags & LOCKED) != 0) {
setInfo(Type.ErrorType);
@@ -671,7 +672,7 @@ public abstract class Symbol implements Modifiers, Kinds {
/** get info at phase #id, without forcing lazy types.
*/
- public Type rawInfoAt(int id) {
+ private Type rawInfoAt(int id) {
//if (infos == TypeIntervalList.EMPTY) return Type.NoType;//DEBUG
assert infos != TypeIntervalList.EMPTY : this;
int nextid = infos.limit;
@@ -699,6 +700,14 @@ public abstract class Symbol implements Modifiers, Kinds {
}
}
+ public Type rawFirstInfo() {
+ TypeIntervalList infos1 = infos;
+ while (infos1.prev.limit >= 0) {
+ infos1 = infos1.prev;
+ }
+ return infos1.info;
+ }
+
public Type rawInfo() {
return rawInfoAt(currentPhaseId());
}
diff --git a/sources/scalac/symtab/SymbolTablePrinter.java b/sources/scalac/symtab/SymbolTablePrinter.java
index a28abc9457..6a3dd3e7b4 100644
--- a/sources/scalac/symtab/SymbolTablePrinter.java
+++ b/sources/scalac/symtab/SymbolTablePrinter.java
@@ -343,7 +343,7 @@ public class SymbolTablePrinter {
/** Prints the type of the given symbol with the given inner string. */
public SymbolTablePrinter printSymbolType(Symbol symbol, String inner) {
- Type type = symbol.rawInfoAt(global.POST_ANALYZER_PHASE_ID);
+ Type type = symbol.rawFirstInfo();
if (!(type instanceof Type.LazyType)) type = symbol.info();
boolean star = false;
if ((symbol.flags & Modifiers.REPEATED) != 0 &&
diff --git a/sources/scalac/symtab/classfile/AttributeParser.java b/sources/scalac/symtab/classfile/AttributeParser.java
index a4cfc6fec6..7c52cd347e 100644
--- a/sources/scalac/symtab/classfile/AttributeParser.java
+++ b/sources/scalac/symtab/classfile/AttributeParser.java
@@ -140,9 +140,8 @@ public class AttributeParser implements ClassfileConstants {
case META_ATTR:
//System.out.println("parsing meta data for " + sym);
String meta = pool.readPool(in.nextChar()).toString().trim();
- sym.setInfo(
- new MetaParser(meta, tvars, sym, type).parse(),
- Symbol.FIRST_ID);
+ sym.setFirstInfo(
+ new MetaParser(meta, tvars, sym, type).parse());
return;
default:
@@ -190,7 +189,7 @@ public class AttributeParser implements ClassfileConstants {
Name.fromString(token).toTypeName(),
owner,
Modifiers.PARAM);
- s.setInfo(parser.defs.ANY_TYPE, Symbol.FIRST_ID);
+ s.setFirstInfo(parser.defs.ANY_TYPE);
tvars.enter(s);
return s;
} else
@@ -246,7 +245,7 @@ public class AttributeParser implements ClassfileConstants {
//System.out.println("new var " + s + ", " + token);//DEBUG
if (token.equals("<")) {
nextToken();
- s.setInfo(parseType(), Symbol.FIRST_ID);
+ s.setFirstInfo(parseType());
}
syms.add(s);
} while (token.equals(","));
@@ -259,10 +258,9 @@ public class AttributeParser implements ClassfileConstants {
Symbol constr = parser.c.primaryConstructor();
switch (constr.rawInfo()) {
case MethodType(Symbol[] vparams, _):
- constr.setInfo(
+ constr.setFirstInfo(
Type.PolyType(
- smbls, Type.MethodType(vparams, clazztype)),
- Symbol.FIRST_ID);
+ smbls, Type.MethodType(vparams, clazztype)));
break;
default:
throw new ApplicationError(constr.rawInfo());
@@ -330,12 +328,12 @@ public class AttributeParser implements ClassfileConstants {
Name.fromString(token).toTypeName(),
owner,
Modifiers.PARAM);
- s.setInfo(parser.defs.ANY_TYPE, Symbol.FIRST_ID);
+ s.setFirstInfo(parser.defs.ANY_TYPE);
locals.enter(s);
nextToken();
if (token.equals("<")) {
nextToken();
- s.setInfo(parseType(), Symbol.FIRST_ID);
+ s.setFirstInfo(parseType());
}
syms.add(s);
} while (token.equals(","));
@@ -359,7 +357,7 @@ public class AttributeParser implements ClassfileConstants {
Position.NOPOS,
Name.fromString("x" + (i++)),
owner,
- flags).setInfo(parseType(), Symbol.FIRST_ID));
+ flags).setFirstInfo(parseType()));
//System.out.println(" + " + token);
} while (token.equals(","));
assert ")".equals(token);
@@ -412,7 +410,7 @@ public class AttributeParser implements ClassfileConstants {
Position.NOPOS,
Name.fromString("x" + (i++)),
owner,
- Modifiers.PARAM).setInfo(parseType(), Symbol.FIRST_ID));
+ Modifiers.PARAM).setFirstInfo(parseType()));
//System.out.println(" + " + token);
} while (token.equals(","));
assert ")".equals(token);
diff --git a/sources/scalac/symtab/classfile/ClassfileParser.java b/sources/scalac/symtab/classfile/ClassfileParser.java
index 48295cec46..04d876fce8 100644
--- a/sources/scalac/symtab/classfile/ClassfileParser.java
+++ b/sources/scalac/symtab/classfile/ClassfileParser.java
@@ -92,12 +92,12 @@ public class ClassfileParser implements ClassfileConstants {
this.statics = new Scope();
// set type of class
Type classType = Type.compoundType(basetpes, locals, c);
- c.setInfo(classType, Symbol.FIRST_ID);
+ c.setFirstInfo(classType);
// set type of statics
Symbol staticsClass = c.module().moduleClass();
if (staticsClass.isModuleClass()) {
Type staticsInfo = Type.compoundType(Type.EMPTY_ARRAY, statics, staticsClass);
- staticsClass.setInfo(staticsInfo, Symbol.FIRST_ID);
+ staticsClass.setFirstInfo(staticsInfo);
c.module().setInfo(Type.TypeRef(staticsClass.owner().thisType(),
staticsClass, Type.EMPTY_ARRAY));
}
@@ -113,8 +113,8 @@ public class ClassfileParser implements ClassfileConstants {
Symbol constr = c.primaryConstructor();
if (!constr.isInitialized()) {
- constr.setInfo(
- Type.MethodType(Symbol.EMPTY_ARRAY, ctype), Symbol.FIRST_ID);
+ constr.setFirstInfo(
+ Type.MethodType(Symbol.EMPTY_ARRAY, ctype));
if ((c.flags & Modifiers.INTERFACE) == 0)
constr.flags |= Modifiers.PRIVATE;
}
@@ -185,7 +185,7 @@ public class ClassfileParser implements ClassfileConstants {
if ((flags & 0x0008) != 0)
owner = c.module().moduleClass();
Symbol s = new TermSymbol(Position.NOPOS, name, owner, mods);
- s.setInfo(type, Symbol.FIRST_ID);
+ s.setFirstInfo(type);
attrib.readAttributes(s, type, FIELD_ATTR);
((flags & 0x0008) != 0 ? statics : locals).enterOrOverload(s);
}
@@ -212,7 +212,7 @@ public class ClassfileParser implements ClassfileConstants {
default:
throw new ApplicationError();
}
- s.setInfo(type, Symbol.FIRST_ID);
+ s.setFirstInfo(type);
attrib.readAttributes(s, type, METH_ATTR);
Symbol constr = c.primaryConstructor();
if (constr.isInitialized()) constr = c.addConstructor();
@@ -224,7 +224,7 @@ public class ClassfileParser implements ClassfileConstants {
Position.NOPOS, name,
((flags & 0x0008) != 0) ? c.module().moduleClass() : c,
transFlags(flags));
- s.setInfo(type, Symbol.FIRST_ID);
+ s.setFirstInfo(type);
attrib.readAttributes(s, type, METH_ATTR);
((flags & 0x0008) != 0 ? statics : locals).enterOrOverload(s);
}
diff --git a/sources/scalac/symtab/classfile/UnPickle.java b/sources/scalac/symtab/classfile/UnPickle.java
index f7f039c8c8..4e2eb566fb 100644
--- a/sources/scalac/symtab/classfile/UnPickle.java
+++ b/sources/scalac/symtab/classfile/UnPickle.java
@@ -167,7 +167,7 @@ public class UnPickle implements Kinds, Modifiers, EntryTags {
scope.enter(sym);
} else {
assert sym == other
- : "double enter: " + other + ":" + other.rawInfoAt(Symbol.FIRST_ID) + "," + sym + ":" + sym.rawInfoAt(Symbol.FIRST_ID);
+ : "double enter: " + other + ":" + other.rawFirstInfo() + "," + sym + ":" + sym.rawFirstInfo();
}
}
}
@@ -230,14 +230,14 @@ public class UnPickle implements Kinds, Modifiers, EntryTags {
case TYPEsym:
entries[n] = sym = new AbsTypeSymbol(
Position.NOPOS, name, owner, flags);
- sym.setInfo(getType(inforef), Symbol.FIRST_ID);
+ sym.setFirstInfo(getType(inforef));
sym.setLoBound(readTypeRef());
break;
case ALIASsym:
entries[n] = sym = new AliasTypeSymbol(
Position.NOPOS, name, owner, flags);
- sym.setInfo(getType(inforef), Symbol.FIRST_ID);
+ sym.setFirstInfo(getType(inforef));
Symbol constr = readSymbolRef();
break;
@@ -251,7 +251,7 @@ public class UnPickle implements Kinds, Modifiers, EntryTags {
sym.copyTo(clr);
entries[n] = sym = clr;
}
- sym.setInfo(getType(inforef), Symbol.FIRST_ID);
+ sym.setFirstInfo(getType(inforef));
sym.setTypeOfThis(readTypeRef());
Symbol constr = readSymbolRef();
if (constr != sym.primaryConstructor()) {
@@ -284,7 +284,7 @@ public class UnPickle implements Kinds, Modifiers, EntryTags {
entries[n] = sym = moduleroot;
}
Type tp = getType(inforef);
- sym.setInfo(setOwner(tp, sym), Symbol.FIRST_ID);
+ sym.setFirstInfo(setOwner(tp, sym));
break;
default:
@@ -366,7 +366,7 @@ public class UnPickle implements Kinds, Modifiers, EntryTags {
params[i] = new TermSymbol(
Position.NOPOS, Name.fromString("$" + i),
Symbol.NONE, PARAM | flags[i]);
- params[i].setInfo(argtypes[i], Symbol.FIRST_ID);
+ params[i].setFirstInfo(argtypes[i]);
}
tpe = Type.MethodType(params, restype);
break;
diff --git a/sources/scalac/typechecker/Analyzer.java b/sources/scalac/typechecker/Analyzer.java
index 296f20dc76..7aeed9432d 100644
--- a/sources/scalac/typechecker/Analyzer.java
+++ b/sources/scalac/typechecker/Analyzer.java
@@ -96,7 +96,7 @@ public class Analyzer extends Transformer implements Modifiers, Kinds {
public void lateEnter(Unit unit, Symbol sym) {
enterUnit(unit);
- if (sym.rawInfoAt(Symbol.FIRST_ID) instanceof SourceCompleter) {
+ if (sym.rawFirstInfo() instanceof SourceCompleter) {
sym.setInfo(Type.ErrorType);
String kind = (sym.name.isTermName()) ? "object " : "class ";
throw new Type.Error("file " + unit.source + " does not define public " +