X-Git-Url: http://git.megacz.com/?p=org.ibex.classgen.git;a=blobdiff_plain;f=src%2Forg%2Fibex%2Fclassgen%2FMethodGen.java;h=ba055bf78a666d700613bee7257d78adbff18e39;hp=31d1229b306f7a2c00ba716f1db289c829c507e3;hb=69b2d27ebab56f1b0e4df2a3a301f4d852439e8e;hpb=20b36057bc5aee6e799cce02a3bf289916889fc1 diff --git a/src/org/ibex/classgen/MethodGen.java b/src/org/ibex/classgen/MethodGen.java index 31d1229..ba055bf 100644 --- a/src/org/ibex/classgen/MethodGen.java +++ b/src/org/ibex/classgen/MethodGen.java @@ -10,7 +10,8 @@ public class MethodGen implements CGConst { private static final int NO_CODE = -1; private static final int FINISHED = -2; - + + private final ClassFile owner; private final CPGen cp; private final String name; private final Type ret; @@ -49,8 +50,9 @@ public class MethodGen implements CGConst { // FIXME: attrs, body } - MethodGen(CPGen cp, DataInput in) throws IOException { + MethodGen(CPGen cp, DataInput in, ClassFile owner) throws IOException { this.cp = cp; + this.owner = owner; flags = in.readShort(); name = cp.getUtf8ByIndex(in.readShort()); String descriptor = cp.getUtf8ByIndex(in.readShort()); @@ -70,21 +72,19 @@ public class MethodGen implements CGConst { this.ret = ret; this.args = args; this.flags = flags; + this.owner = owner; attrs = new ClassFile.AttrGen(cp); codeAttrs = new ClassFile.AttrGen(cp); cp.addUtf8(name); - cp.addUtf8(getDescriptor()); + cp.addUtf8(owner.getType().method(name, ret, args).getDescriptor()); if((owner.flags & ACC_INTERFACE) != 0 || (flags & (ACC_ABSTRACT|ACC_NATIVE)) != 0) size = capacity = -1; maxLocals = Math.max(args.length + (flags&ACC_STATIC)==0 ? 1 : 0, 4); } - /** Returns the descriptor string for this method */ - public String getDescriptor() { return new MethodRef(null, name, ret, args).getDescriptor(); } - private class ExnTableEnt { public int start; public int end; @@ -629,7 +629,7 @@ public class MethodGen implements CGConst { void dump(DataOutput o) throws IOException { o.writeShort(flags); o.writeShort(cp.getUtf8Index(name)); - o.writeShort(cp.getUtf8Index(getDescriptor())); + o.writeShort(cp.getUtf8Index(owner.getType().method(name, ret, args).getDescriptor())); o.writeShort(attrs.size()); attrs.dump(o); }