summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpaltherr <paltherr@epfl.ch>2004-04-13 18:50:44 +0000
committerpaltherr <paltherr@epfl.ch>2004-04-13 18:50:44 +0000
commit483f42e9ab225b4f3d0e2aee412e5b1a91fbb97b (patch)
treefc38b259fd392614f41447e6923a3cb0b9b59721
parent82a62ec95a6ee537af3c82521397f63be132dfbc (diff)
downloadscala-483f42e9ab225b4f3d0e2aee412e5b1a91fbb97b.tar.gz
scala-483f42e9ab225b4f3d0e2aee412e5b1a91fbb97b.tar.bz2
scala-483f42e9ab225b4f3d0e2aee412e5b1a91fbb97b.zip
- Removed usage of Symbol.module() in Pickle/Un...
- Removed usage of Symbol.module() in Pickle/UnPickle
-rw-r--r--sources/scala/tools/scalap/ScalaAttribute.scala4
-rw-r--r--sources/scalac/symtab/EntryTags.java3
-rw-r--r--sources/scalac/symtab/classfile/Pickle.java13
-rw-r--r--sources/scalac/symtab/classfile/UnPickle.java46
4 files changed, 40 insertions, 26 deletions
diff --git a/sources/scala/tools/scalap/ScalaAttribute.scala b/sources/scala/tools/scalap/ScalaAttribute.scala
index 5b562e6a9c..8e582e83e1 100644
--- a/sources/scala/tools/scalap/ScalaAttribute.scala
+++ b/sources/scala/tools/scalap/ScalaAttribute.scala
@@ -80,7 +80,9 @@ class ScalaAttribute(in: ByteArrayReader) {
case ALIAS_SYM =>
AliasSym(readSymInfo, in.nextNat)
case CLASS_SYM =>
- ClassSym(readSymInfo, in.nextNat, in.nextNat)
+ val info = readSymInfo;
+ if (Flags.is(info.flags, Flags.OBJECT)) in.nextNat;
+ ClassSym(info, in.nextNat, in.nextNat)
case VAL_SYM =>
ValSym(readSymInfo, if (in.bp < end) in.nextNat else -1)
case EXT_REF =>
diff --git a/sources/scalac/symtab/EntryTags.java b/sources/scalac/symtab/EntryTags.java
index edceade341..4c6fe9d737 100644
--- a/sources/scalac/symtab/EntryTags.java
+++ b/sources/scalac/symtab/EntryTags.java
@@ -19,7 +19,8 @@ public interface EntryTags {
* | 4 NONEsym len_Nat
* | 5 TYPEsym len_Nat SymbolInfo lobound_Ref
* | 6 ALIASsym len_Nat SymbolInfo constrsym_Ref
- * | 7 CLASSsym len_Nat SymbolInfo thistype_Ref constrsym_Ref
+ * | 7 CLASSsym len_Nat SymbolInfo [modulesym_Ref]
+ * thistype_Ref constrsym_Ref
* | 8 VALsym len_Nat SymbolInfo [classsym_Ref]
* | 9 EXTref len_Nat name_Ref [owner_Ref]
* | 10 EXTMODCLASSref len_Nat name_Ref [owner_Ref]
diff --git a/sources/scalac/symtab/classfile/Pickle.java b/sources/scalac/symtab/classfile/Pickle.java
index 2c46855821..bd2f1f0ef2 100644
--- a/sources/scalac/symtab/classfile/Pickle.java
+++ b/sources/scalac/symtab/classfile/Pickle.java
@@ -34,6 +34,7 @@ public class Pickle implements Kinds, Modifiers, EntryTags {
private HashMap index;
private Object[] entries;
private int ep;
+ private final HashMap modules; // maps module-classes to modules
/** Write symbol table info for root.
* root must be either a module or a class.
@@ -42,6 +43,7 @@ public class Pickle implements Kinds, Modifiers, EntryTags {
index = new HashMap();
entries = new Object[256];
ep = 0;
+ modules = new HashMap();
}
/** Pickle all symbols descending from `root'.
@@ -141,8 +143,12 @@ public class Pickle implements Kinds, Modifiers, EntryTags {
if (sym.isConstructor() &&
sym == sym.constructorClass().allConstructors())
putSymbol(sym.constructorClass());
- else if (sym.isModule())
+ else if (sym.isModule()) {
+ Symbol clasz = sym.moduleClass();
putSymbol(sym.moduleClass());
+ assert !modules.containsKey(clasz): Debug.show(sym);
+ modules.put(clasz, sym);
+ }
break;
default:
throw new ApplicationError();
@@ -352,6 +358,11 @@ public class Pickle implements Kinds, Modifiers, EntryTags {
break;
case CLASS:
writeRef(sym.info());
+ if (sym.isModuleClass()) {
+ Symbol module = (Symbol)modules.remove(sym);
+ assert module != null: Debug.show(sym);
+ writeRef(module);
+ }
writeRef(sym.typeOfThis());
writeRef(sym.allConstructors());
break;
diff --git a/sources/scalac/symtab/classfile/UnPickle.java b/sources/scalac/symtab/classfile/UnPickle.java
index 5f6997b7a3..61c62dc63f 100644
--- a/sources/scalac/symtab/classfile/UnPickle.java
+++ b/sources/scalac/symtab/classfile/UnPickle.java
@@ -255,19 +255,18 @@ public class UnPickle implements Kinds, Modifiers, EntryTags, TypeTags {
break;
case CLASSsym:
- Symbol clr = ((flags & MODUL) == 0) ? classroot
- : moduleroot.moduleClass();
- if (name == clr.name && owner == clr.owner()) {
- if (global.debug) global.log("overwriting " + clr);
- entries[n] = sym = clr;
+ if ((flags & MODUL) != 0) {
+ Symbol modulesym = readSymbolRef();
+ entries[n] = sym = modulesym.moduleClass();
+ sym.flags = flags;
+ } else if (name == classroot.name && owner == classroot.owner()) {
+ if (global.debug)
+ global.log("overwriting " + classroot);
+ entries[n] = sym = classroot;
sym.flags = flags;
- } else if ((flags & MODUL) == 0) {
+ } else {
entries[n] = sym = owner.newClass(
Position.NOPOS, flags, name);
- } else {
- entries[n] = sym = owner.newModule(
- Position.NOPOS, flags, name.toTermName())
- .moduleClass();
}
sym.setInfo(getType(inforef, sym));
sym.setTypeOfThis(readTypeRef(sym));
@@ -276,29 +275,30 @@ public class UnPickle implements Kinds, Modifiers, EntryTags, TypeTags {
break;
case VALsym:
- Symbol tsym = bp < end ? readSymbolRef() : null;
if (name == moduleroot.name && owner == moduleroot.owner()) {
if (global.debug)
global.log("overwriting " + moduleroot);
entries[n] = sym = moduleroot;
sym.flags = flags;
- } else if (tsym == null) {
- if (name == Names.CONSTRUCTOR) {
+ } else if ((flags & MODUL) != 0) {
+ entries[n] = sym = owner.newModule(
+ Position.NOPOS, flags, name);
+ } else if (name == Names.CONSTRUCTOR) {
+ Symbol tsym = bp < end ? readSymbolRef() : null;
+ if (tsym == null) {
entries[n] = sym = owner.newConstructor(
Position.NOPOS, flags);
} else {
- entries[n] = sym = owner.newTerm(
- Position.NOPOS, flags, name);
- }
- } else {
- if (name == Names.CONSTRUCTOR) {
entries[n] = sym = tsym.allConstructors();
- } else {
- assert (flags & MODUL) != 0: name;
- assert tsym.isModuleClass(): Debug.show(tsym);
- entries[n] = sym = tsym.module();
+ sym.flags = flags;
}
- sym.flags = flags;
+ } else {
+ entries[n] = sym = owner.newTerm(
+ Position.NOPOS, flags, name);
+ }
+ if (sym.isModule()) {
+ Symbol clasz = readSymbolRef();
+ assert clasz == sym.moduleClass(): Debug.show(sym);
}
sym.setInfo(getType(inforef, sym));
break;