X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=src%2Forg%2Fibex%2Fclassgen%2FMethodGen.java;h=3405fc943c70d291326c868cc92e7e1b25cc02c3;hb=069115fd4de6720de0a4a1ee37f05fec438fc325;hp=baf7fe3f4e79842af1741c592987e7ac48e5cf94;hpb=72cc9664e25a90f5241c9f4c39319889cd36ed15;p=org.ibex.classgen.git diff --git a/src/org/ibex/classgen/MethodGen.java b/src/org/ibex/classgen/MethodGen.java index baf7fe3..3405fc9 100644 --- a/src/org/ibex/classgen/MethodGen.java +++ b/src/org/ibex/classgen/MethodGen.java @@ -25,7 +25,8 @@ public class MethodGen implements CGConst { private byte[] op; private Object[] arg; private ConstantPool.Ent[] cparg; - + + // Constructors ////////////////////////////////////////////////////////////////////////////// MethodGen(Type.Class.Method method, int flags) { @@ -291,7 +292,8 @@ public class MethodGen implements CGConst { } /** Adds a exception type that can be thrown from this method - NOTE: This isn't enforced by the JVM. This is for reference only. A method can throw exceptions not declared to be thrown + NOTE: This isn't enforced by the JVM. This is for reference + only. A method can throw exceptions not declared to be thrown @param type The type of exception that can be thrown */ public final void addThrow(Type.Class type) { thrownExceptions.put(type, type); } @@ -547,30 +549,6 @@ public class MethodGen implements CGConst { // Emitting Bits ////////////////////////////////////////////////////////////////////////////// - /** Negates the IF* instruction, op (IF_ICMPGT -> IF_ICMPLE, IFNE -> IFEQ, etc) - @exception IllegalArgumentException if op 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) { @@ -1044,4 +1022,31 @@ public class MethodGen implements CGConst { } } + // Unused ////////////////////////////////////////////////////////////////////////////// + + /** Negates the IF* instruction, op (IF_ICMPGT -> IF_ICMPLE, IFNE -> IFEQ, etc) + @exception IllegalArgumentException if op 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)); + } + } + + }