1 52 53 package com.go.trove.classfile; 54 55 65 public class Opcode { 66 public final static byte NOP = (byte)0; 67 public final static byte ACONST_NULL = (byte)1; 68 public final static byte ICONST_M1 = (byte)2; 69 public final static byte ICONST_0 = (byte)3; 70 public final static byte ICONST_1 = (byte)4; 71 public final static byte ICONST_2 = (byte)5; 72 public final static byte ICONST_3 = (byte)6; 73 public final static byte ICONST_4 = (byte)7; 74 public final static byte ICONST_5 = (byte)8; 75 public final static byte LCONST_0 = (byte)9; 76 public final static byte LCONST_1 = (byte)10; 77 public final static byte FCONST_0 = (byte)11; 78 public final static byte FCONST_1 = (byte)12; 79 public final static byte FCONST_2 = (byte)13; 80 public final static byte DCONST_0 = (byte)14; 81 public final static byte DCONST_1 = (byte)15; 82 public final static byte BIPUSH = (byte)16; 83 public final static byte SIPUSH = (byte)17; 84 public final static byte LDC = (byte)18; 85 public final static byte LDC_W = (byte)19; 86 public final static byte LDC2_W = (byte)20; 87 public final static byte ILOAD = (byte)21; 88 public final static byte LLOAD = (byte)22; 89 public final static byte FLOAD = (byte)23; 90 public final static byte DLOAD = (byte)24; 91 public final static byte ALOAD = (byte)25; 92 public final static byte ILOAD_0 = (byte)26; 93 public final static byte ILOAD_1 = (byte)27; 94 public final static byte ILOAD_2 = (byte)28; 95 public final static byte ILOAD_3 = (byte)29; 96 public final static byte LLOAD_0 = (byte)30; 97 public final static byte LLOAD_1 = (byte)31; 98 public final static byte LLOAD_2 = (byte)32; 99 public final static byte LLOAD_3 = (byte)33; 100 public final static byte FLOAD_0 = (byte)34; 101 public final static byte FLOAD_1 = (byte)35; 102 public final static byte FLOAD_2 = (byte)36; 103 public final static byte FLOAD_3 = (byte)37; 104 public final static byte DLOAD_0 = (byte)38; 105 public final static byte DLOAD_1 = (byte)39; 106 public final static byte DLOAD_2 = (byte)40; 107 public final static byte DLOAD_3 = (byte)41; 108 public final static byte ALOAD_0 = (byte)42; 109 public final static byte ALOAD_1 = (byte)43; 110 public final static byte ALOAD_2 = (byte)44; 111 public final static byte ALOAD_3 = (byte)45; 112 public final static byte IALOAD = (byte)46; 113 public final static byte LALOAD = (byte)47; 114 public final static byte FALOAD = (byte)48; 115 public final static byte DALOAD = (byte)49; 116 public final static byte AALOAD = (byte)50; 117 public final static byte BALOAD = (byte)51; 118 public final static byte CALOAD = (byte)52; 119 public final static byte SALOAD = (byte)53; 120 public final static byte ISTORE = (byte)54; 121 public final static byte LSTORE = (byte)55; 122 public final static byte FSTORE = (byte)56; 123 public final static byte DSTORE = (byte)57; 124 public final static byte ASTORE = (byte)58; 125 public final static byte ISTORE_0 = (byte)59; 126 public final static byte ISTORE_1 = (byte)60; 127 public final static byte ISTORE_2 = (byte)61; 128 public final static byte ISTORE_3 = (byte)62; 129 public final static byte LSTORE_0 = (byte)63; 130 public final static byte LSTORE_1 = (byte)64; 131 public final static byte LSTORE_2 = (byte)65; 132 public final static byte LSTORE_3 = (byte)66; 133 public final static byte FSTORE_0 = (byte)67; 134 public final static byte FSTORE_1 = (byte)68; 135 public final static byte FSTORE_2 = (byte)69; 136 public final static byte FSTORE_3 = (byte)70; 137 public final static byte DSTORE_0 = (byte)71; 138 public final static byte DSTORE_1 = (byte)72; 139 public final static byte DSTORE_2 = (byte)73; 140 public final static byte DSTORE_3 = (byte)74; 141 public final static byte ASTORE_0 = (byte)75; 142 public final static byte ASTORE_1 = (byte)76; 143 public final static byte ASTORE_2 = (byte)77; 144 public final static byte ASTORE_3 = (byte)78; 145 public final static byte IASTORE = (byte)79; 146 public final static byte LASTORE = (byte)80; 147 public final static byte FASTORE = (byte)81; 148 public final static byte DASTORE = (byte)82; 149 public final static byte AASTORE = (byte)83; 150 public final static byte BASTORE = (byte)84; 151 public final static byte CASTORE = (byte)85; 152 public final static byte SASTORE = (byte)86; 153 public final static byte POP = (byte)87; 154 public final static byte POP2 = (byte)88; 155 public final static byte DUP = (byte)89; 156 public final static byte DUP_X1 = (byte)90; 157 public final static byte DUP_X2 = (byte)91; 158 public final static byte DUP2 = (byte)92; 159 public final static byte DUP2_X1 = (byte)93; 160 public final static byte DUP2_X2 = (byte)94; 161 public final static byte SWAP = (byte)95; 162 public final static byte IADD = (byte)96; 163 public final static byte LADD = (byte)97; 164 public final static byte FADD = (byte)98; 165 public final static byte DADD = (byte)99; 166 public final static byte ISUB = (byte)100; 167 public final static byte LSUB = (byte)101; 168 public final static byte FSUB = (byte)102; 169 public final static byte DSUB = (byte)103; 170 public final static byte IMUL = (byte)104; 171 public final static byte LMUL = (byte)105; 172 public final static byte FMUL = (byte)106; 173 public final static byte DMUL = (byte)107; 174 public final static byte IDIV = (byte)108; 175 public final static byte LDIV = (byte)109; 176 public final static byte FDIV = (byte)110; 177 public final static byte DDIV = (byte)111; 178 public final static byte IREM = (byte)112; 179 public final static byte LREM = (byte)113; 180 public final static byte FREM = (byte)114; 181 public final static byte DREM = (byte)115; 182 public final static byte INEG = (byte)116; 183 public final static byte LNEG = (byte)117; 184 public final static byte FNEG = (byte)118; 185 public final static byte DNEG = (byte)119; 186 public final static byte ISHL = (byte)120; 187 public final static byte LSHL = (byte)121; 188 public final static byte ISHR = (byte)122; 189 public final static byte LSHR = (byte)123; 190 public final static byte IUSHR = (byte)124; 191 public final static byte LUSHR = (byte)125; 192 public final static byte IAND = (byte)126; 193 public final static byte LAND = (byte)127; 194 public final static byte IOR = (byte)128; 195 public final static byte LOR = (byte)129; 196 public final static byte IXOR = (byte)130; 197 public final static byte LXOR = (byte)131; 198 public final static byte IINC = (byte)132; 199 public final static byte I2L = (byte)133; 200 public final static byte I2F = (byte)134; 201 public final static byte I2D = (byte)135; 202 public final static byte L2I = (byte)136; 203 public final static byte L2F = (byte)137; 204 public final static byte L2D = (byte)138; 205 public final static byte F2I = (byte)139; 206 public final static byte F2L = (byte)140; 207 public final static byte F2D = (byte)141; 208 public final static byte D2I = (byte)142; 209 public final static byte D2L = (byte)143; 210 public final static byte D2F = (byte)144; 211 public final static byte I2B = (byte)145; 212 public final static byte I2C = (byte)146; 213 public final static byte I2S = (byte)147; 214 public final static byte LCMP = (byte)148; 215 public final static byte FCMPL = (byte)149; 216 public final static byte FCMPG = (byte)150; 217 public final static byte DCMPL = (byte)151; 218 public final static byte DCMPG = (byte)152; 219 public final static byte IFEQ = (byte)153; 220 public final static byte IFNE = (byte)154; 221 public final static byte IFLT = (byte)155; 222 public final static byte IFGE = (byte)156; 223 public final static byte IFGT = (byte)157; 224 public final static byte IFLE = (byte)158; 225 public final static byte IF_ICMPEQ = (byte)159; 226 public final static byte IF_ICMPNE = (byte)160; 227 public final static byte IF_ICMPLT = (byte)161; 228 public final static byte IF_ICMPGE = (byte)162; 229 public final static byte IF_ICMPGT = (byte)163; 230 public final static byte IF_ICMPLE = (byte)164; 231 public final static byte IF_ACMPEQ = (byte)165; 232 public final static byte IF_ACMPNE = (byte)166; 233 public final static byte GOTO = (byte)167; 234 public final static byte JSR = (byte)168; 235 public final static byte RET = (byte)169; 236 public final static byte TABLESWITCH = (byte)170; 237 public final static byte LOOKUPSWITCH = (byte)171; 238 public final static byte IRETURN = (byte)172; 239 public final static byte LRETURN = (byte)173; 240 public final static byte FRETURN = (byte)174; 241 public final static byte DRETURN = (byte)175; 242 public final static byte ARETURN = (byte)176; 243 public final static byte RETURN = (byte)177; 244 public final static byte GETSTATIC = (byte)178; 245 public final static byte PUTSTATIC = (byte)179; 246 public final static byte GETFIELD = (byte)180; 247 public final static byte PUTFIELD = (byte)181; 248 public final static byte INVOKEVIRTUAL = (byte)182; 249 public final static byte INVOKESPECIAL = (byte)183; 250 public final static byte INVOKESTATIC = (byte)184; 251 public final static byte INVOKEINTERFACE = (byte)185; 252 public final static byte UNUSED = (byte)186; 253 public final static byte NEW = (byte)187; 254 public final static byte NEWARRAY = (byte)188; 255 public final static byte ANEWARRAY = (byte)189; 256 public final static byte ARRAYLENGTH = (byte)190; 257 public final static byte ATHROW = (byte)191; 258 public final static byte CHECKCAST = (byte)192; 259 public final static byte INSTANCEOF = (byte)193; 260 public final static byte MONITORENTER = (byte)194; 261 public final static byte MONITOREXIT = (byte)195; 262 public final static byte WIDE = (byte)196; 263 public final static byte MULTIANEWARRAY = (byte)197; 264 public final static byte IFNULL = (byte)198; 265 public final static byte IFNONNULL = (byte)199; 266 public final static byte GOTO_W = (byte)200; 267 public final static byte JSR_W = (byte)201; 268 public final static byte BREAKPOINT = (byte)202; 269 270 273 public final static String getMnemonic(byte opcode) 274 throws IllegalArgumentException { 275 try { 276 return Mnemonic.m[opcode & 0xff]; 277 } 278 catch (ArrayIndexOutOfBoundsException e) { 279 throw new IllegalArgumentException 280 ("Opcode not valid: " + opcode); 281 } 282 } 283 284 288 public final static byte reverseIfOpcode(byte opcode) { 289 294 switch (opcode) { 295 case IF_ACMPEQ: 296 return IF_ACMPNE; 297 case IF_ACMPNE: 298 return IF_ACMPEQ; 299 case IF_ICMPEQ: 300 return IF_ICMPNE; 301 case IF_ICMPNE: 302 return IF_ICMPEQ; 303 case IF_ICMPLT: 304 return IF_ICMPGE; 305 case IF_ICMPGE: 306 return IF_ICMPLT; 307 case IF_ICMPGT: 308 return IF_ICMPLE; 309 case IF_ICMPLE: 310 return IF_ICMPGT; 311 case IFEQ: 312 return IFNE; 313 case IFNE: 314 return IFEQ; 315 case IFLT: 316 return IFGE; 317 case IFGE: 318 return IFLT; 319 case IFGT: 320 return IFLE; 321 case IFLE: 322 return IFGT; 323 case IFNONNULL: 324 return IFNULL; 325 case IFNULL: 326 return IFNONNULL; 327 default: 328 throw new IllegalArgumentException 329 ("Opcode not an if instruction: " + getMnemonic(opcode)); 330 } 331 } 332 333 private static class Mnemonic { 334 public static final String [] m = 335 { 336 "nop", 337 "aconst_null", 338 "iconst_m1", 339 "iconst_0", 340 "iconst_1", 341 "iconst_2", 342 "iconst_3", 343 "iconst_4", 344 "iconst_5", 345 "lconst_0", 346 "lconst_1", 347 "fconst_0", 348 "fconst_1", 349 "fconst_2", 350 "dconst_0", 351 "dconst_1", 352 "bipush", 353 "sipush", 354 "ldc", 355 "ldc_w", 356 "ldc2_w", 357 "iload", 358 "lload", 359 "fload", 360 "dload", 361 "aload", 362 "iload_0", 363 "iload_1", 364 "iload_2", 365 "iload_3", 366 "lload_0", 367 "lload_1", 368 "lload_2", 369 "lload_3", 370 "fload_0", 371 "fload_1", 372 "fload_2", 373 "fload_3", 374 "dload_0", 375 "dload_1", 376 "dload_2", 377 "dload_3", 378 "aload_0", 379 "aload_1", 380 "aload_2", 381 "aload_3", 382 "iaload", 383 "laload", 384 "faload", 385 "daload", 386 "aaload", 387 "baload", 388 "caload", 389 "saload", 390 "istore", 391 "lstore", 392 "fstore", 393 "dstore", 394 "astore", 395 "istore_0", 396 "istore_1", 397 "istore_2", 398 "istore_3", 399 "lstore_0", 400 "lstore_1", 401 "lstore_2", 402 "lstore_3", 403 "fstore_0", 404 "fstore_1", 405 "fstore_2", 406 "fstore_3", 407 "dstore_0", 408 "dstore_1", 409 "dstore_2", 410 "dstore_3", 411 "astore_0", 412 "astore_1", 413 "astore_2", 414 "astore_3", 415 "iastore", 416 "lastore", 417 "fastore", 418 "dastore", 419 "aastore", 420 "bastore", 421 "castore", 422 "sastore", 423 "pop", 424 "pop2", 425 "dup", 426 "dup_x1", 427 "dup_x2", 428 "dup2", 429 "dup2_x1", 430 "dup2_x2", 431 "swap", 432 "iadd", 433 "ladd", 434 "fadd", 435 "dadd", 436 "isub", 437 "lsub", 438 "fsub", 439 "dsub", 440 "imul", 441 "lmul", 442 "fmul", 443 "dmul", 444 "idiv", 445 "ldiv", 446 "fdiv", 447 "ddiv", 448 "irem", 449 "lrem", 450 "frem", 451 "drem", 452 "ineg", 453 "lneg", 454 "fneg", 455 "dneg", 456 "ishl", 457 "lshl", 458 "ishr", 459 "lshr", 460 "iushr", 461 "lushr", 462 "iand", 463 "land", 464 "ior", 465 "lor", 466 "ixor", 467 "lxor", 468 "iinc", 469 "i2l", 470 "i2f", 471 "i2d", 472 "l2i", 473 "l2f", 474 "l2d", 475 "f2i", 476 "f2l", 477 "f2d", 478 "d2i", 479 "d2l", 480 "d2f", 481 "i2b", 482 "i2c", 483 "i2s", 484 "lcmp", 485 "fcmpl", 486 "fcmpg", 487 "dcmpl", 488 "dcmpg", 489 "ifeq", 490 "ifne", 491 "iflt", 492 "ifge", 493 "ifgt", 494 "ifle", 495 "if_icmpeq", 496 "if_icmpne", 497 "if_icmplt", 498 "if_icmpge", 499 "if_icmpgt", 500 "if_icmple", 501 "if_acmpeq", 502 "if_acmpne", 503 "goto", 504 "jsr", 505 "ret", 506 "tableswitch", 507 "lookupswitch", 508 "ireturn", 509 "lreturn", 510 "freturn", 511 "dreturn", 512 "areturn", 513 "return", 514 "getstatic", 515 "putstatic", 516 "getfield", 517 "putfield", 518 "invokevirtual", 519 "invokespecial", 520 "invokestatic", 521 "invokeinterface", 522 "unused", 523 "new", 524 "newarray", 525 "anewarray", 526 "arraylength", 527 "athrow", 528 "checkcast", 529 "instanceof", 530 "monitorenter", 531 "monitorexit", 532 "wide", 533 "multianewarray", 534 "ifnull", 535 "ifnonnull", 536 "goto_w", 537 "jsr_w", 538 "breakpoint", 539 }; 540 } 541 } 542 | Popular Tags |