do not push void method results
[org.ibex.classgen.git] / src / org / ibex / classgen / JSSA.java
index e608b42..d01aa06 100644 (file)
@@ -435,8 +435,8 @@ public class JSSA extends MethodGen implements CGConst {
             if (o instanceof Long) return Type.LONG;
             if (o instanceof Double) return Type.DOUBLE;
             if (o instanceof Float) return Type.FLOAT;
-            if (o instanceof ConstantPool.Ent) throw new Error("unimplemented");
-            throw new Error("this should not happen");
+            if (o instanceof Integer) return Type.INT;
+            throw new IllegalStateException("unknown constant type");
         }
     }
 
@@ -557,12 +557,16 @@ public class JSSA extends MethodGen implements CGConst {
                 Type.Class.Method method = (Type.Class.Method)arg;
                 Expr args[] = new Expr[method.getNumArgs()];
                 for(int i=0; i<args.length; i++) args[args.length-i-1] = pop();
+                Expr ret;
                 switch(op) {
-                    case INVOKEVIRTUAL:   return push(new InvokeVirtual(method, args, pop()));
-                    case INVOKEINTERFACE: return push(new InvokeInterface(method, args, pop()));
-                    case INVOKESPECIAL:   return push(new InvokeSpecial(method, args, pop()));
-                    case INVOKESTATIC:    return push(new InvokeStatic(method, args));
+                    case INVOKEVIRTUAL:   ret = new InvokeVirtual(method, args, pop()); break;
+                    case INVOKEINTERFACE: ret = new InvokeInterface(method, args, pop()); break;
+                    case INVOKESPECIAL:   ret = new InvokeSpecial(method, args, pop()); break;
+                    case INVOKESTATIC:    ret = new InvokeStatic(method, args); break;
+                    default: throw new Error("should never happen");
                 }
+                if(ret.getType() != Type.VOID) push(ret);
+                return ret;
             }
 
                 // Field Access //////////////////////////////////////////////////////////////////////////////