diff options
author | Martin Odersky <odersky@gmail.com> | 2003-03-31 08:29:52 +0000 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2003-03-31 08:29:52 +0000 |
commit | efd06d74f1621351c70456478b07a4ace6a9a211 (patch) | |
tree | 01ac7505ed4f33582974d4519dc3e33d601614d2 /sources/scalac/symtab | |
parent | 85c73ba918913361f925c23469c012096a93fb54 (diff) | |
download | scala-efd06d74f1621351c70456478b07a4ace6a9a211.tar.gz scala-efd06d74f1621351c70456478b07a4ace6a9a211.tar.bz2 scala-efd06d74f1621351c70456478b07a4ace6a9a211.zip |
*** empty log message ***
Diffstat (limited to 'sources/scalac/symtab')
-rw-r--r-- | sources/scalac/symtab/Definitions.java | 2 | ||||
-rw-r--r-- | sources/scalac/symtab/Modifiers.java | 2 | ||||
-rw-r--r-- | sources/scalac/symtab/Symbol.java | 14 | ||||
-rw-r--r-- | sources/scalac/symtab/Type.java | 28 | ||||
-rw-r--r-- | sources/scalac/symtab/classfile/AttributeParser.java | 14 | ||||
-rw-r--r-- | sources/scalac/symtab/classfile/ClassfileParser.java | 12 |
6 files changed, 39 insertions, 33 deletions
diff --git a/sources/scalac/symtab/Definitions.java b/sources/scalac/symtab/Definitions.java index de31e34a06..3fe8cc7dee 100644 --- a/sources/scalac/symtab/Definitions.java +++ b/sources/scalac/symtab/Definitions.java @@ -194,7 +194,7 @@ public class Definitions { ANY_TYPE = ANY_CLASS.typeConstructor(); ANY_CLASS.setInfo(Type.compoundType(Type.EMPTY_ARRAY, new Scope(), ANY_CLASS)); ANY_CLASS.constructor().setInfo( - Type.PolyType(Symbol.EMPTY_ARRAY, ANY_TYPE)); + Type.MethodType(Symbol.EMPTY_ARRAY, ANY_TYPE)); // the java.lang.OBJECT class JAVA_OBJECT_CLASS = getClass(Names.java_lang_Object); diff --git a/sources/scalac/symtab/Modifiers.java b/sources/scalac/symtab/Modifiers.java index cbfafae068..8d161ce117 100644 --- a/sources/scalac/symtab/Modifiers.java +++ b/sources/scalac/symtab/Modifiers.java @@ -55,7 +55,7 @@ public interface Modifiers { int SNDTIME = 0x40000000; //debug // masks - int SOURCEFLAGS = 0x00000077 | PARAM | TRAIT; // these modifiers can be set in source programs. + int SOURCEFLAGS = 0x00000077 | DEF | REPEATED | MODUL | MUTABLE | PACKAGE | PARAM | TRAIT; // these modifiers can be set in source programs. int ACCESSFLAGS = PRIVATE | PROTECTED; public static class Helper { diff --git a/sources/scalac/symtab/Symbol.java b/sources/scalac/symtab/Symbol.java index b76b8c2869..7ecbfe543a 100644 --- a/sources/scalac/symtab/Symbol.java +++ b/sources/scalac/symtab/Symbol.java @@ -104,6 +104,14 @@ public abstract class Symbol implements Modifiers, Kinds { } public Symbol setInfo(Type info, int limit) { + assert !isConstructor() + || info instanceof Type.LazyType + || info == Type.ErrorType + || info instanceof Type.MethodType + || info instanceof Type.OverloadedType + || info instanceof Type.PolyType && + ((Type.PolyType)info).result instanceof Type.MethodType + : "illegal type for " + this + ": " + info; if ((flags & (INITIALIZED | LOCKED)) != (INITIALIZED | LOCKED)) { if (infos == TypeIntervalList.EMPTY) infos = new TypeIntervalList(TypeIntervalList.EMPTY); @@ -748,7 +756,7 @@ public abstract class Symbol implements Modifiers, Kinds { if ((flags & TRAIT) != 0) return "trait"; else if ((flags & MODUL) != 0 && Global.instance.debug) - return "module class"; + return "object class"; else return "class"; case TYPE: @@ -756,7 +764,7 @@ public abstract class Symbol implements Modifiers, Kinds { return "type"; case VAL: if (isVariable()) return "variable"; - else if (isModule()) return "module"; + else if (isModule()) return "object"; else if (isConstructor()) return "constructor"; else if (isInitializedMethod() && (Global.instance.debug || (flags & STABLE) == 0) ) @@ -775,7 +783,7 @@ public abstract class Symbol implements Modifiers, Kinds { case ALIAS: return "type"; case VAL: if (isVariable()) return "var"; - else if (isModule()) return "module"; + else if (isModule()) return "object"; else if (isInitializedMethod()) return "def"; else return "val"; default: return ""; diff --git a/sources/scalac/symtab/Type.java b/sources/scalac/symtab/Type.java index 571e12061a..d579ea9685 100644 --- a/sources/scalac/symtab/Type.java +++ b/sources/scalac/symtab/Type.java @@ -26,7 +26,9 @@ public class Type implements Modifiers, Kinds, TypeTags { public case ThisType(Symbol sym); - public case TypeRef(Type pre, Symbol sym, Type[] args); + public case TypeRef(Type pre, Symbol sym, Type[] args) { + assert pre.isLegalPrefix() || pre == ErrorType : pre + "#" + sym; + } public case SingleType(Type pre, Symbol sym) { assert this instanceof ExtSingleType; @@ -80,11 +82,12 @@ public class Type implements Modifiers, Kinds, TypeTags { public static final Type[] NO_ARRAY = new Type[0]; public static SingleType singleType(Type pre, Symbol sym) { - if (pre.isStable() || pre == ErrorType) + if (pre.isStable() || pre == ErrorType) { return new ExtSingleType(pre, sym); - else + } else { throw new Type.Error( - "malformed type: " + pre + "." + sym.nameString() + ".type"); + "malformed type: " + pre + "#" + sym.nameString() + ".type"); + } } public static TypeRef appliedType(Type tycon, Type[] args) { @@ -116,7 +119,7 @@ public class Type implements Modifiers, Kinds, TypeTags { SYNTHETIC | ABSTRACTCLASS); res.tsym.setInfo(res); res.tsym.constructor().setInfo( - Type.PolyType(Symbol.EMPTY_ARRAY, Type.NoType)); + Type.MethodType(Symbol.EMPTY_ARRAY, Type.NoType)); return res; } @@ -127,7 +130,7 @@ public class Type implements Modifiers, Kinds, TypeTags { return pre.memberInfo(sym); else // todo: handle Java-style inner classes throw new Type.Error( - "malformed type: " + pre + "." + sym.nameString()); + "malformed type: " + pre + "#" + sym.nameString()); } static class ExtSingleType extends SingleType { @@ -634,7 +637,7 @@ public class Type implements Modifiers, Kinds, TypeTags { Type pre1 = apply(pre); Type[] args1 = map(args); if (pre1 == pre && args1 == args) return tp; - else return TypeRef(pre1, sym, args1); + else return typeRef(pre1, sym, args1); case SingleType(Type pre, Symbol sym): Type pre1 = apply(pre); if (pre1 == pre) return tp; @@ -866,7 +869,7 @@ public class Type implements Modifiers, Kinds, TypeTags { Type[] args1 = map(args); typeArg = prevTypeArg; if (prefix1 == prefix && args1 == args) return t; - else return TypeRef(prefix1, sym1, args1); + else return typeRef(prefix1, sym1, args1); } case SingleType(Type prefix, Symbol sym): @@ -1075,7 +1078,7 @@ public class Type implements Modifiers, Kinds, TypeTags { protected Type replacement(int i, Type fromtp) { switch (fromtp) { case TypeRef(Type pre, Symbol sym, Type[] args): - return TypeRef(pre, to[i], args); + return typeRef(pre, to[i], args); case SingleType(Type pre, Symbol sym): return singleType(pre, to[i]); default: @@ -1822,7 +1825,7 @@ public class Type implements Modifiers, Kinds, TypeTags { if (args[j] == NoType) args[j] = CovarType(lub(argss[j])); } - return TypeRef(pre, sym, args); + return typeRef(pre, sym, args); } /** The frontier of a closure C is the minimal set of types such that @@ -2050,7 +2053,7 @@ public class Type implements Modifiers, Kinds, TypeTags { Type this1 = unbox(); if (this1 != this) return this1; else if (args.length == 0) return this; - else return TypeRef(pre, sym, Type.EMPTY_ARRAY); + else return typeRef(pre, sym, Type.EMPTY_ARRAY); } default: throw new ApplicationError(); @@ -2104,6 +2107,7 @@ public class Type implements Modifiers, Kinds, TypeTags { case ThisType(Symbol sym): if (sym.isRoot()) return "<root>.this.type"; else if (this == localThisType) return "<local>.this.type"; + else if (sym.isAnonymousClass()) return "this.type"; else { Type this1 = (Global.instance.debug) ? this : expandModuleThis(); if (this1 == this) return sym.nameString() + ".this.type"; @@ -2195,7 +2199,7 @@ public class Type implements Modifiers, Kinds, TypeTags { else if (spre.endsWith(".type")) return spre.substring(0, spre.length() - 4); else - return spre + "@"; + return spre + "#"; } } diff --git a/sources/scalac/symtab/classfile/AttributeParser.java b/sources/scalac/symtab/classfile/AttributeParser.java index 8cc8e296d0..a6ae0a9083 100644 --- a/sources/scalac/symtab/classfile/AttributeParser.java +++ b/sources/scalac/symtab/classfile/AttributeParser.java @@ -253,7 +253,9 @@ public class AttributeParser implements ClassfileConstants { if ((parser.c.flags & Modifiers.INTERFACE) != 0) { parser.c.constructor().setInfo( - Type.PolyType(smbls, constrtype), parser.phaseId); + Type.PolyType( + smbls, Type.MethodType(Symbol.EMPTY_ARRAY, constrtype)), + parser.phaseId); //System.out.println("info = " + parser.c.constructor().info());//DEBUG } Symbol[] constrs; @@ -269,13 +271,9 @@ public class AttributeParser implements ClassfileConstants { switch (constrs[i].rawInfo()) { case MethodType(Symbol[] vparams, _): constrs[i].setInfo( - Type.PolyType(smbls, - Type.MethodType( - vparams, constrtype)), parser.phaseId); - break; - case PolyType(_, _): - constrs[i].setInfo( - Type.PolyType(smbls, constrtype), parser.phaseId); + Type.PolyType( + smbls, Type.MethodType(vparams, constrtype)), + parser.phaseId); break; } //System.out.println("*** constructor " + e.sym + ": " + e.sym.info());//DEBUG diff --git a/sources/scalac/symtab/classfile/ClassfileParser.java b/sources/scalac/symtab/classfile/ClassfileParser.java index 69d95f79f0..a0d69c4bed 100644 --- a/sources/scalac/symtab/classfile/ClassfileParser.java +++ b/sources/scalac/symtab/classfile/ClassfileParser.java @@ -117,10 +117,9 @@ public class ClassfileParser implements ClassfileConstants { assert constrs.length == 1; c.constructor().setInfo(constrs[0].info(), phaseId); } else { - Type constrtype = ((c.flags & Modifiers.INTERFACE) != 0) - ? Type.PolyType(Symbol.EMPTY_ARRAY, ctype) - : Type.MethodType(new Symbol[]{Symbol.NONE}, ctype); - c.constructor().setInfo(constrtype, phaseId); + Symbol[] cparams = ((c.flags & Modifiers.INTERFACE) != 0) ? Symbol.EMPTY_ARRAY + : new Symbol[]{Symbol.NONE}; + c.constructor().setInfo(Type.MethodType(cparams, ctype), phaseId); } attrib.readAttributes(c, classType, CLASS_ATTR); //System.out.println("dynamic class: " + c); @@ -214,10 +213,7 @@ public class ClassfileParser implements ClassfileConstants { } switch (type) { case MethodType(Symbol[] vparams, _): - if (c == defs.OBJECT_CLASS) - type = Type.PolyType(Symbol.EMPTY_ARRAY, ctype); - else - type = Type.MethodType(vparams, ctype); + type = Type.MethodType(vparams, ctype); break; default: throw new ApplicationError(); |