1 19 20 25 26 27 28 29 30 package soot.jimple; 31 32 import soot.*; 33 import soot.jimple.internal.*; 34 import soot.util.*; 35 import java.util.*; 36 import java.io.*; 37 38 46 47 48 public class Jimple 49 { 50 public Jimple( Singletons.Global g ) {} 51 public static Jimple v() { return G.v().soot_jimple_Jimple(); } 52 53 public final static String NEWARRAY = "newarray"; 54 public final static String NEWMULTIARRAY = "newmultiarray"; 55 public final static String NOP = "nop"; 56 public final static String RET = "ret"; 57 public final static String SPECIALINVOKE = "specialinvoke"; 58 public final static String STATICINVOKE = "staticinvoke"; 59 public final static String TABLESWITCH = "tableswitch"; 60 public final static String VIRTUALINVOKE = "virtualinvoke"; 61 public final static String NULL_TYPE = "null_type"; 62 public final static String UNKNOWN = "unknown"; 63 public final static String CMP = "cmp"; 64 public final static String CMPG = "cmpg"; 65 public final static String CMPL = "cmpl"; 66 public final static String ENTERMONITOR = "entermonitor"; 67 public final static String EXITMONITOR = "exitmonitor"; 68 public final static String INTERFACEINVOKE = "interfaceinvoke"; 69 public final static String LENGTHOF = "lengthof"; 70 public final static String LOOKUPSWITCH = "lookupswitch"; 71 public final static String NEG = "neg"; 72 public final static String IF = "if"; 73 public final static String ABSTRACT = "abstract"; 74 public final static String BOOLEAN = "boolean"; 75 public final static String BREAK = "break"; 76 public final static String BYTE = "byte"; 77 public final static String CASE = "case"; 78 public final static String CATCH = "catch"; 79 public final static String CHAR = "char"; 80 public final static String CLASS = "class"; 81 public final static String FINAL = "final"; 82 public final static String NATIVE = "native"; 83 public final static String PUBLIC = "public"; 84 public final static String PROTECTED = "protected"; 85 public final static String PRIVATE = "private"; 86 public final static String STATIC = "static"; 87 public final static String SYNCHRONIZED = "synchronized"; 88 public final static String TRANSIENT = "transient"; 89 public final static String VOLATILE = "volatile"; 90 public final static String STRICTFP = "strictfp"; 91 public final static String ENUM = "enum"; 92 public final static String ANNOTATION = "annotation"; 93 public final static String INTERFACE = "interface"; 94 public final static String VOID = "void"; 95 public final static String SHORT = "short"; 96 public final static String INT = "int"; 97 public final static String LONG = "long"; 98 public final static String FLOAT = "float"; 99 public final static String DOUBLE = "double"; 100 public final static String EXTENDS = "extends"; 101 public final static String IMPLEMENTS = "implements"; 102 public final static String BREAKPOINT = "breakpoint"; 103 public final static String DEFAULT = "default"; 104 public final static String GOTO = "goto"; 105 public final static String INSTANCEOF = "instanceof"; 106 public final static String NEW = "new"; 107 public final static String RETURN = "return"; 108 public final static String THROW = "throw"; 109 public final static String THROWS = "throws"; 110 public final static String NULL = "null"; 111 public final static String FROM = "from"; 112 public final static String TO = "to"; 113 public final static String WITH = "with"; 114 public final static String CLS = "cls"; 115 public final static String TRUE = "true"; 116 public final static String FALSE = "false"; 117 118 public static List jimpleKeywordList() 119 { 120 List l = new LinkedList(); 121 l.add (NEWARRAY); l.add (NEWMULTIARRAY); l.add (NOP); 122 l.add (RET); l.add (SPECIALINVOKE); l.add (STATICINVOKE); 123 l.add (TABLESWITCH); l.add (VIRTUALINVOKE); l.add (NULL_TYPE); 124 l.add (UNKNOWN); l.add (CMP); l.add (CMPG); l.add (CMPL); 125 l.add (ENTERMONITOR); l.add (EXITMONITOR); l.add (INTERFACEINVOKE); 126 l.add (LENGTHOF); l.add (LOOKUPSWITCH); l.add (NEG); 127 l.add (IF); l.add (ABSTRACT); l.add (BOOLEAN); l.add (BREAK); 128 l.add (BYTE); l.add(CASE); l.add (CATCH); l.add (CHAR); 129 l.add (CLASS); l.add (FINAL); l.add (NATIVE); l.add (PUBLIC); 130 l.add (PROTECTED); l.add (PRIVATE); l.add (STATIC); 131 l.add (SYNCHRONIZED); l.add (TRANSIENT); l.add (VOLATILE); 132 l.add (STRICTFP); l.add (ENUM); l.add (ANNOTATION); 133 l.add (INTERFACE); l.add (VOID); l.add (SHORT); 134 l.add (INT); l.add (LONG); l.add (FLOAT); l.add (DOUBLE); 135 l.add (EXTENDS); l.add (IMPLEMENTS); l.add (BREAKPOINT); 136 l.add (DEFAULT); l.add (GOTO); l.add (INSTANCEOF); 137 l.add (NEW); l.add (RETURN); l.add (THROW); l.add (THROWS); 138 l.add (NULL); l.add (FROM); l.add (TO); l.add (WITH); 139 l.add (CLS); l.add (TRUE); l.add (FALSE); 140 return l; 141 } 142 143 public static boolean isJavaKeywordType(Type t) 144 { 145 return !(t instanceof StmtAddressType || 146 t instanceof UnknownType || 147 t instanceof RefType || 148 (t instanceof ArrayType && (!isJavaKeywordType(((ArrayType)t).baseType))) || 149 t instanceof ErroneousType ); 150 } 151 152 153 154 public static Value cloneIfNecessary(Value val) 155 { 156 if( val instanceof Local || val instanceof Constant ) 157 return val; 158 else 159 return (Value) val.clone(); 160 } 161 162 165 166 public XorExpr newXorExpr(Value op1, Value op2) 167 { 168 return new JXorExpr(op1, op2); 169 } 170 171 172 175 176 public UshrExpr newUshrExpr(Value op1, Value op2) 177 { 178 return new JUshrExpr(op1, op2); 179 } 180 181 182 185 186 public SubExpr newSubExpr(Value op1, Value op2) 187 { 188 return new JSubExpr(op1, op2); 189 } 190 191 192 195 196 public ShrExpr newShrExpr(Value op1, Value op2) 197 { 198 return new JShrExpr(op1, op2); 199 } 200 201 202 205 206 public ShlExpr newShlExpr(Value op1, Value op2) 207 { 208 return new JShlExpr(op1, op2); 209 } 210 211 212 215 216 public RemExpr newRemExpr(Value op1, Value op2) 217 { 218 return new JRemExpr(op1, op2); 219 } 220 221 222 225 226 public OrExpr newOrExpr(Value op1, Value op2) 227 { 228 return new JOrExpr(op1, op2); 229 } 230 231 232 235 236 public NeExpr newNeExpr(Value op1, Value op2) 237 { 238 return new JNeExpr(op1, op2); 239 } 240 241 242 245 246 public MulExpr newMulExpr(Value op1, Value op2) 247 { 248 return new JMulExpr(op1, op2); 249 } 250 251 252 255 256 public LeExpr newLeExpr(Value op1, Value op2) 257 { 258 return new JLeExpr(op1, op2); 259 } 260 261 262 265 266 public GeExpr newGeExpr(Value op1, Value op2) 267 { 268 return new JGeExpr(op1, op2); 269 } 270 271 272 275 276 public EqExpr newEqExpr(Value op1, Value op2) 277 { 278 return new JEqExpr(op1, op2); 279 } 280 281 284 285 public DivExpr newDivExpr(Value op1, Value op2) 286 { 287 return new JDivExpr(op1, op2); 288 } 289 290 291 294 295 public CmplExpr newCmplExpr(Value op1, Value op2) 296 { 297 return new JCmplExpr(op1, op2); 298 } 299 300 301 304 305 public CmpgExpr newCmpgExpr(Value op1, Value op2) 306 { 307 return new JCmpgExpr(op1, op2); 308 } 309 310 311 314 315 public CmpExpr newCmpExpr(Value op1, Value op2) 316 { 317 return new JCmpExpr(op1, op2); 318 } 319 320 321 324 325 public GtExpr newGtExpr(Value op1, Value op2) 326 { 327 return new JGtExpr(op1, op2); 328 } 329 330 331 334 335 public LtExpr newLtExpr(Value op1, Value op2) 336 { 337 return new JLtExpr(op1, op2); 338 } 339 340 343 344 public AddExpr newAddExpr(Value op1, Value op2) 345 { 346 return new JAddExpr(op1, op2); 347 } 348 349 350 353 354 public AndExpr newAndExpr(Value op1, Value op2) 355 { 356 return new JAndExpr(op1, op2); 357 } 358 359 360 363 364 public NegExpr newNegExpr(Value op) 365 { 366 return new JNegExpr(op); 367 } 368 369 370 373 374 public LengthExpr newLengthExpr(Value op) 375 { 376 return new JLengthExpr(op); 377 } 378 379 380 383 384 public CastExpr newCastExpr(Value op1, Type t) 385 { 386 return new JCastExpr(op1, t); 387 } 388 389 393 394 public InstanceOfExpr newInstanceOfExpr(Value op1, Type t) 395 { 396 return new JInstanceOfExpr(op1, t); 397 } 398 399 400 403 404 public NewExpr newNewExpr(RefType type) 405 { 406 return new JNewExpr(type); 407 } 408 409 410 413 414 public NewArrayExpr newNewArrayExpr(Type type, Value size) 415 { 416 return new JNewArrayExpr(type, size); 417 } 418 419 422 423 public NewMultiArrayExpr newNewMultiArrayExpr(ArrayType type, List sizes) 424 { 425 return new JNewMultiArrayExpr(type, sizes); 426 } 427 428 429 432 433 public StaticInvokeExpr newStaticInvokeExpr(SootMethodRef method, List args) 434 { 435 return new JStaticInvokeExpr(method, args); 436 } 437 438 439 442 443 public SpecialInvokeExpr newSpecialInvokeExpr(Local base, SootMethodRef method, List args) 444 { 445 return new JSpecialInvokeExpr(base, method, args); 446 } 447 448 449 452 453 public VirtualInvokeExpr newVirtualInvokeExpr(Local base, SootMethodRef method, List args) 454 { 455 return new JVirtualInvokeExpr(base, method, args); 456 } 457 458 459 462 463 public InterfaceInvokeExpr newInterfaceInvokeExpr(Local base, SootMethodRef method, List args) 464 { 465 return new JInterfaceInvokeExpr(base, method, args); 466 } 467 468 469 470 473 474 public StaticInvokeExpr newStaticInvokeExpr(SootMethodRef method) 475 { 476 return new JStaticInvokeExpr(method, new ArrayList()); 477 } 478 479 480 483 484 public SpecialInvokeExpr newSpecialInvokeExpr(Local base, SootMethodRef method) 485 { 486 return new JSpecialInvokeExpr(base, method, new ArrayList()); 487 } 488 489 490 493 494 public VirtualInvokeExpr newVirtualInvokeExpr(Local base, SootMethodRef method) 495 { 496 return new JVirtualInvokeExpr(base, method, new ArrayList()); 497 } 498 499 500 503 504 public InterfaceInvokeExpr newInterfaceInvokeExpr(Local base, SootMethodRef method) 505 { 506 return new JInterfaceInvokeExpr(base, method, new ArrayList()); 507 } 508 509 510 513 514 public StaticInvokeExpr newStaticInvokeExpr(SootMethodRef method, Value arg) 515 { 516 return new JStaticInvokeExpr(method, Arrays.asList(new Value[] {arg})); 517 } 518 519 520 523 524 public SpecialInvokeExpr newSpecialInvokeExpr(Local base, SootMethodRef method, Value arg) 525 { 526 return new JSpecialInvokeExpr(base, method, Arrays.asList(new Value[] {arg})); 527 } 528 529 530 533 534 public VirtualInvokeExpr newVirtualInvokeExpr(Local base, SootMethodRef method, Value arg) 535 { 536 return new JVirtualInvokeExpr(base, method, Arrays.asList(new Value[] {arg})); 537 } 538 539 540 543 544 public InterfaceInvokeExpr newInterfaceInvokeExpr(Local base, SootMethodRef method, Value arg) 545 { 546 return new JInterfaceInvokeExpr(base, method, Arrays.asList(new Value[] {arg})); 547 } 548 549 550 553 554 public StaticInvokeExpr newStaticInvokeExpr(SootMethodRef method, Value arg1, Value arg2) 555 { 556 return new JStaticInvokeExpr(method, Arrays.asList(new Value[] {arg1, arg2})); 557 } 558 559 560 563 564 public SpecialInvokeExpr newSpecialInvokeExpr(Local base, SootMethodRef method, Value arg1, Value arg2) 565 { 566 return new JSpecialInvokeExpr(base, method, Arrays.asList(new Value[] {arg1, arg2})); 567 } 568 569 570 573 574 public VirtualInvokeExpr newVirtualInvokeExpr(Local base, SootMethodRef method, Value arg1, Value arg2) 575 { 576 return new JVirtualInvokeExpr(base, method, Arrays.asList(new Value[] {arg1, arg2})); 577 } 578 579 580 583 584 public InterfaceInvokeExpr newInterfaceInvokeExpr(Local base, SootMethodRef method, Value arg1, Value arg2) 585 { 586 return new JInterfaceInvokeExpr(base, method, Arrays.asList(new Value[] {arg1, arg2})); 587 } 588 589 590 591 594 595 public ThrowStmt newThrowStmt(Value op) 596 { 597 return new JThrowStmt(op); 598 } 599 600 601 604 605 public ExitMonitorStmt newExitMonitorStmt(Value op) 606 { 607 return new JExitMonitorStmt(op); 608 } 609 610 611 614 615 public EnterMonitorStmt newEnterMonitorStmt(Value op) 616 { 617 return new JEnterMonitorStmt(op); 618 } 619 620 621 624 625 public BreakpointStmt newBreakpointStmt() 626 { 627 return new JBreakpointStmt(); 628 } 629 630 631 634 635 public GotoStmt newGotoStmt(Unit target) 636 { 637 return new JGotoStmt(target); 638 } 639 640 public GotoStmt newGotoStmt(UnitBox stmtBox) 641 { 642 return new JGotoStmt(stmtBox); 643 } 644 645 646 647 650 651 public NopStmt newNopStmt() 652 { 653 return new JNopStmt(); 654 } 655 656 657 660 661 public ReturnVoidStmt newReturnVoidStmt() 662 { 663 return new JReturnVoidStmt(); 664 } 665 666 667 670 671 public ReturnStmt newReturnStmt(Value op) 672 { 673 return new JReturnStmt(op); 674 } 675 676 677 680 681 public RetStmt newRetStmt(Value stmtAddress) 682 { 683 return new JRetStmt(stmtAddress); 684 } 685 686 687 690 691 public IfStmt newIfStmt(Value condition, Unit target) 692 { 693 return new JIfStmt(condition, target); 694 } 695 696 public IfStmt newIfStmt(Value condition, UnitBox target) 697 { 698 return new JIfStmt(condition, target); 699 } 700 701 702 705 706 public IdentityStmt newIdentityStmt(Value local, Value identityRef) 707 { 708 return new JIdentityStmt(local, identityRef); 709 } 710 711 712 715 716 public AssignStmt newAssignStmt(Value variable, Value rvalue) 717 { 718 return new JAssignStmt(variable, rvalue); 719 } 720 721 722 725 726 public InvokeStmt newInvokeStmt(Value op) 727 { 728 return new JInvokeStmt(op); 729 } 730 731 732 735 736 public TableSwitchStmt newTableSwitchStmt(Value key, int lowIndex, int highIndex, List targets, Unit defaultTarget) 737 { 738 return new JTableSwitchStmt(key, lowIndex, highIndex, targets, defaultTarget); 739 } 740 741 742 public TableSwitchStmt newTableSwitchStmt(Value key, int lowIndex, int highIndex, List targets, UnitBox defaultTarget) 743 { 744 return new JTableSwitchStmt(key, lowIndex, highIndex, targets, defaultTarget); 745 } 746 747 750 751 public LookupSwitchStmt newLookupSwitchStmt(Value key, List lookupValues, List targets, Unit defaultTarget) 752 { 753 return new JLookupSwitchStmt(key, lookupValues, targets, defaultTarget); 754 } 755 756 public LookupSwitchStmt newLookupSwitchStmt(Value key, List lookupValues, List targets, UnitBox defaultTarget) 757 { 758 return new JLookupSwitchStmt(key, lookupValues, targets, defaultTarget); 759 } 760 761 762 765 766 public Local newLocal(String name, Type t) 767 { 768 return new JimpleLocal(name.intern(), t); 769 } 770 771 774 775 public Trap newTrap(SootClass exception, Unit beginStmt, Unit endStmt, Unit handlerStmt) 776 { 777 return new JTrap(exception, beginStmt, endStmt, handlerStmt); 778 } 779 780 public Trap newTrap(SootClass exception, UnitBox beginStmt, UnitBox endStmt, UnitBox handlerStmt) 781 { 782 return new JTrap(exception, beginStmt, endStmt, handlerStmt); 783 } 784 785 786 789 790 public StaticFieldRef newStaticFieldRef(SootFieldRef f) 791 { 792 return new StaticFieldRef(f); 793 } 794 795 796 799 800 public ThisRef newThisRef(RefType t) 801 { 802 return new ThisRef(t); 803 } 804 805 806 809 810 public ParameterRef newParameterRef(Type paramType, int number) 811 { 812 return new ParameterRef(paramType, number); 813 } 814 815 818 819 public InstanceFieldRef newInstanceFieldRef(Value base, SootFieldRef f) 820 { 821 return new JInstanceFieldRef(base, f); 822 } 823 824 825 828 829 public CaughtExceptionRef newCaughtExceptionRef() 830 { 831 return new JCaughtExceptionRef(); 832 } 833 834 835 838 839 public ArrayRef newArrayRef(Value base, Value index) 840 { 841 return new JArrayRef(base, index); 842 } 843 844 public ValueBox newVariableBox(Value value) 846 { 847 return new VariableBox(value); 848 } 849 850 public ValueBox newLocalBox(Value value) 851 { 852 return new JimpleLocalBox(value); 853 } 854 855 public ValueBox newRValueBox(Value value) 857 { 858 return new RValueBox(value); 859 } 860 861 public ValueBox newImmediateBox(Value value) 862 { 863 return new ImmediateBox(value); 864 } 865 866 public ValueBox newArgBox(Value value) 867 { 868 return new ImmediateBox(value); 869 } 870 871 public ValueBox newIdentityRefBox(Value value) 872 { 873 return new IdentityRefBox(value); 874 } 875 876 public ValueBox newConditionExprBox(Value value) 877 { 878 return new ConditionExprBox(value); 879 } 880 881 public ValueBox newInvokeExprBox(Value value) 882 { 883 return new InvokeExprBox(value); 884 } 885 886 public UnitBox newStmtBox(Unit unit) 887 { 888 return new StmtBox((Stmt) unit); 889 } 890 891 892 public JimpleBody newBody(SootMethod m) 893 { 894 return new JimpleBody(m); 895 } 896 897 898 public JimpleBody newBody() 899 { 900 return new JimpleBody(); 901 } 902 903 907 969 } 970 | Popular Tags |