projects
/
org.ibex.classgen.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
updates to CGConsts, generator program
[org.ibex.classgen.git]
/
src
/
org
/
ibex
/
classgen
/
MethodGen.java
diff --git
a/src/org/ibex/classgen/MethodGen.java
b/src/org/ibex/classgen/MethodGen.java
index
31d1229
..
2dcb4e3
100644
(file)
--- a/
src/org/ibex/classgen/MethodGen.java
+++ b/
src/org/ibex/classgen/MethodGen.java
@@
-10,8
+10,9
@@
public class MethodGen implements CGConst {
private static final int NO_CODE = -1;
private static final int FINISHED = -2;
private static final int NO_CODE = -1;
private static final int FINISHED = -2;
-
- private final CPGen cp;
+
+ private final ClassFile owner;
+ private final ConstantPool cp;
private final String name;
private final Type ret;
private final Type[] args;
private final String name;
private final Type ret;
private final Type[] args;
@@
-49,8
+50,9
@@
public class MethodGen implements CGConst {
// FIXME: attrs, body
}
// FIXME: attrs, body
}
- MethodGen(CPGen cp, DataInput in) throws IOException {
+ MethodGen(ConstantPool cp, DataInput in, ClassFile owner) throws IOException {
this.cp = cp;
this.cp = cp;
+ this.owner = owner;
flags = in.readShort();
name = cp.getUtf8ByIndex(in.readShort());
String descriptor = cp.getUtf8ByIndex(in.readShort());
flags = in.readShort();
name = cp.getUtf8ByIndex(in.readShort());
String descriptor = cp.getUtf8ByIndex(in.readShort());
@@
-70,27
+72,25
@@
public class MethodGen implements CGConst {
this.ret = ret;
this.args = args;
this.flags = flags;
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);
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);
}
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;
public int handler;
private class ExnTableEnt {
public int start;
public int end;
public int handler;
- public CPGen.Ent typeEnt;
- public ExnTableEnt(int start, int end, int handler, CPGen.Ent typeEnt) {
+ public ConstantPool.Ent typeEnt;
+ public ExnTableEnt(int start, int end, int handler, ConstantPool.Ent typeEnt) {
this.start = start;
this.end = end;
this.handler = handler;
this.start = start;
this.end = end;
this.handler = handler;
@@
-280,7
+280,7
@@
public class MethodGen implements CGConst {
}
}
int opdata = OP_DATA[op&0xff];
}
}
int opdata = OP_DATA[op&0xff];
- if((opdata&OP_CPENT_FLAG) != 0 && !(arg instanceof CPGen.Ent)) {
+ if((opdata&OP_CPENT_FLAG) != 0 && !(arg instanceof ConstantPool.Ent)) {
if (op==INVOKEINTERFACE) arg = cp.add(arg, true);
else arg = cp.add(arg);
}
if (op==INVOKEINTERFACE) arg = cp.add(arg, true);
else arg = cp.add(arg);
}
@@
-460,7
+460,7
@@
public class MethodGen implements CGConst {
break;
}
case LDC:
break;
}
case LDC:
- j = cp.getIndex((CPGen.Ent)arg[i]);
+ j = cp.getIndex((ConstantPool.Ent)arg[i]);
if(j >= 256) this.op[i] = op = LDC_W;
break;
default:
if(j >= 256) this.op[i] = op = LDC_W;
break;
default:
@@
-581,7
+581,7
@@
public class MethodGen implements CGConst {
throw new Error("should never happen");
}
} else if((opdata & OP_CPENT_FLAG) != 0) {
throw new Error("should never happen");
}
} else if((opdata & OP_CPENT_FLAG) != 0) {
- int v = cp.getIndex((CPGen.Ent)arg);
+ int v = cp.getIndex((ConstantPool.Ent)arg);
if(argLength == 1) o.writeByte(v);
else if(argLength == 2) o.writeShort(v);
else throw new Error("should never happen");
if(argLength == 1) o.writeByte(v);
else if(argLength == 2) o.writeShort(v);
else throw new Error("should never happen");
@@
-620,7
+620,7
@@
public class MethodGen implements CGConst {
baos.reset();
o.writeShort(thrownExceptions.size());
for(Enumeration e = thrownExceptions.keys();e.hasMoreElements();)
baos.reset();
o.writeShort(thrownExceptions.size());
for(Enumeration e = thrownExceptions.keys();e.hasMoreElements();)
- o.writeShort(cp.getIndex((CPGen.Ent)thrownExceptions.get(e.nextElement())));
+ o.writeShort(cp.getIndex((ConstantPool.Ent)thrownExceptions.get(e.nextElement())));
attrs.add("Exceptions", baos.toByteArray());
size = capacity = FINISHED;
attrs.add("Exceptions", baos.toByteArray());
size = capacity = FINISHED;
@@
-629,7
+629,7
@@
public class MethodGen implements CGConst {
void dump(DataOutput o) throws IOException {
o.writeShort(flags);
o.writeShort(cp.getUtf8Index(name));
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);
}
o.writeShort(attrs.size());
attrs.dump(o);
}