X-Git-Url: http://git.megacz.com/?p=org.ibex.classgen.git;a=blobdiff_plain;f=src%2Forg%2Fibex%2Fclassgen%2FConstantPool.java;h=67f4245cd3e03e7fd11c6d4f77c20a80ecf4d80e;hp=dbd958ce1260e1d241000e571a115401ab43b7c1;hb=d54f8660ded621af4065b8907255c162df0f6eb0;hpb=23042bc1dd664a6f8ca52125ce9874ef1c248769 diff --git a/src/org/ibex/classgen/ConstantPool.java b/src/org/ibex/classgen/ConstantPool.java index dbd958c..67f4245 100644 --- a/src/org/ibex/classgen/ConstantPool.java +++ b/src/org/ibex/classgen/ConstantPool.java @@ -23,7 +23,6 @@ class ConstantPool implements CGConst { Object key; Ent(int tag) { this.tag = tag; } void dump(DataOutput o) throws IOException { o.writeByte(tag); } - String debugToString() { return toString(); } // so we can remove this method when not debugging abstract Object _key(); final Object key() { return key == null ? (key = _key()) : key; } int slots() { return 1; } // number of slots this ent takes up @@ -41,7 +40,7 @@ class ConstantPool implements CGConst { String s; Utf8Ent() { super(CONSTANT_UTF8); } Utf8Ent(String s) { this(); this.s = s; } - String debugToString() { return s; } + public String toString() { return s; } void dump(DataOutput o) throws IOException { super.dump(o); o.writeUTF(s); } Object _key() { return new Utf8Key(s); } } @@ -86,9 +85,11 @@ class ConstantPool implements CGConst { ClassEnt(String s) { this(); this.utf8 = (Utf8Ent) addUtf8(s); } void dump(DataOutput o) throws IOException { super.dump(o); o.writeShort(utf8.n); } Type.Class getTypeClass() { return (Type.Class) key(); } - Object _key() { return new Type.Class(utf8.s); } + Object _key() { + return Type.fromDescriptor(utf8.s.startsWith("[") ? utf8.s : "L" + utf8.s + ";"); + } void unref() { utf8.unref(); super.unref(); } - String debugToString() { return "[Class: " + utf8.s + "]"; } + public String toString() { return "[Class: " + utf8.s + "]"; } } class NameAndTypeEnt extends Ent { @@ -196,7 +197,7 @@ class ConstantPool implements CGConst { String getUtf8KeyByIndex(int index) { Ent e = getByIndex(index); - if(!(e instanceof Utf8Ent)) throw new IllegalArgumentException("that isn't a utf8 (" + e.debugToString() + ")"); + if(!(e instanceof Utf8Ent)) throw new IllegalArgumentException("that isn't a utf8 (" + e.toString() + ")"); return ((Utf8Ent)e).s; } @@ -218,7 +219,7 @@ class ConstantPool implements CGConst { return ent; } - if (o instanceof Type.Class) { ent = new ClassEnt(((Type.Class)o).internalForm()); } + if (o instanceof Type.Ref) { ent = new ClassEnt(((Type.Ref)o).internalForm()); } else if (o instanceof String) { ent = new StringLitEnt((String)o); } else if (o instanceof Integer) { ent = new IntLitEnt(((Integer)o).intValue()); } else if (o instanceof Float) { ent = new FloatLitEnt(((Float)o).floatValue()); } @@ -236,10 +237,10 @@ class ConstantPool implements CGConst { : m instanceof Type.Class.Method ? CONSTANT_METHODREF : 0; if (tag == 0) throw new Error("should never happen"); - ent = new MemberEnt(tag, m.getDeclaringClass(), m.name, m.getDescriptor()); + ent = new MemberEnt(tag, m.getDeclaringClass(), m.name, m.getTypeDescriptor()); } else { - throw new IllegalArgumentException("Unknown type passed to add"); + throw new IllegalArgumentException("Unknown type " + o + " passed to add"); } int spaces = ent.slots(); @@ -309,7 +310,7 @@ class ConstantPool implements CGConst { Sort.sort(ents, compareFunc); o.writeShort(usedSlots); for(int i=0;i