1 19 20 25 26 27 28 29 30 31 32 package soot.coffi; 33 import soot.*; 34 35 38 class ByteCode { 39 40 public static final int NOP = 0; 41 public static final int ACONST_NULL = 1; 42 public static final int ICONST_M1 = 2; 43 public static final int ICONST_0 = 3; 44 public static final int ICONST_1 = 4; 45 public static final int ICONST_2 = 5; 46 public static final int ICONST_3 = 6; 47 public static final int ICONST_4 = 7; 48 public static final int ICONST_5 = 8; 49 public static final int LCONST_0 = 9; 50 public static final int LCONST_1 = 10; 51 public static final int FCONST_0 = 11; 52 public static final int FCONST_1 = 12; 53 public static final int FCONST_2 = 13; 54 public static final int DCONST_0 = 14; 55 public static final int DCONST_1 = 15; 56 public static final int BIPUSH = 16; 57 public static final int SIPUSH = 17; 58 public static final int LDC1 = 18; 59 public static final int LDC2 = 19; 60 public static final int LDC2W = 20; 61 public static final int ILOAD = 21; 62 public static final int LLOAD = 22; 63 public static final int FLOAD = 23; 64 public static final int DLOAD = 24; 65 public static final int ALOAD = 25; 66 public static final int ILOAD_0 = 26; 67 public static final int ILOAD_1 = 27; 68 public static final int ILOAD_2 = 28; 69 public static final int ILOAD_3 = 29; 70 public static final int LLOAD_0 = 30; 71 public static final int LLOAD_1 = 31; 72 public static final int LLOAD_2 = 32; 73 public static final int LLOAD_3 = 33; 74 public static final int FLOAD_0 = 34; 75 public static final int FLOAD_1 = 35; 76 public static final int FLOAD_2 = 36; 77 public static final int FLOAD_3 = 37; 78 public static final int DLOAD_0 = 38; 79 public static final int DLOAD_1 = 39; 80 public static final int DLOAD_2 = 40; 81 public static final int DLOAD_3 = 41; 82 public static final int ALOAD_0 = 42; 83 public static final int ALOAD_1 = 43; 84 public static final int ALOAD_2 = 44; 85 public static final int ALOAD_3 = 45; 86 public static final int IALOAD = 46; 87 public static final int LALOAD = 47; 88 public static final int FALOAD = 48; 89 public static final int DALOAD = 49; 90 public static final int AALOAD = 50; 91 public static final int BALOAD = 51; 92 public static final int CALOAD = 52; 93 public static final int SALOAD = 53; 94 public static final int ISTORE = 54; 95 public static final int LSTORE = 55; 96 public static final int FSTORE = 56; 97 public static final int DSTORE = 57; 98 public static final int ASTORE = 58; 99 public static final int ISTORE_0 = 59; 100 public static final int ISTORE_1 = 60; 101 public static final int ISTORE_2 = 61; 102 public static final int ISTORE_3 = 62; 103 public static final int LSTORE_0 = 63; 104 public static final int LSTORE_1 = 64; 105 public static final int LSTORE_2 = 65; 106 public static final int LSTORE_3 = 66; 107 public static final int FSTORE_0 = 67; 108 public static final int FSTORE_1 = 68; 109 public static final int FSTORE_2 = 69; 110 public static final int FSTORE_3 = 70; 111 public static final int DSTORE_0 = 71; 112 public static final int DSTORE_1 = 72; 113 public static final int DSTORE_2 = 73; 114 public static final int DSTORE_3 = 74; 115 public static final int ASTORE_0 = 75; 116 public static final int ASTORE_1 = 76; 117 public static final int ASTORE_2 = 77; 118 public static final int ASTORE_3 = 78; 119 public static final int IASTORE = 79; 120 public static final int LASTORE = 80; 121 public static final int FASTORE = 81; 122 public static final int DASTORE = 82; 123 public static final int AASTORE = 83; 124 public static final int BASTORE = 84; 125 public static final int CASTORE = 85; 126 public static final int SASTORE = 86; 127 public static final int POP = 87; 128 public static final int POP2 = 88; 129 public static final int DUP = 89; 130 public static final int DUP_X1 = 90; 131 public static final int DUP_X2 = 91; 132 public static final int DUP2 = 92; 133 public static final int DUP2_X1 = 93; 134 public static final int DUP2_X2 = 94; 135 public static final int SWAP = 95; 136 public static final int IADD = 96; 137 public static final int LADD = 97; 138 public static final int FADD = 98; 139 public static final int DADD = 99; 140 public static final int ISUB = 100; 141 public static final int LSUB = 101; 142 public static final int FSUB = 102; 143 public static final int DSUB = 103; 144 public static final int IMUL = 104; 145 public static final int LMUL = 105; 146 public static final int FMUL = 106; 147 public static final int DMUL = 107; 148 public static final int IDIV = 108; 149 public static final int LDIV = 109; 150 public static final int FDIV = 110; 151 public static final int DDIV = 111; 152 public static final int IREM = 112; 153 public static final int LREM = 113; 154 public static final int FREM = 114; 155 public static final int DREM = 115; 156 public static final int INEG = 116; 157 public static final int LNEG = 117; 158 public static final int FNEG = 118; 159 public static final int DNEG = 119; 160 public static final int ISHL = 120; 161 public static final int LSHL = 121; 162 public static final int ISHR = 122; 163 public static final int LSHR = 123; 164 public static final int IUSHR = 124; 165 public static final int LUSHR = 125; 166 public static final int IAND = 126; 167 public static final int LAND = 127; 168 public static final int IOR = 128; 169 public static final int LOR = 129; 170 public static final int IXOR = 130; 171 public static final int LXOR = 131; 172 public static final int IINC = 132; 173 public static final int I2L = 133; 174 public static final int I2F = 134; 175 public static final int I2D = 135; 176 public static final int L2I = 136; 177 public static final int L2F = 137; 178 public static final int L2D = 138; 179 public static final int F2I = 139; 180 public static final int F2L = 140; 181 public static final int F2D = 141; 182 public static final int D2I = 142; 183 public static final int D2L = 143; 184 public static final int D2F = 144; 185 public static final int INT2BYTE = 145; 186 public static final int INT2CHAR = 146; 187 public static final int INT2SHORT = 147; 188 public static final int LCMP = 148; 189 public static final int FCMPL = 149; 190 public static final int FCMPG = 150; 191 public static final int DCMPL = 151; 192 public static final int DCMPG = 152; 193 public static final int IFEQ = 153; 194 public static final int IFNE = 154; 195 public static final int IFLT = 155; 196 public static final int IFGE = 156; 197 public static final int IFGT = 157; 198 public static final int IFLE = 158; 199 public static final int IF_ICMPEQ = 159; 200 public static final int IF_ICMPNE = 160; 201 public static final int IF_ICMPLT = 161; 202 public static final int IF_ICMPGE = 162; 203 public static final int IF_ICMPGT = 163; 204 public static final int IF_ICMPLE = 164; 205 public static final int IF_ACMPEQ = 165; 206 public static final int IF_ACMPNE = 166; 207 public static final int GOTO = 167; 208 public static final int JSR = 168; 209 public static final int RET = 169; 210 public static final int TABLESWITCH = 170; 211 public static final int LOOKUPSWITCH = 171; 212 public static final int IRETURN = 172; 213 public static final int LRETURN = 173; 214 public static final int FRETURN = 174; 215 public static final int DRETURN = 175; 216 public static final int ARETURN = 176; 217 public static final int RETURN = 177; 218 public static final int GETSTATIC = 178; 219 public static final int PUTSTATIC = 179; 220 public static final int GETFIELD = 180; 221 public static final int PUTFIELD = 181; 222 public static final int INVOKEVIRTUAL = 182; 223 public static final int INVOKENONVIRTUAL = 183; 224 public static final int INVOKESTATIC = 184; 225 public static final int INVOKEINTERFACE = 185; 226 227 public static final int NEW = 187; 228 public static final int NEWARRAY = 188; 229 public static final int ANEWARRAY = 189; 230 public static final int ARRAYLENGTH = 190; 231 public static final int ATHROW = 191; 232 public static final int CHECKCAST = 192; 233 public static final int INSTANCEOF = 193; 234 public static final int MONITORENTER = 194; 235 public static final int MONITOREXIT = 195; 236 public static final int WIDE = 196; 237 public static final int MULTIANEWARRAY = 197; 238 public static final int IFNULL = 198; 239 public static final int IFNONNULL = 199; 240 public static final int GOTO_W = 200; 241 public static final int JSR_W = 201; 242 public static final int BREAKPOINT = 202; 243 249 public static final int RET_W = 209; 250 296 297 private int icount; 298 private Instruction instructions[]; 299 300 301 ByteCode() { } 302 303 314 public Instruction disassemble_bytecode(byte bc[],int index) { 315 byte b = bc[index]; 318 boolean isWide = false; 319 Instruction i; 320 int x; 321 322 x = ((int)b)&0xff; 323 324 switch(x) { 325 case BIPUSH: 326 i = (Instruction)new Instruction_Bipush(); 327 break; 328 case SIPUSH: 329 i = (Instruction)new Instruction_Sipush(); 330 break; 331 case LDC1: 332 i = (Instruction)new Instruction_Ldc1(); 333 break; 334 case LDC2: 335 i = (Instruction)new Instruction_Ldc2(); 336 break; 337 case LDC2W: 338 i = (Instruction)new Instruction_Ldc2w(); 339 break; 340 case ACONST_NULL: 341 i = (Instruction)new Instruction_Aconst_null(); 342 break; 343 case ICONST_M1: 344 i = (Instruction)new Instruction_Iconst_m1(); 345 break; 346 case ICONST_0: 347 i = (Instruction)new Instruction_Iconst_0(); 348 break; 349 case ICONST_1: 350 i = (Instruction)new Instruction_Iconst_1(); 351 break; 352 case ICONST_2: 353 i = (Instruction)new Instruction_Iconst_2(); 354 break; 355 case ICONST_3: 356 i = (Instruction)new Instruction_Iconst_3(); 357 break; 358 case ICONST_4: 359 i = (Instruction)new Instruction_Iconst_4(); 360 break; 361 case ICONST_5: 362 i = (Instruction)new Instruction_Iconst_5(); 363 break; 364 case LCONST_0: 365 i = (Instruction)new Instruction_Lconst_0(); 366 break; 367 case LCONST_1: 368 i = (Instruction)new Instruction_Lconst_1(); 369 break; 370 case FCONST_0: 371 i = (Instruction)new Instruction_Fconst_0(); 372 break; 373 case FCONST_1: 374 i = (Instruction)new Instruction_Fconst_1(); 375 break; 376 case FCONST_2: 377 i = (Instruction)new Instruction_Fconst_2(); 378 break; 379 case DCONST_0: 380 i = (Instruction)new Instruction_Dconst_0(); 381 break; 382 case DCONST_1: 383 i = (Instruction)new Instruction_Dconst_1(); 384 break; 385 case ILOAD: 386 i = (Instruction)new Instruction_Iload(); 387 break; 388 case ILOAD_0: 389 i = (Instruction)new Instruction_Iload_0(); 390 break; 391 case ILOAD_1: 392 i = (Instruction)new Instruction_Iload_1(); 393 break; 394 case ILOAD_2: 395 i = (Instruction)new Instruction_Iload_2(); 396 break; 397 case ILOAD_3: 398 i = (Instruction)new Instruction_Iload_3(); 399 break; 400 case LLOAD: 401 i = (Instruction)new Instruction_Lload(); 402 break; 403 case LLOAD_0: 404 i = (Instruction)new Instruction_Lload_0(); 405 break; 406 case LLOAD_1: 407 i = (Instruction)new Instruction_Lload_1(); 408 break; 409 case LLOAD_2: 410 i = (Instruction)new Instruction_Lload_2(); 411 break; 412 case LLOAD_3: 413 i = (Instruction)new Instruction_Lload_3(); 414 break; 415 case FLOAD: 416 i = (Instruction)new Instruction_Fload(); 417 break; 418 case FLOAD_0: 419 i = (Instruction)new Instruction_Fload_0(); 420 break; 421 case FLOAD_1: 422 i = (Instruction)new Instruction_Fload_1(); 423 break; 424 case FLOAD_2: 425 i = (Instruction)new Instruction_Fload_2(); 426 break; 427 case FLOAD_3: 428 i = (Instruction)new Instruction_Fload_3(); 429 break; 430 case DLOAD: 431 i = (Instruction)new Instruction_Dload(); 432 break; 433 case DLOAD_0: 434 i = (Instruction)new Instruction_Dload_0(); 435 break; 436 case DLOAD_1: 437 i = (Instruction)new Instruction_Dload_1(); 438 break; 439 case DLOAD_2: 440 i = (Instruction)new Instruction_Dload_2(); 441 break; 442 case DLOAD_3: 443 i = (Instruction)new Instruction_Dload_3(); 444 break; 445 case ALOAD: 446 i = (Instruction)new Instruction_Aload(); 447 break; 448 case ALOAD_0: 449 i = (Instruction)new Instruction_Aload_0(); 450 break; 451 case ALOAD_1: 452 i = (Instruction)new Instruction_Aload_1(); 453 break; 454 case ALOAD_2: 455 i = (Instruction)new Instruction_Aload_2(); 456 break; 457 case ALOAD_3: 458 i = (Instruction)new Instruction_Aload_3(); 459 break; 460 case ISTORE: 461 i = (Instruction)new Instruction_Istore(); 462 break; 463 case ISTORE_0: 464 i = (Instruction)new Instruction_Istore_0(); 465 break; 466 case ISTORE_1: 467 i = (Instruction)new Instruction_Istore_1(); 468 break; 469 case ISTORE_2: 470 i = (Instruction)new Instruction_Istore_2(); 471 break; 472 case ISTORE_3: 473 i = (Instruction)new Instruction_Istore_3(); 474 break; 475 case LSTORE: 476 i = (Instruction)new Instruction_Lstore(); 477 break; 478 case LSTORE_0: 479 i = (Instruction)new Instruction_Lstore_0(); 480 break; 481 case LSTORE_1: 482 i = (Instruction)new Instruction_Lstore_1(); 483 break; 484 case LSTORE_2: 485 i = (Instruction)new Instruction_Lstore_2(); 486 break; 487 case LSTORE_3: 488 i = (Instruction)new Instruction_Lstore_3(); 489 break; 490 case FSTORE: 491 i = (Instruction)new Instruction_Fstore(); 492 break; 493 case FSTORE_0: 494 i = (Instruction)new Instruction_Fstore_0(); 495 break; 496 case FSTORE_1: 497 i = (Instruction)new Instruction_Fstore_1(); 498 break; 499 case FSTORE_2: 500 i = (Instruction)new Instruction_Fstore_2(); 501 break; 502 case FSTORE_3: 503 i = (Instruction)new Instruction_Fstore_3(); 504 break; 505 case DSTORE: 506 i = (Instruction)new Instruction_Dstore(); 507 break; 508 case DSTORE_0: 509 i = (Instruction)new Instruction_Dstore_0(); 510 break; 511 case DSTORE_1: 512 i = (Instruction)new Instruction_Dstore_1(); 513 break; 514 case DSTORE_2: 515 i = (Instruction)new Instruction_Dstore_2(); 516 break; 517 case DSTORE_3: 518 i = (Instruction)new Instruction_Dstore_3(); 519 break; 520 case ASTORE: 521 i = (Instruction)new Instruction_Astore(); 522 break; 523 case ASTORE_0: 524 i = (Instruction)new Instruction_Astore_0(); 525 break; 526 case ASTORE_1: 527 i = (Instruction)new Instruction_Astore_1(); 528 break; 529 case ASTORE_2: 530 i = (Instruction)new Instruction_Astore_2(); 531 break; 532 case ASTORE_3: 533 i = (Instruction)new Instruction_Astore_3(); 534 break; 535 case IINC: 536 i = (Instruction)new Instruction_Iinc(); 537 break; 538 case WIDE: 539 { 540 int nextIndex = ((int) bc[index+1]) & 0xff; 541 542 switch(nextIndex) 543 { 544 case ILOAD: 545 i = new Instruction_Iload(); 546 break; 547 548 case FLOAD: 549 i = new Instruction_Fload(); 550 break; 551 552 case ALOAD: 553 i = new Instruction_Aload(); 554 break; 555 556 case LLOAD: 557 i = new Instruction_Lload(); 558 break; 559 560 case DLOAD: 561 i = new Instruction_Dload(); 562 break; 563 564 case ISTORE: 565 i = new Instruction_Istore(); 566 break; 567 568 case FSTORE: 569 i = new Instruction_Fstore(); 570 break; 571 572 case ASTORE: 573 i = new Instruction_Astore(); 574 break; 575 576 case LSTORE: 577 i = new Instruction_Lstore(); 578 break; 579 580 case DSTORE: 581 i = new Instruction_Dstore(); 582 break; 583 584 case RET: 585 i = new Instruction_Ret(); 586 break; 587 588 case IINC: 589 i = new Instruction_Iinc(); 590 break; 591 592 default: 593 throw new RuntimeException ("invalid wide instruction: " + nextIndex); 594 } 595 596 ((Instruction_bytevar) i).isWide = true; 597 isWide = true; 598 } 599 600 break; 601 602 case NEWARRAY: 603 i = (Instruction)new Instruction_Newarray(); 604 break; 605 case ANEWARRAY: 606 i = (Instruction)new Instruction_Anewarray(); 607 break; 608 case MULTIANEWARRAY: 609 i = (Instruction)new Instruction_Multianewarray(); 610 break; 611 case ARRAYLENGTH: 612 i = (Instruction)new Instruction_Arraylength(); 613 break; 614 case IALOAD: 615 i = (Instruction)new Instruction_Iaload(); 616 break; 617 case LALOAD: 618 i = (Instruction)new Instruction_Laload(); 619 break; 620 case FALOAD: 621 i = (Instruction)new Instruction_Faload(); 622 break; 623 case DALOAD: 624 i = (Instruction)new Instruction_Daload(); 625 break; 626 case AALOAD: 627 i = (Instruction)new Instruction_Aaload(); 628 break; 629 case BALOAD: 630 i = (Instruction)new Instruction_Baload(); 631 break; 632 case CALOAD: 633 i = (Instruction)new Instruction_Caload(); 634 break; 635 case SALOAD: 636 i = (Instruction)new Instruction_Saload(); 637 break; 638 case IASTORE: 639 i = (Instruction)new Instruction_Iastore(); 640 break; 641 case LASTORE: 642 i = (Instruction)new Instruction_Lastore(); 643 break; 644 case FASTORE: 645 i = (Instruction)new Instruction_Fastore(); 646 break; 647 case DASTORE: 648 i = (Instruction)new Instruction_Dastore(); 649 break; 650 case AASTORE: 651 i = (Instruction)new Instruction_Aastore(); 652 break; 653 case BASTORE: 654 i = (Instruction)new Instruction_Bastore(); 655 break; 656 case CASTORE: 657 i = (Instruction)new Instruction_Castore(); 658 break; 659 case SASTORE: 660 i = (Instruction)new Instruction_Sastore(); 661 break; 662 case NOP: 663 i = (Instruction)new Instruction_Nop(); 664 break; 665 case POP: 666 i = (Instruction)new Instruction_Pop(); 667 break; 668 case POP2: 669 i = (Instruction)new Instruction_Pop2(); 670 break; 671 case DUP: 672 i = (Instruction)new Instruction_Dup(); 673 break; 674 case DUP2: 675 i = (Instruction)new Instruction_Dup2(); 676 break; 677 case DUP_X1: 678 i = (Instruction)new Instruction_Dup_x1(); 679 break; 680 case DUP_X2: 681 i = (Instruction)new Instruction_Dup_x2(); 682 break; 683 case DUP2_X1: 684 i = (Instruction)new Instruction_Dup2_x1(); 685 break; 686 case DUP2_X2: 687 i = (Instruction)new Instruction_Dup2_x2(); 688 break; 689 case SWAP: 690 i = (Instruction)new Instruction_Swap(); 691 break; 692 case IADD: 693 i = (Instruction)new Instruction_Iadd(); 694 break; 695 case LADD: 696 i = (Instruction)new Instruction_Ladd(); 697 break; 698 case FADD: 699 i = (Instruction)new Instruction_Fadd(); 700 break; 701 case DADD: 702 i = (Instruction)new Instruction_Dadd(); 703 break; 704 case ISUB: 705 i = (Instruction)new Instruction_Isub(); 706 break; 707 case LSUB: 708 i = (Instruction)new Instruction_Lsub(); 709 break; 710 case FSUB: 711 i = (Instruction)new Instruction_Fsub(); 712 break; 713 case DSUB: 714 i = (Instruction)new Instruction_Dsub(); 715 break; 716 case IMUL: 717 i = (Instruction)new Instruction_Imul(); 718 break; 719 case LMUL: 720 i = (Instruction)new Instruction_Lmul(); 721 break; 722 case FMUL: 723 i = (Instruction)new Instruction_Fmul(); 724 break; 725 case DMUL: 726 i = (Instruction)new Instruction_Dmul(); 727 break; 728 case IDIV: 729 i = (Instruction)new Instruction_Idiv(); 730 break; 731 case LDIV: 732 i = (Instruction)new Instruction_Ldiv(); 733 break; 734 case FDIV: 735 i = (Instruction)new Instruction_Fdiv(); 736 break; 737 case DDIV: 738 i = (Instruction)new Instruction_Ddiv(); 739 break; 740 case IREM: 741 i = (Instruction)new Instruction_Irem(); 742 break; 743 case LREM: 744 i = (Instruction)new Instruction_Lrem(); 745 break; 746 case FREM: 747 i = (Instruction)new Instruction_Frem(); 748 break; 749 case DREM: 750 i = (Instruction)new Instruction_Drem(); 751 break; 752 case INEG: 753 i = (Instruction)new Instruction_Ineg(); 754 break; 755 case LNEG: 756 i = (Instruction)new Instruction_Lneg(); 757 break; 758 case FNEG: 759 i = (Instruction)new Instruction_Fneg(); 760 break; 761 case DNEG: 762 i = (Instruction)new Instruction_Dneg(); 763 break; 764 case ISHL: 765 i = (Instruction)new Instruction_Ishl(); 766 break; 767 case ISHR: 768 i = (Instruction)new Instruction_Ishr(); 769 break; 770 case IUSHR: 771 i = (Instruction)new Instruction_Iushr(); 772 break; 773 case LSHL: 774 i = (Instruction)new Instruction_Lshl(); 775 break; 776 case LSHR: 777 i = (Instruction)new Instruction_Lshr(); 778 break; 779 case LUSHR: 780 i = (Instruction)new Instruction_Lushr(); 781 break; 782 case IAND: 783 i = (Instruction)new Instruction_Iand(); 784 break; 785 case LAND: 786 i = (Instruction)new Instruction_Land(); 787 break; 788 case IOR: 789 i = (Instruction)new Instruction_Ior(); 790 break; 791 case LOR: 792 i = (Instruction)new Instruction_Lor(); 793 break; 794 case IXOR: 795 i = (Instruction)new Instruction_Ixor(); 796 break; 797 case LXOR: 798 i = (Instruction)new Instruction_Lxor(); 799 break; 800 case I2L: 801 i = (Instruction)new Instruction_I2l(); 802 break; 803 case I2F: 804 i = (Instruction)new Instruction_I2f(); 805 break; 806 case I2D: 807 i = (Instruction)new Instruction_I2d(); 808 break; 809 case L2I: 810 i = (Instruction)new Instruction_L2i(); 811 break; 812 case L2F: 813 i = (Instruction)new Instruction_L2f(); 814 break; 815 case L2D: 816 i = (Instruction)new Instruction_L2d(); 817 break; 818 case F2I: 819 i = (Instruction)new Instruction_F2i(); 820 break; 821 case F2L: 822 i = (Instruction)new Instruction_F2l(); 823 break; 824 case F2D: 825 i = (Instruction)new Instruction_F2d(); 826 break; 827 case D2I: 828 i = (Instruction)new Instruction_D2i(); 829 break; 830 case D2L: 831 i = (Instruction)new Instruction_D2l(); 832 break; 833 case D2F: 834 i = (Instruction)new Instruction_D2f(); 835 break; 836 case INT2BYTE: 837 i = (Instruction)new Instruction_Int2byte(); 838 break; 839 case INT2CHAR: 840 i = (Instruction)new Instruction_Int2char(); 841 break; 842 case INT2SHORT: 843 i = (Instruction)new Instruction_Int2short(); 844 break; 845 case IFEQ: 846 i = (Instruction)new Instruction_Ifeq(); 847 break; 848 case IFNULL: 849 i = (Instruction)new Instruction_Ifnull(); 850 break; 851 case IFLT: 852 i = (Instruction)new Instruction_Iflt(); 853 break; 854 case IFLE: 855 i = (Instruction)new Instruction_Ifle(); 856 break; 857 case IFNE: 858 i = (Instruction)new Instruction_Ifne(); 859 break; 860 case IFNONNULL: 861 i = (Instruction)new Instruction_Ifnonnull(); 862 break; 863 case IFGT: 864 i = (Instruction)new Instruction_Ifgt(); 865 break; 866 case IFGE: 867 i = (Instruction)new Instruction_Ifge(); 868 break; 869 case IF_ICMPEQ: 870 i = (Instruction)new Instruction_If_icmpeq(); 871 break; 872 case IF_ICMPLT: 873 i = (Instruction)new Instruction_If_icmplt(); 874 break; 875 case IF_ICMPLE: 876 i = (Instruction)new Instruction_If_icmple(); 877 break; 878 case IF_ICMPNE: 879 i = (Instruction)new Instruction_If_icmpne(); 880 break; 881 case IF_ICMPGT: 882 i = (Instruction)new Instruction_If_icmpgt(); 883 break; 884 case IF_ICMPGE: 885 i = (Instruction)new Instruction_If_icmpge(); 886 break; 887 case LCMP: 888 i = (Instruction)new Instruction_Lcmp(); 889 break; 890 case FCMPL: 891 i = (Instruction)new Instruction_Fcmpl(); 892 break; 893 case FCMPG: 894 i = (Instruction)new Instruction_Fcmpg(); 895 break; 896 case DCMPL: 897 i = (Instruction)new Instruction_Dcmpl(); 898 break; 899 case DCMPG: 900 i = (Instruction)new Instruction_Dcmpg(); 901 break; 902 case IF_ACMPEQ: 903 i = (Instruction)new Instruction_If_acmpeq(); 904 break; 905 case IF_ACMPNE: 906 i = (Instruction)new Instruction_If_acmpne(); 907 break; 908 case GOTO: 909 i = (Instruction)new Instruction_Goto(); 910 break; 911 case GOTO_W: 912 i = (Instruction)new Instruction_Goto_w(); 913 break; 914 case JSR: 915 i = (Instruction)new Instruction_Jsr(); 916 break; 917 case JSR_W: 918 i = (Instruction)new Instruction_Jsr_w(); 919 break; 920 case RET: 921 i = (Instruction)new Instruction_Ret(); 922 break; 923 case RET_W: 924 i = (Instruction)new Instruction_Ret_w(); 925 break; 926 case RETURN: 927 i = (Instruction)new Instruction_Return(); 928 break; 929 case IRETURN: 930 i = (Instruction)new Instruction_Ireturn(); 931 break; 932 case LRETURN: 933 i = (Instruction)new Instruction_Lreturn(); 934 break; 935 case FRETURN: 936 i = (Instruction)new Instruction_Freturn(); 937 break; 938 case DRETURN: 939 i = (Instruction)new Instruction_Dreturn(); 940 break; 941 case ARETURN: 942 i = (Instruction)new Instruction_Areturn(); 943 break; 944 case BREAKPOINT: 945 i = (Instruction)new Instruction_Breakpoint(); 946 break; 947 case TABLESWITCH: 948 i = (Instruction)new Instruction_Tableswitch(); 949 break; 950 case LOOKUPSWITCH: 951 i = (Instruction)new Instruction_Lookupswitch(); 952 break; 953 case PUTFIELD: 954 i = (Instruction)new Instruction_Putfield(); 955 break; 956 case GETFIELD: 957 i = (Instruction)new Instruction_Getfield(); 958 break; 959 case PUTSTATIC: 960 i = (Instruction)new Instruction_Putstatic(); 961 break; 962 case GETSTATIC: 963 i = (Instruction)new Instruction_Getstatic(); 964 break; 965 case INVOKEVIRTUAL: 966 i = (Instruction)new Instruction_Invokevirtual(); 967 break; 968 case INVOKENONVIRTUAL: 969 i = (Instruction)new Instruction_Invokenonvirtual(); 970 break; 971 case INVOKESTATIC: 972 i = (Instruction)new Instruction_Invokestatic(); 973 break; 974 case INVOKEINTERFACE: 975 i = (Instruction)new Instruction_Invokeinterface(); 976 break; 977 case ATHROW: 978 i = (Instruction)new Instruction_Athrow(); 979 break; 980 case NEW: 981 i = (Instruction)new Instruction_New(); 982 break; 983 case CHECKCAST: 984 i = (Instruction)new Instruction_Checkcast(); 985 break; 986 case INSTANCEOF: 987 i = (Instruction)new Instruction_Instanceof(); 988 break; 989 case MONITORENTER: 990 i = (Instruction)new Instruction_Monitorenter(); 991 break; 992 case MONITOREXIT: 993 i = (Instruction)new Instruction_Monitorexit(); 994 break; 995 default: 996 i = (Instruction)new Instruction_Unknown(b); 1001 break; 1002 } 1003 1004 i.label = index; 1005 1006 if(isWide) 1007 i.parse(bc,index+2); 1008 else 1009 i.parse(bc,index+1); 1010 1011 return i; 1012 } 1013 1014 1021 public void build(Instruction insts) { 1022 Instruction i,j; 1023 attribute_info ai; 1024 Code_attribute ca; 1025 1026 i = insts; 1027 icount = 0; 1029 while (i != null) { 1030 icount++; 1031 i = i.next; 1032 } 1033 if (icount>0) { 1035 instructions = new Instruction[icount]; 1036 int k; 1041 k = 0; 1042 i = insts; 1043 while (i != null) { 1044 instructions[k] = i; 1045 k++; 1046 i = i.next; 1047 } 1048 1049 i = insts; 1051 while (i!=null) { 1052 i.offsetToPointer(this); 1053 i = i.next; 1054 } 1055 } 1056 } 1057 1058 1064 public static void showCode(Instruction inst,cp_info constant_pool[]) { 1065 showCode(inst,0,constant_pool); 1066 } 1067 1074 public static void showCode(Instruction inst,int startinst,cp_info constant_pool[]) { 1075 int i; 1076 Instruction j = inst; 1077 String pref; 1078 i = startinst; 1079 while (j!=null) { 1080 if (i>999) pref = ""; 1081 else if (i>99) pref = " "; 1082 else if (i>9) pref = " "; 1083 else pref = " "; 1084 G.v().out.print(pref + i + ": "); 1085 G.v().out.println(j.toString(constant_pool)); 1086 i = j.nextOffset(i); 1087 j = j.next; 1088 } 1089 } 1090 1091 1095 public Instruction locateInst(int index) { 1097 return locateInstr(index,0,icount); 1098 } 1099 1100 private Instruction locateInstr(int index,int mini,int maxi) { 1101 int mid = (maxi-mini)/2 + mini; 1102 1103 if (mini>maxi) return null; 1104 if (instructions[mid].label==index) 1105 return instructions[mid]; 1106 if (instructions[mid].label > index) 1107 return locateInstr(index,mini,mid-1); 1108 return locateInstr(index,mid+1,maxi); 1109 } 1110} 1111 | Popular Tags |