From: adam Date: Fri, 3 Jun 2005 05:44:35 +0000 (+0000) Subject: eliminated MethodRef.I X-Git-Url: http://git.megacz.com/?p=org.ibex.classgen.git;a=commitdiff_plain;h=7fbbcd1b85ae398c4468651e05df64e938812397 eliminated MethodRef.I darcs-hash:20050603054435-5007d-5945ba6138bb4903ace678a3cbc95a3bf820b7d4.gz --- diff --git a/src/org/ibex/classgen/CPGen.java b/src/org/ibex/classgen/CPGen.java index ec956d6..92f7643 100644 --- a/src/org/ibex/classgen/CPGen.java +++ b/src/org/ibex/classgen/CPGen.java @@ -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); diff --git a/src/org/ibex/classgen/MethodGen.java b/src/org/ibex/classgen/MethodGen.java index 32fd705..31d1229 100644 --- a/src/org/ibex/classgen/MethodGen.java +++ b/src/org/ibex/classgen/MethodGen.java @@ -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; diff --git a/src/org/ibex/classgen/MethodRef.java b/src/org/ibex/classgen/MethodRef.java index 399195c..6dbb46f 100644 --- a/src/org/ibex/classgen/MethodRef.java +++ b/src/org/ibex/classgen/MethodRef.java @@ -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); } - } }