summaryrefslogtreecommitdiff
path: root/sources/scalac/symtab/classfile/UnPickle.java
diff options
context:
space:
mode:
authorpaltherr <paltherr@epfl.ch>2004-03-20 20:20:37 +0000
committerpaltherr <paltherr@epfl.ch>2004-03-20 20:20:37 +0000
commit05f04931562a4a25476816fa13a71b26656bf3e5 (patch)
treedce31ec43b232aa23357e399d58891334d9a0639 /sources/scalac/symtab/classfile/UnPickle.java
parent5d81251857c0029f88e6935943368a6bb3d32faf (diff)
downloadscala-05f04931562a4a25476816fa13a71b26656bf3e5.tar.gz
scala-05f04931562a4a25476816fa13a71b26656bf3e5.tar.bz2
scala-05f04931562a4a25476816fa13a71b26656bf3e5.zip
- Added parse methods in UnPickle
- Removed UnPickle.sourcePath
Diffstat (limited to 'sources/scalac/symtab/classfile/UnPickle.java')
-rw-r--r--sources/scalac/symtab/classfile/UnPickle.java33
1 files changed, 24 insertions, 9 deletions
diff --git a/sources/scalac/symtab/classfile/UnPickle.java b/sources/scalac/symtab/classfile/UnPickle.java
index c0a62b5724..e6cf6d3afc 100644
--- a/sources/scalac/symtab/classfile/UnPickle.java
+++ b/sources/scalac/symtab/classfile/UnPickle.java
@@ -9,6 +9,7 @@
package scalac.symtab.classfile;
import java.util.HashMap;
+import java.io.IOException;
import java.io.PrintStream;
import scalac.*;
import scalac.atree.AConstant;
@@ -25,18 +26,34 @@ public class UnPickle implements Kinds, Modifiers, EntryTags, TypeTags {
*/
static final boolean debug = true;
+ public static void parse(Global global, AbstractFile file, Symbol root)
+ throws IOException
+ {
+ try {
+ parse(global, file.read(), root);
+ } catch (BadSignature exception) {
+ throw new IOException("symbol file '" + file.getPath() + "' "
+ + "could not be loaded; " + exception.getMessage());
+ }
+ }
+
+ public static void parse(Global global, byte[] data, Symbol root)
+ throws BadSignature
+ {
+ new UnPickle(global, data, root);
+ }
+
Symbol classroot;
Symbol moduleroot;
byte[] bytes;
int bp;
- Name sourceName;
int[] index;
Object[] entries;
int paramFlags;
- Global global;
+ final Global global;
- UnPickle(Symbol root, byte[] data, Name sourceName) {
- global = Global.instance;
+ private UnPickle(Global global, byte[] data, Symbol root) {
+ this.global = global;
if (root.isConstructor()) {
this.classroot = root.constructorClass();
this.moduleroot = classroot.dualClass().module();
@@ -56,7 +73,6 @@ public class UnPickle implements Kinds, Modifiers, EntryTags, TypeTags {
moduleroot.moduleClass() + " " + moduleroot.moduleClass().primaryConstructor());
this.bytes = data;
this.bp = 0;
- this.sourceName = sourceName;
index = new int[readNat()];
for (int i = 0; i < index.length; i++) {
index[i] = bp;
@@ -179,13 +195,13 @@ public class UnPickle implements Kinds, Modifiers, EntryTags, TypeTags {
case EXTMODCLASSref:
Name name = readNameRef();
if (bp == end) {
- owner = Global.instance.definitions.ROOT_CLASS;
+ owner = global.definitions.ROOT_CLASS;
} else {
assert bp < end;
owner = readSymbolRef();
}
if (name == Names.ROOT && owner == Symbol.NONE) {
- sym = Global.instance.definitions.ROOT_CLASS;
+ sym = global.definitions.ROOT_CLASS;
if (tag == EXTref) sym = sym;
// !!! line above is usefull for the transition
// !!! after some time, replace it by the following line:
@@ -506,8 +522,7 @@ public class UnPickle implements Kinds, Modifiers, EntryTags, TypeTags {
public static class BadSignature extends java.lang.Error {
public BadSignature(UnPickle outer, String msg) {
- super("symbol data " + outer.sourceName +
- " could not be loaded; " + msg);
+ super(msg);
}
public BadSignature(UnPickle outer) {
this(outer, "malformed signature at " + outer.bp);