X-Git-Url: http://git.megacz.com/?p=org.ibex.classgen.git;a=blobdiff_plain;f=src%2Forg%2Fibex%2Fclassgen%2FJSSA.java;h=55ed8dbb06cef09f087632e4486c6b1e9e358f85;hp=a3dd785f88b0809fc9f2fa84ea6adc341cb0d720;hb=5186b123d341165e00082608ad38500f076f90f8;hpb=f74781e04f6123176bcfc60cab61a65a28914e58 diff --git a/src/org/ibex/classgen/JSSA.java b/src/org/ibex/classgen/JSSA.java index a3dd785..55ed8db 100644 --- a/src/org/ibex/classgen/JSSA.java +++ b/src/org/ibex/classgen/JSSA.java @@ -36,36 +36,6 @@ public class JSSA extends MethodGen implements CGConst { } } } - - public void debugBodyToString(StringBuffer sb) { - StringBuffer sb0 = new StringBuffer(); - super.debugBodyToString(sb0); - StringTokenizer st = new StringTokenizer(sb0.toString(), "\n"); - String[] lines = new String[st.countTokens()]; - for(int i=0; i") ? method.getDeclaringClass().getName() : method.name); } + public String _toString() { return _toString(method.name.equals("") ? method.getDeclaringClass().getName() : method.name); } } public class InvokeInterface extends InvokeVirtual{public InvokeInterface(Type.Class.Method m, Expr[] a, Expr e){super(m,a,e);}} public class InvokeVirtual extends Invoke { public final Expr instance; public InvokeVirtual(Type.Class.Method m, Expr[] a, Expr e) { super(m, a); instance = e; } - public String toString() { return toString(method.name); } - protected String toString(String name) { + public String _toString() { return _toString(method.name); } + protected String _toString(String name) { StringBuffer sb = new StringBuffer(); sb.append(instance+"."); sb.append(name); @@ -438,8 +429,9 @@ public class JSSA extends MethodGen implements CGConst { private final Object o; public Constant(int i) { this(new Integer(i)); } public Constant(Object o) { this.o = o; } - public String toString() { return o instanceof String ? "\"" + o + "\"" : o.toString(); } + public String _toString() { return o == null ? "null" : o instanceof String ? "\"" + o + "\"" : o.toString(); } public Type getType() { + if (o == null) return Type.NULL; if (o instanceof Byte) return Type.BYTE; if (o instanceof Short) return Type.SHORT; if (o instanceof Character) return Type.CHAR; @@ -478,19 +470,19 @@ public class JSSA extends MethodGen implements CGConst { // Stack manipulations ////////////////////////////////////////////////////////////////////////////// - case ACONST_NULL: return stack[sp++] = new Constant(null); - case ICONST_M1: return stack[sp++] = new Constant(-1); + case ACONST_NULL: push(new Constant(null)); return null; + case ICONST_M1: push(new Constant(-1)); return null; case ICONST_0: case LCONST_0: case FCONST_0: case DCONST_0: push(new Constant(0)); return null; case ICONST_1: case LCONST_1: case FCONST_1: case DCONST_1: push(new Constant(1)); return null; case ICONST_2: case FCONST_2: push(new Constant(2)); return null; case ICONST_3: push(new Constant(3)); return null; case ICONST_4: push(new Constant(4)); return null; case ICONST_5: push(new Constant(5)); return null; - case ILOAD: case LLOAD: case FLOAD: case DLOAD: case ALOAD: return push(local[i1]); - case ILOAD_0: case LLOAD_0: case FLOAD_0: case DLOAD_0: case ALOAD_0: return push(local[0]); - case ILOAD_1: case LLOAD_1: case FLOAD_1: case DLOAD_1: case ALOAD_1: return push(local[1]); - case ALOAD_2: case DLOAD_2: case FLOAD_2: case LLOAD_2: case ILOAD_2: return push(local[2]); - case ILOAD_3: case LLOAD_3: case FLOAD_3: case DLOAD_3: case ALOAD_3: return push(local[3]); + case ILOAD: case LLOAD: case FLOAD: case DLOAD: case ALOAD: push(local[i1]); return null; + case ILOAD_0: case LLOAD_0: case FLOAD_0: case DLOAD_0: case ALOAD_0: push(local[0]); return null; + case ILOAD_1: case LLOAD_1: case FLOAD_1: case DLOAD_1: case ALOAD_1: push(local[1]); return null; + case ALOAD_2: case DLOAD_2: case FLOAD_2: case LLOAD_2: case ILOAD_2: push(local[2]); return null; + case ILOAD_3: case LLOAD_3: case FLOAD_3: case DLOAD_3: case ALOAD_3: push(local[3]); return null; case ISTORE: case LSTORE: case FSTORE: case DSTORE: case ASTORE: local[i1] = pop(); return null; case ISTORE_0: case LSTORE_0: case FSTORE_0: case DSTORE_0: case ASTORE_0: local[0] = pop(); return null; case ISTORE_1: case LSTORE_1: case FSTORE_1: case DSTORE_1: case ASTORE_1: local[1] = pop(); return null; @@ -580,7 +572,7 @@ public class JSSA extends MethodGen implements CGConst { case INVOKESTATIC: ret = new InvokeStatic(method, args); break; default: throw new Error("should never happen"); } - if(ret.getType() != Type.VOID) push(ret); + if (ret.getType() != Type.VOID) push(ret); return new Seq(ret); } @@ -628,8 +620,8 @@ public class JSSA extends MethodGen implements CGConst { case BIPUSH: push(new Constant((Integer)arg)); return null; case SIPUSH: push(new Constant((Integer)arg)); return null; - case TABLESWITCH: new Branch((MethodGen.Switch)arg); - case LOOKUPSWITCH: new Branch((MethodGen.Switch)arg); + case TABLESWITCH: return new Branch((MethodGen.Switch)arg); + case LOOKUPSWITCH: return new Branch((MethodGen.Switch)arg); /* case MONITORENTER: Op.monitorEnter(pop()); @@ -651,6 +643,58 @@ public class JSSA extends MethodGen implements CGConst { } } + + public void debugBodyToString(StringBuffer sb) { + StringBuffer sb0 = new StringBuffer(); + super.debugBodyToString(sb0); + StringTokenizer st = new StringTokenizer(sb0.toString(), "\n"); + String[] lines = new String[st.countTokens()]; + for(int i=0; i