From 3aa7f6ca2f345c00a4bfcb6f2b41122a859ac2bb Mon Sep 17 00:00:00 2001 From: brian Date: Sat, 29 May 2004 09:17:00 +0000 Subject: [PATCH] minor bug fixes darcs-hash:20040529091700-24bed-d7bee1ee6d57cc211b75e8912f0a1c1c04eeca60.gz --- src/org/ibex/classgen/MethodGen.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/org/ibex/classgen/MethodGen.java b/src/org/ibex/classgen/MethodGen.java index 6603ebd..0fc3074 100644 --- a/src/org/ibex/classgen/MethodGen.java +++ b/src/org/ibex/classgen/MethodGen.java @@ -371,6 +371,8 @@ public class MethodGen implements CGConst { int codeSize = p; + if(codeSize >= 65536) throw new ClassGen.Exn("method too large in size"); + o.writeShort(maxStack); o.writeShort(maxLocals); o.writeInt(codeSize); @@ -423,8 +425,14 @@ public class MethodGen implements CGConst { default: if((opdata & OP_BRANCH_FLAG) != 0) { int v = pc[((Integer)arg).intValue()] - pc[i]; - if(v < -32768 || v > 32767) throw new ClassGen.Exn("overflow of s2 offset"); - o.writeShort(v); + if(argLength == 2) { + if(v < -32768 || v > 32767) throw new ClassGen.Exn("overflow of s2 offset"); + o.writeShort(v); + } else if(argLength == 4) { + o.writeInt(v); + } else { + throw new Error("should never happen"); + } } else if((opdata & OP_CPENT_FLAG) != 0) { int v = ((CPGen.Ent)arg).getIndex(); if(argLength == 1) o.writeByte(v); -- 1.7.10.4