-
- /** Sets the maximum number of locals in the function to <i>maxLocals</i>. NOTE: This defaults to 0 and is automatically increased as
- necessary when *LOAD/*STORE bytecodes are added. You do not need to call this function in most cases */
- public void setMaxLocals(int maxLocals) { this.maxLocals = maxLocals; }
- /** Sets the maxinum size of th stack for this function to <i>maxStack</i>. This defaults to 16< */
- public void setMaxStack(int maxStack) { this.maxStack = maxStack; }
+
+
+ // Emitting Bits //////////////////////////////////////////////////////////////////////////////
+
+ /** Negates the IF* instruction, <i>op</i> (IF_ICMPGT -> IF_ICMPLE, IFNE -> IFEQ, etc)
+ @exception IllegalArgumentException if <i>op</i> isn't an IF* instruction */
+ public static byte negate(byte op) {
+ switch(op) {
+ case IFEQ: return IFNE;
+ case IFNE: return IFEQ;
+ case IFLT: return IFGE;
+ case IFGE: return IFLT;
+ case IFGT: return IFLE;
+ case IFLE: return IFGT;
+ case IF_ICMPEQ: return IF_ICMPNE;
+ case IF_ICMPNE: return IF_ICMPEQ;
+ case IF_ICMPLT: return IF_ICMPGE;
+ case IF_ICMPGE: return IF_ICMPLT;
+ case IF_ICMPGT: return IF_ICMPLE;
+ case IF_ICMPLE: return IF_ICMPGT;
+ case IF_ACMPEQ: return IF_ACMPNE;
+ case IF_ACMPNE: return IF_ACMPEQ;
+
+ default:
+ throw new IllegalArgumentException("Can't negate " + Integer.toHexString(op));
+ }
+ }
+
+ private Object resolveTarget(Object arg) {
+ int target;
+ if (arg instanceof PhantomTarget) {
+ target = ((PhantomTarget)arg).getTarget();
+ if (target == -1) throw new IllegalStateException("unresolved phantom target");
+ arg = N(target);
+ } else {
+ target = ((Integer)arg).intValue();
+ }
+ if (target < 0 || target >= size)
+ throw new IllegalStateException("invalid target address " + target + "/" + size);
+ return arg;
+ }