From: adam Date: Thu, 2 Jun 2005 07:46:53 +0000 (+0000) Subject: got it to compile X-Git-Url: http://git.megacz.com/?p=org.ibex.classgen.git;a=commitdiff_plain;h=cd0ae78576749ddda5d9dfda5b9e88dd78fda0c9 got it to compile darcs-hash:20050602074653-5007d-e6eaa6b619b266a9cff720683a66e176e1d25dc6.gz --- diff --git a/src/org/ibex/classgen/CPGen.java b/src/org/ibex/classgen/CPGen.java index 6527816..25f22be 100644 --- a/src/org/ibex/classgen/CPGen.java +++ b/src/org/ibex/classgen/CPGen.java @@ -24,6 +24,7 @@ class CPGen { CPGen owner; // don't need this yet, but we will to implement ref() and unref() int n; // this is the refcount if state == OPEN, index if >= STABLE int tag; + Ent e0; Ent(CPGen owner, int tag) { this.owner = owner; this.tag = tag; } @@ -84,19 +85,23 @@ class CPGen { if(e2 != null) o.writeShort(e2.n); } + private String fixme() { throw new Error("fixme"); } Object key() throws ClassGen.ClassReadExn { switch(tag) { case 7: return new Type.Object(((Utf8Ent)e0).s); case 8: return (((Utf8Ent)e1).s); - case 9: + case 9: { NameAndTypeKey nt = (NameAndTypeKey) e2.key(); Type t = Type.fromDescriptor(nt.type); if(t == null) throw new ClassGen.ClassReadExn("invalid type descriptor"); - return FieldRef((Type.Object)e1.key(), nt.name, t); - case 10: + return new FieldRef((Type.Object)e1.key(), nt.name, t); + } + case 10: { NameAndTypeKey nt = (NameAndTypeKey) e2.key(); - return MethodRef((Type.Object)e1.key(),throw new Error("fixme")); + return new MethodRef((Type.Object)e1.key(), fixme(), null, null); + } } + throw new Error("FIXME"); } } @@ -105,6 +110,7 @@ class CPGen { Utf8Ent(CPGen owner) { super(owner,1); } String debugToString() { return s; } void dump(DataOutput o) throws IOException { super.dump(o); o.writeUTF(s); } + Object key() { throw new Error("Brian is lame"); } } /* @@ -150,6 +156,8 @@ class CPGen { return ent.n; } + public final Type.Object getType(int index) { return new Type.Object(((Utf8Ent)getByIndex(index)).s); } + public final Ent getByIndex(int index) { if(state < STABLE) throw new IllegalStateException("constant pool is not stable"); Ent e; @@ -299,18 +307,19 @@ class CPGen { } } - CPGen(DataInput in) throws ClassGen.ClassReadExn { - usedSlots = i.readUnsignedShort(); + CPGen(DataInput in) throws ClassGen.ClassReadExn, IOException { + usedSlots = in.readUnsignedShort(); if(usedSlots==0) throw new ClassGen.ClassReadExn("invalid used slots"); // these are to remember the CPRefEnt e0 and e1s we have to fix up + int[] e0s = new int[usedSlots]; int[] e1s = new int[usedSlots]; int[] e2s = new int[usedSlots]; entriesByIndex = new Ent[usedSlots]; for(int index=1;index