1 7 8 package org.gjt.jclasslib.bytecode; 9 10 16 public class OpcodesUtil implements Opcodes { 17 18 private static String [] opcodeVerbose; 19 20 static { 21 22 opcodeVerbose = new String [256]; 23 24 opcodeVerbose[OPCODE_NOP] = "nop"; 25 opcodeVerbose[OPCODE_ACONST_NULL] = "aconst_null"; 26 opcodeVerbose[OPCODE_ICONST_M1] = "iconst_m1"; 27 opcodeVerbose[OPCODE_ICONST_0] = "iconst_0"; 28 opcodeVerbose[OPCODE_ICONST_1] = "iconst_1"; 29 opcodeVerbose[OPCODE_ICONST_2] = "iconst_2"; 30 opcodeVerbose[OPCODE_ICONST_3] = "iconst_3"; 31 opcodeVerbose[OPCODE_ICONST_4] = "iconst_4"; 32 opcodeVerbose[OPCODE_ICONST_5] = "iconst_5"; 33 opcodeVerbose[OPCODE_LCONST_0] = "lconst_0"; 34 opcodeVerbose[OPCODE_LCONST_1] = "lconst_1"; 35 opcodeVerbose[OPCODE_FCONST_0] = "fconst_0"; 36 opcodeVerbose[OPCODE_FCONST_1] = "fconst_1"; 37 opcodeVerbose[OPCODE_FCONST_2] = "fconst_2"; 38 opcodeVerbose[OPCODE_DCONST_0] = "dconst_0"; 39 opcodeVerbose[OPCODE_DCONST_1] = "dconst_1"; 40 opcodeVerbose[OPCODE_BIPUSH] = "bipush"; 41 opcodeVerbose[OPCODE_SIPUSH] = "sipush"; 42 opcodeVerbose[OPCODE_LDC] = "ldc"; 43 opcodeVerbose[OPCODE_LDC_W] = "ldc_w"; 44 opcodeVerbose[OPCODE_LDC2_W] = "ldc2_w"; 45 opcodeVerbose[OPCODE_ILOAD] = "iload"; 46 opcodeVerbose[OPCODE_LLOAD] = "lload"; 47 opcodeVerbose[OPCODE_FLOAD] = "fload"; 48 opcodeVerbose[OPCODE_DLOAD] = "dload"; 49 opcodeVerbose[OPCODE_ALOAD] = "aload"; 50 opcodeVerbose[OPCODE_ILOAD_0] = "iload_0"; 51 opcodeVerbose[OPCODE_ILOAD_1] = "iload_1"; 52 opcodeVerbose[OPCODE_ILOAD_2] = "iload_2"; 53 opcodeVerbose[OPCODE_ILOAD_3] = "iload_3"; 54 opcodeVerbose[OPCODE_LLOAD_0] = "lload_0"; 55 opcodeVerbose[OPCODE_LLOAD_1] = "lload_1"; 56 opcodeVerbose[OPCODE_LLOAD_2] = "lload_2"; 57 opcodeVerbose[OPCODE_LLOAD_3] = "lload_3"; 58 opcodeVerbose[OPCODE_FLOAD_0] = "fload_0"; 59 opcodeVerbose[OPCODE_FLOAD_1] = "fload_1"; 60 opcodeVerbose[OPCODE_FLOAD_2] = "fload_2"; 61 opcodeVerbose[OPCODE_FLOAD_3] = "fload_3"; 62 opcodeVerbose[OPCODE_DLOAD_0] = "dload_0"; 63 opcodeVerbose[OPCODE_DLOAD_1] = "dload_1"; 64 opcodeVerbose[OPCODE_DLOAD_2] = "dload_2"; 65 opcodeVerbose[OPCODE_DLOAD_3] = "dload_3"; 66 opcodeVerbose[OPCODE_ALOAD_0] = "aload_0"; 67 opcodeVerbose[OPCODE_ALOAD_1] = "aload_1"; 68 opcodeVerbose[OPCODE_ALOAD_2] = "aload_2"; 69 opcodeVerbose[OPCODE_ALOAD_3] = "aload_3"; 70 opcodeVerbose[OPCODE_IALOAD] = "iaload"; 71 opcodeVerbose[OPCODE_LALOAD] = "laload"; 72 opcodeVerbose[OPCODE_FALOAD] = "faload"; 73 opcodeVerbose[OPCODE_DALOAD] = "daload"; 74 opcodeVerbose[OPCODE_AALOAD] = "aaload"; 75 opcodeVerbose[OPCODE_BALOAD] = "baload"; 76 opcodeVerbose[OPCODE_CALOAD] = "caload"; 77 opcodeVerbose[OPCODE_SALOAD] = "saload"; 78 opcodeVerbose[OPCODE_ISTORE] = "istore"; 79 opcodeVerbose[OPCODE_LSTORE] = "lstore"; 80 opcodeVerbose[OPCODE_FSTORE] = "fstore"; 81 opcodeVerbose[OPCODE_DSTORE] = "dstore"; 82 opcodeVerbose[OPCODE_ASTORE] = "astore"; 83 opcodeVerbose[OPCODE_ISTORE_0] = "istore_0"; 84 opcodeVerbose[OPCODE_ISTORE_1] = "istore_1"; 85 opcodeVerbose[OPCODE_ISTORE_2] = "istore_2"; 86 opcodeVerbose[OPCODE_ISTORE_3] = "istore_3"; 87 opcodeVerbose[OPCODE_LSTORE_0] = "lstore_0"; 88 opcodeVerbose[OPCODE_LSTORE_1] = "lstore_1"; 89 opcodeVerbose[OPCODE_LSTORE_2] = "lstore_2"; 90 opcodeVerbose[OPCODE_LSTORE_3] = "lstore_3"; 91 opcodeVerbose[OPCODE_FSTORE_0] = "fstore_0"; 92 opcodeVerbose[OPCODE_FSTORE_1] = "fstore_1"; 93 opcodeVerbose[OPCODE_FSTORE_2] = "fstore_2"; 94 opcodeVerbose[OPCODE_FSTORE_3] = "fstore_3"; 95 opcodeVerbose[OPCODE_DSTORE_0] = "dstore_0"; 96 opcodeVerbose[OPCODE_DSTORE_1] = "dstore_1"; 97 opcodeVerbose[OPCODE_DSTORE_2] = "dstore_2"; 98 opcodeVerbose[OPCODE_DSTORE_3] = "dstore_3"; 99 opcodeVerbose[OPCODE_ASTORE_0] = "astore_0"; 100 opcodeVerbose[OPCODE_ASTORE_1] = "astore_1"; 101 opcodeVerbose[OPCODE_ASTORE_2] = "astore_2"; 102 opcodeVerbose[OPCODE_ASTORE_3] = "astore_3"; 103 opcodeVerbose[OPCODE_IASTORE] = "iastore"; 104 opcodeVerbose[OPCODE_LASTORE] = "lastore"; 105 opcodeVerbose[OPCODE_FASTORE] = "fastore"; 106 opcodeVerbose[OPCODE_DASTORE] = "dastore"; 107 opcodeVerbose[OPCODE_AASTORE] = "aastore"; 108 opcodeVerbose[OPCODE_BASTORE] = "bastore"; 109 opcodeVerbose[OPCODE_CASTORE] = "castore"; 110 opcodeVerbose[OPCODE_SASTORE] = "sastore"; 111 opcodeVerbose[OPCODE_POP] = "pop"; 112 opcodeVerbose[OPCODE_POP2] = "pop2"; 113 opcodeVerbose[OPCODE_DUP] = "dup"; 114 opcodeVerbose[OPCODE_DUP_X1] = "dup_x1"; 115 opcodeVerbose[OPCODE_DUP_X2] = "dup_x2"; 116 opcodeVerbose[OPCODE_DUP2] = "dup2"; 117 opcodeVerbose[OPCODE_DUP2_X1] = "dup2_x1"; 118 opcodeVerbose[OPCODE_DUP2_X2] = "dup2_x2"; 119 opcodeVerbose[OPCODE_SWAP] = "swap"; 120 opcodeVerbose[OPCODE_IADD] = "iadd"; 121 opcodeVerbose[OPCODE_LADD] = "ladd"; 122 opcodeVerbose[OPCODE_FADD] = "fadd"; 123 opcodeVerbose[OPCODE_DADD] = "dadd"; 124 opcodeVerbose[OPCODE_ISUB] = "isub"; 125 opcodeVerbose[OPCODE_LSUB] = "lsub"; 126 opcodeVerbose[OPCODE_FSUB] = "fsub"; 127 opcodeVerbose[OPCODE_DSUB] = "dsub"; 128 opcodeVerbose[OPCODE_IMUL] = "imul"; 129 opcodeVerbose[OPCODE_LMUL] = "lmul"; 130 opcodeVerbose[OPCODE_FMUL] = "fmul"; 131 opcodeVerbose[OPCODE_DMUL] = "dmul"; 132 opcodeVerbose[OPCODE_IDIV] = "idiv"; 133 opcodeVerbose[OPCODE_LDIV] = "ldiv"; 134 opcodeVerbose[OPCODE_FDIV] = "fdiv"; 135 opcodeVerbose[OPCODE_DDIV] = "ddiv"; 136 opcodeVerbose[OPCODE_IREM] = "irem"; 137 opcodeVerbose[OPCODE_LREM] = "lrem"; 138 opcodeVerbose[OPCODE_FREM] = "frem"; 139 opcodeVerbose[OPCODE_DREM] = "drem"; 140 opcodeVerbose[OPCODE_INEG] = "ineg"; 141 opcodeVerbose[OPCODE_LNEG] = "lneg"; 142 opcodeVerbose[OPCODE_FNEG] = "fneg"; 143 opcodeVerbose[OPCODE_DNEG] = "dneg"; 144 opcodeVerbose[OPCODE_ISHL] = "ishl"; 145 opcodeVerbose[OPCODE_LSHL] = "lshl"; 146 opcodeVerbose[OPCODE_ISHR] = "ishr"; 147 opcodeVerbose[OPCODE_LSHR] = "lshr"; 148 opcodeVerbose[OPCODE_IUSHR] = "iushr"; 149 opcodeVerbose[OPCODE_LUSHR] = "lushr"; 150 opcodeVerbose[OPCODE_IAND] = "iand"; 151 opcodeVerbose[OPCODE_LAND] = "land"; 152 opcodeVerbose[OPCODE_IOR] = "ior"; 153 opcodeVerbose[OPCODE_LOR] = "lor"; 154 opcodeVerbose[OPCODE_IXOR] = "ixor"; 155 opcodeVerbose[OPCODE_LXOR] = "lxor"; 156 opcodeVerbose[OPCODE_IINC] = "iinc"; 157 opcodeVerbose[OPCODE_I2L] = "i2l"; 158 opcodeVerbose[OPCODE_I2F] = "i2f"; 159 opcodeVerbose[OPCODE_I2D] = "i2d"; 160 opcodeVerbose[OPCODE_L2I] = "l2i"; 161 opcodeVerbose[OPCODE_L2F] = "l2f"; 162 opcodeVerbose[OPCODE_L2D] = "l2d"; 163 opcodeVerbose[OPCODE_F2I] = "f2i"; 164 opcodeVerbose[OPCODE_F2L] = "f2l"; 165 opcodeVerbose[OPCODE_F2D] = "f2d"; 166 opcodeVerbose[OPCODE_D2I] = "d2i"; 167 opcodeVerbose[OPCODE_D2L] = "d2l"; 168 opcodeVerbose[OPCODE_D2F] = "d2f"; 169 opcodeVerbose[OPCODE_I2B] = "i2b"; 170 opcodeVerbose[OPCODE_I2C] = "i2c"; 171 opcodeVerbose[OPCODE_I2S] = "i2s"; 172 opcodeVerbose[OPCODE_LCMP] = "lcmp"; 173 opcodeVerbose[OPCODE_FCMPL] = "fcmpl"; 174 opcodeVerbose[OPCODE_FCMPG] = "fcmpg"; 175 opcodeVerbose[OPCODE_DCMPL] = "dcmpl"; 176 opcodeVerbose[OPCODE_DCMPG] = "dcmpg"; 177 opcodeVerbose[OPCODE_IFEQ] = "ifeq"; 178 opcodeVerbose[OPCODE_IFNE] = "ifne"; 179 opcodeVerbose[OPCODE_IFLT] = "iflt"; 180 opcodeVerbose[OPCODE_IFGE] = "ifge"; 181 opcodeVerbose[OPCODE_IFGT] = "ifgt"; 182 opcodeVerbose[OPCODE_IFLE] = "ifle"; 183 opcodeVerbose[OPCODE_IF_ICMPEQ] = "if_icmpeq"; 184 opcodeVerbose[OPCODE_IF_ICMPNE] = "if_icmpne"; 185 opcodeVerbose[OPCODE_IF_ICMPLT] = "if_icmplt"; 186 opcodeVerbose[OPCODE_IF_ICMPGE] = "if_icmpge"; 187 opcodeVerbose[OPCODE_IF_ICMPGT] = "if_icmpgt"; 188 opcodeVerbose[OPCODE_IF_ICMPLE] = "if_icmple"; 189 opcodeVerbose[OPCODE_IF_ACMPEQ] = "if_acmpeq"; 190 opcodeVerbose[OPCODE_IF_ACMPNE] = "if_acmpne"; 191 opcodeVerbose[OPCODE_GOTO] = "goto"; 192 opcodeVerbose[OPCODE_JSR] = "jsr"; 193 opcodeVerbose[OPCODE_RET] = "ret"; 194 opcodeVerbose[OPCODE_TABLESWITCH] = "tableswitch"; 195 opcodeVerbose[OPCODE_LOOKUPSWITCH] = "lookupswitch"; 196 opcodeVerbose[OPCODE_IRETURN] = "ireturn"; 197 opcodeVerbose[OPCODE_LRETURN] = "lreturn"; 198 opcodeVerbose[OPCODE_FRETURN] = "freturn"; 199 opcodeVerbose[OPCODE_DRETURN] = "dreturn"; 200 opcodeVerbose[OPCODE_ARETURN] = "areturn"; 201 opcodeVerbose[OPCODE_RETURN] = "return"; 202 opcodeVerbose[OPCODE_GETSTATIC] = "getstatic"; 203 opcodeVerbose[OPCODE_PUTSTATIC] = "putstatic"; 204 opcodeVerbose[OPCODE_GETFIELD] = "getfield"; 205 opcodeVerbose[OPCODE_PUTFIELD] = "putfield"; 206 opcodeVerbose[OPCODE_INVOKEVIRTUAL] = "invokevirtual"; 207 opcodeVerbose[OPCODE_INVOKESPECIAL] = "invokespecial"; 208 opcodeVerbose[OPCODE_INVOKESTATIC] = "invokestatic"; 209 opcodeVerbose[OPCODE_INVOKEINTERFACE] = "invokeinterface"; 210 opcodeVerbose[OPCODE_XXXUNUSEDXXX] = "xxxunusedxxx"; 211 opcodeVerbose[OPCODE_NEW] = "new"; 212 opcodeVerbose[OPCODE_NEWARRAY] = "newarray"; 213 opcodeVerbose[OPCODE_ANEWARRAY] = "anewarray"; 214 opcodeVerbose[OPCODE_ARRAYLENGTH] = "arraylength"; 215 opcodeVerbose[OPCODE_ATHROW] = "athrow"; 216 opcodeVerbose[OPCODE_CHECKCAST] = "checkcast"; 217 opcodeVerbose[OPCODE_INSTANCEOF] = "instanceof"; 218 opcodeVerbose[OPCODE_MONITORENTER] = "monitorenter"; 219 opcodeVerbose[OPCODE_MONITOREXIT] = "monitorexit"; 220 opcodeVerbose[OPCODE_WIDE] = "wide"; 221 opcodeVerbose[OPCODE_MULTIANEWARRAY] = "multianewarray"; 222 opcodeVerbose[OPCODE_IFNULL] = "ifnull"; 223 opcodeVerbose[OPCODE_IFNONNULL] = "ifnonnull"; 224 opcodeVerbose[OPCODE_GOTO_W] = "goto_w"; 225 opcodeVerbose[OPCODE_JSR_W] = "jsr_w"; 226 opcodeVerbose[OPCODE_BREAKPOINT] = "breakpoint"; 227 opcodeVerbose[OPCODE_IMPDEP1] = "impdep1"; 228 opcodeVerbose[OPCODE_IMPDEP2] = "impdep2"; 229 230 } 231 232 233 238 public static String getVerbose(int opcode) { 239 if (opcode < 0 || opcode > 255) { 240 return null; 241 } else { 242 return opcodeVerbose[opcode]; 243 } 244 } 245 246 252 public static String getArrayTypeVerbose(int arrayType) { 253 254 switch (arrayType) { 255 case NEWARRAY_T_BOOLEAN: 256 return "boolean"; 257 case NEWARRAY_T_CHAR: 258 return "char"; 259 case NEWARRAY_T_FLOAT: 260 return "float"; 261 case NEWARRAY_T_DOUBLE: 262 return "double"; 263 case NEWARRAY_T_BYTE: 264 return "byte"; 265 case NEWARRAY_T_SHORT: 266 return "short"; 267 case NEWARRAY_T_INT: 268 return "int"; 269 case NEWARRAY_T_LONG: 270 return "long"; 271 default: 272 return "invalid array type"; 273 } 274 } 275 } 276 | Popular Tags |