From 1a607deb9b281751feb3c57b163d17f7d1c0c801 Mon Sep 17 00:00:00 2001 From: brian Date: Thu, 27 May 2004 01:29:12 +0000 Subject: [PATCH] fix xSTORE bugs darcs-hash:20040527012912-24bed-128fac4608c7f7570c7f2669d3641988c69910cf.gz --- src/org/ibex/classgen/CGConst.java | 10 +++++----- src/org/ibex/classgen/MethodGen.java | 13 +++++++------ 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/src/org/ibex/classgen/CGConst.java b/src/org/ibex/classgen/CGConst.java index cfef6b7..83d2056 100644 --- a/src/org/ibex/classgen/CGConst.java +++ b/src/org/ibex/classgen/CGConst.java @@ -82,11 +82,11 @@ public interface CGConst { public static final byte BALOAD = (byte) 0x33; // 0 public static final byte CALOAD = (byte) 0x34; // 0 public static final byte SALOAD = (byte) 0x35; // 0 - public static final byte ISTORE = (byte) 0x36; // 0 - public static final byte LSTORE = (byte) 0x37; // 9 - public static final byte FSTORE = (byte) 0x38; // 0 - public static final byte DSTORE = (byte) 0x39; // 0 - public static final byte ASTORE = (byte) 0x3A; // 0 + public static final byte ISTORE = (byte) 0x36; // 1 + public static final byte LSTORE = (byte) 0x37; // 1 + public static final byte FSTORE = (byte) 0x38; // 1 + public static final byte DSTORE = (byte) 0x39; // 1 + public static final byte ASTORE = (byte) 0x3A; // 1 public static final byte ISTORE_0 = (byte) 0x3B; // 0 public static final byte ISTORE_1 = (byte) 0x3C; // 0 public static final byte ISTORE_2 = (byte) 0x3D; // 0 diff --git a/src/org/ibex/classgen/MethodGen.java b/src/org/ibex/classgen/MethodGen.java index b193e59..d375316 100644 --- a/src/org/ibex/classgen/MethodGen.java +++ b/src/org/ibex/classgen/MethodGen.java @@ -126,7 +126,7 @@ public class MethodGen implements CGConst { } } - private void set(int pos, byte op, Object arg) { + public void set(int pos, byte op, Object arg) { int iarg = arg instanceof Integer ? ((Integer)arg).intValue() : -1; switch(op) { @@ -134,7 +134,7 @@ public class MethodGen implements CGConst { case FSTORE: case DLOAD: case DSTORE: case ALOAD: case ASTORE: { if(iarg >= 0 && iarg <= 3) { - int base = -1; + byte base = 0; switch(op) { case ILOAD: base = ILOAD_0; break; case ISTORE: base = ISTORE_0; break; @@ -147,10 +147,11 @@ public class MethodGen implements CGConst { case ALOAD: base = ALOAD_0; break; case ASTORE: base = ASTORE_0; break; } - op = (byte)(base + iarg); + op = (byte)((base&0xff) + iarg); } else { - if(iarg > maxLocals) maxLocals = iarg; + if(iarg >= maxLocals) maxLocals = iarg + 1; } + break; } case LDC: if(arg instanceof Integer) { set(pos,op,iarg); return; } @@ -170,7 +171,7 @@ public class MethodGen implements CGConst { _set(pos,op,arg); } - public final void _set(int pos, byte op, Object arg) { + private final void _set(int pos, byte op, Object arg) { if(capacity == -1) throw new IllegalStateException("method can't have code"); if(size == -1) throw new IllegalStateException("method is finalized"); if(!OP_VALID(op)) throw new IllegalArgumentException("unknown bytecode"); @@ -495,7 +496,7 @@ public class MethodGen implements CGConst { 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x03, 0x05, 0x13, 0x15, 0x15, 0x03, 0x03, 0x03, 0x03, 0x03, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x13, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x03, 0x03, 0x03, 0x03, 0x03, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, -- 1.7.10.4