import java.util.*;
public class MethodGen implements CGConst {
- private final static boolean EMIT_NOPS = true;
+ private final static boolean EMIT_NOPS = false;
+
+ private static final int NO_CODE = -1;
+ private static final int FINISHED = -2;
private final CPGen cp;
private final String name;
private final void grow() { if(size == capacity) grow(size+1); }
private final void grow(int newCap) {
- if(capacity == -1) throw new IllegalStateException("method can't have code");
+ if(capacity == NO_CODE) throw new IllegalStateException("method can't have code");
+ if(capacity == FINISHED) throw new IllegalStateException("method has been finished");
if(newCap <= capacity) return;
newCap = Math.max(newCap,capacity == 0 ? 256 : capacity*2);
}
private void _finish() throws IOException {
- if(size == -1) return;
+ if(size == FINISHED) return;
ByteArrayOutputStream baos = new ByteArrayOutputStream();
DataOutput o = new DataOutputStream(baos);
if(iarg < -128 || iarg >= 256) throw new ClassGen.Exn("overflow of s/u1 option");
o.writeByte(iarg);
} else if(argLength == 2) {
- if(iarg < -32767 || iarg >= 65536) throw new ClassGen.Exn("overflow of s/u2 option");
+ if(iarg < -32768 || iarg >= 65536) throw new ClassGen.Exn("overflow of s/u2 option");
o.writeShort(iarg);
} else {
throw new Error("should never happen");
o.writeShort(((CPGen.Ent)thrownExceptions.get(e.nextElement())).getIndex());
attrs.add("Exceptions",baos.toByteArray());
- size = -1;
+ size = capacity = FINISHED;
}
public void dump(DataOutput o) throws IOException {