eliminated MethodRef.I
authoradam <adam@megacz.com>
Fri, 3 Jun 2005 05:44:35 +0000 (05:44 +0000)
committeradam <adam@megacz.com>
Fri, 3 Jun 2005 05:44:35 +0000 (05:44 +0000)
darcs-hash:20050603054435-5007d-5945ba6138bb4903ace678a3cbc95a3bf820b7d4.gz

src/org/ibex/classgen/CPGen.java
src/org/ibex/classgen/MethodGen.java
src/org/ibex/classgen/MethodRef.java

index ec956d6..92f7643 100644 (file)
@@ -177,7 +177,8 @@ class CPGen {
     public final Ent addNameAndType(String name, String descriptor) { return add(new NameAndTypeKey(name, descriptor)); }
     public final Ent addUtf8(String s) { return add(new Utf8Key(s)); }
     
-    public final Ent add(Object o) {
+    public final Ent add(Object o) { return add(o, false); }
+    public final Ent add(Object o, boolean invokeInterface) {
         if(state == SEALED) throw new IllegalStateException("constant pool is sealed");
             
         Ent ent = get(o);
@@ -216,7 +217,7 @@ class CPGen {
             ent = ce;
         } else if(o instanceof MemberRef) {
             MemberRef key = (MemberRef) o;
-            int tag = o instanceof FieldRef ? 9 : o instanceof MethodRef ? 10 : o instanceof MethodRef.I ? 11 : 0;
+            int tag = invokeInterface ? 11 : o instanceof FieldRef ? 9 : o instanceof MethodRef ? 10 : 0;
             if(tag == 0) throw new Error("should never happen");
             CPRefEnt ce = new CPRefEnt(tag);
             ce.e1 = add(key.klass);
index 32fd705..31d1229 100644 (file)
@@ -276,14 +276,14 @@ public class MethodGen implements CGConst {
                 if(arg instanceof Long || arg instanceof Double) op = LDC2_W;
                 break;
             case INVOKEINTERFACE: {
-                MethodRef mr = (MethodRef)arg;
-                if(arg instanceof MethodRef) arg = new MethodRef.I(mr.klass, mr.name, mr.returnType, mr.argTypes);
                 break;
             }
         }
         int opdata = OP_DATA[op&0xff];
-        if((opdata&OP_CPENT_FLAG) != 0 && !(arg instanceof CPGen.Ent))
-            arg = cp.add(arg);
+        if((opdata&OP_CPENT_FLAG) != 0 && !(arg instanceof CPGen.Ent)) {
+            if (op==INVOKEINTERFACE) arg = cp.add(arg, true);
+            else arg = cp.add(arg);
+        }
         else if((opdata&OP_VALID_FLAG) == 0)
             throw new IllegalArgumentException("unknown bytecode");
         this.op[pos] = op;
index 399195c..6dbb46f 100644 (file)
@@ -28,12 +28,4 @@ public class MethodRef extends MemberRef {
         sb.append(returnType.getDescriptor());
         return sb.toString();
     }
-    
-    /** MethodRef class used for the INVOKEINTERFACE bytecode. Although this contains the same
-        data as a normal MethodRef, these are treated differently in the byte code format. In general,
-        users don't need to be concerned with this though because MethodRef's are automatically converted
-        to MethodRef.I's when they are applied to an INVOKEINTERFACE bytecode */
-    public static class I extends MethodRef {
-        public I(Type.Class c, String name, Type ret, Type[] args) { super(c, name, ret, args); }
-    }
 }