From: brian Date: Fri, 28 May 2004 09:33:48 +0000 (+0000) Subject: more sanity checking X-Git-Url: http://git.megacz.com/?p=org.ibex.classgen.git;a=commitdiff_plain;h=9b8b835136fbb1c781662651ff76bc1d5d849742 more sanity checking darcs-hash:20040528093348-24bed-e1a1a112278a4d5db8c5806676d9122adb79e7eb.gz --- diff --git a/src/org/ibex/classgen/CPGen.java b/src/org/ibex/classgen/CPGen.java index 56d5149..e22fd9e 100644 --- a/src/org/ibex/classgen/CPGen.java +++ b/src/org/ibex/classgen/CPGen.java @@ -99,8 +99,6 @@ class CPGen { Ent ent = get(o); if(ent != null) return ent; - if(nextIndex == 65536) throw new ClassGen.Exn("constant pool full"); - if(o instanceof Type.Object) { CPRefEnt ce = new CPRefEnt(7); ce.e1 = addUtf8(((Type.Object)o).internalForm()); @@ -147,8 +145,12 @@ class CPGen { throw new IllegalArgumentException("Unknown type passed to add"); } - ent.index = nextIndex++; - if(ent instanceof LongEnt) nextIndex++; + int spaces = ent instanceof LongEnt ? 2 : 1; + + if(nextIndex + spaces > 65536) throw new ClassGen.Exn("constant pool full"); + + ent.index = nextIndex; + nextIndex += spaces; count++; entries.put(o,ent); diff --git a/src/org/ibex/classgen/MethodGen.java b/src/org/ibex/classgen/MethodGen.java index b82567e..68aebd2 100644 --- a/src/org/ibex/classgen/MethodGen.java +++ b/src/org/ibex/classgen/MethodGen.java @@ -296,6 +296,12 @@ public class MethodGen implements CGConst { p += 1 + 3 + 4; // opcode itself, padding, default if(op == TABLESWITCH) p += 4 + 4 + targets.length * 4; // lo, hi, targets else p += 4 + targets.length * 4 * 2; // count, key,val * targets + if(op == LOOKUPSWITCH) { + int[] vals = ((LSI)si).vals; + for(j=1;j