KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > soot > jimple > Jimple


1 /* Soot - a J*va Optimization Framework
2  * Copyright (C) 1997-1999 Raja Vallee-Rai
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the
16  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17  * Boston, MA 02111-1307, USA.
18  */

19
20 /*
21  * Modified by the Sable Research Group and others 1997-1999.
22  * See the 'credits' file distributed with Soot for the complete list of
23  * contributors. (Soot is distributed at http://www.sable.mcgill.ca/soot)
24  */

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 /**
39     The Jimple class contains all the constructors for the components of the Jimple
40     grammar for the Jimple body. <br><br>
41
42     Immediate -> Local | Constant <br>
43     RValue -> Local | Constant | ConcreteRef | Expr<br>
44     Variable -> Local | ArrayRef | InstanceFieldRef | StaticFieldRef <br>
45  */

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 JavaDoc NEWARRAY = "newarray";
54     public final static String JavaDoc NEWMULTIARRAY = "newmultiarray";
55     public final static String JavaDoc NOP = "nop";
56     public final static String JavaDoc RET = "ret";
57     public final static String JavaDoc SPECIALINVOKE = "specialinvoke";
58     public final static String JavaDoc STATICINVOKE = "staticinvoke";
59     public final static String JavaDoc TABLESWITCH = "tableswitch";
60     public final static String JavaDoc VIRTUALINVOKE = "virtualinvoke";
61     public final static String JavaDoc NULL_TYPE = "null_type";
62     public final static String JavaDoc UNKNOWN = "unknown";
63     public final static String JavaDoc CMP = "cmp";
64     public final static String JavaDoc CMPG = "cmpg";
65     public final static String JavaDoc CMPL = "cmpl";
66     public final static String JavaDoc ENTERMONITOR = "entermonitor";
67     public final static String JavaDoc EXITMONITOR = "exitmonitor";
68     public final static String JavaDoc INTERFACEINVOKE = "interfaceinvoke";
69     public final static String JavaDoc LENGTHOF = "lengthof";
70     public final static String JavaDoc LOOKUPSWITCH = "lookupswitch";
71     public final static String JavaDoc NEG = "neg";
72     public final static String JavaDoc IF = "if";
73     public final static String JavaDoc ABSTRACT = "abstract";
74     public final static String JavaDoc BOOLEAN = "boolean";
75     public final static String JavaDoc BREAK = "break";
76     public final static String JavaDoc BYTE = "byte";
77     public final static String JavaDoc CASE = "case";
78     public final static String JavaDoc CATCH = "catch";
79     public final static String JavaDoc CHAR = "char";
80     public final static String JavaDoc CLASS = "class";
81     public final static String JavaDoc FINAL = "final";
82     public final static String JavaDoc NATIVE = "native";
83     public final static String JavaDoc PUBLIC = "public";
84     public final static String JavaDoc PROTECTED = "protected";
85     public final static String JavaDoc PRIVATE = "private";
86     public final static String JavaDoc STATIC = "static";
87     public final static String JavaDoc SYNCHRONIZED = "synchronized";
88     public final static String JavaDoc TRANSIENT = "transient";
89     public final static String JavaDoc VOLATILE = "volatile";
90     public final static String JavaDoc STRICTFP = "strictfp";
91     public final static String JavaDoc ENUM = "enum";
92     public final static String JavaDoc ANNOTATION = "annotation";
93     public final static String JavaDoc INTERFACE = "interface";
94     public final static String JavaDoc VOID = "void";
95     public final static String JavaDoc SHORT = "short";
96     public final static String JavaDoc INT = "int";
97     public final static String JavaDoc LONG = "long";
98     public final static String JavaDoc FLOAT = "float";
99     public final static String JavaDoc DOUBLE = "double";
100     public final static String JavaDoc EXTENDS = "extends";
101     public final static String JavaDoc IMPLEMENTS = "implements";
102     public final static String JavaDoc BREAKPOINT = "breakpoint";
103     public final static String JavaDoc DEFAULT = "default";
104     public final static String JavaDoc GOTO = "goto";
105     public final static String JavaDoc INSTANCEOF = "instanceof";
106     public final static String JavaDoc NEW = "new";
107     public final static String JavaDoc RETURN = "return";
108     public final static String JavaDoc THROW = "throw";
109     public final static String JavaDoc THROWS = "throws";
110     public final static String JavaDoc NULL = "null";
111     public final static String JavaDoc FROM = "from";
112     public final static String JavaDoc TO = "to";
113     public final static String JavaDoc WITH = "with";
114     public final static String JavaDoc CLS = "cls";
115     public final static String JavaDoc TRUE = "true";
116     public final static String JavaDoc 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     /**
163         Constructs a XorExpr(Immediate, Immediate) grammar chunk.
164      */

165
166     public XorExpr newXorExpr(Value op1, Value op2)
167     {
168         return new JXorExpr(op1, op2);
169     }
170
171
172     /**
173         Constructs a UshrExpr(Immediate, Immediate) grammar chunk.
174      */

175
176     public UshrExpr newUshrExpr(Value op1, Value op2)
177     {
178         return new JUshrExpr(op1, op2);
179     }
180
181
182     /**
183         Constructs a SubExpr(Immediate, Immediate) grammar chunk.
184      */

185
186     public SubExpr newSubExpr(Value op1, Value op2)
187     {
188         return new JSubExpr(op1, op2);
189     }
190
191
192     /**
193         Constructs a ShrExpr(Immediate, Immediate) grammar chunk.
194      */

195
196     public ShrExpr newShrExpr(Value op1, Value op2)
197     {
198         return new JShrExpr(op1, op2);
199     }
200
201
202     /**
203         Constructs a ShlExpr(Immediate, Immediate) grammar chunk.
204      */

205
206     public ShlExpr newShlExpr(Value op1, Value op2)
207     {
208         return new JShlExpr(op1, op2);
209     }
210
211
212     /**
213         Constructs a RemExpr(Immediate, Immediate) grammar chunk.
214      */

215
216     public RemExpr newRemExpr(Value op1, Value op2)
217     {
218         return new JRemExpr(op1, op2);
219     }
220
221
222     /**
223         Constructs a OrExpr(Immediate, Immediate) grammar chunk.
224      */

225
226     public OrExpr newOrExpr(Value op1, Value op2)
227     {
228         return new JOrExpr(op1, op2);
229     }
230
231
232     /**
233         Constructs a NeExpr(Immediate, Immediate) grammar chunk.
234      */

235
236     public NeExpr newNeExpr(Value op1, Value op2)
237     {
238         return new JNeExpr(op1, op2);
239     }
240
241
242     /**
243         Constructs a MulExpr(Immediate, Immediate) grammar chunk.
244      */

245
246     public MulExpr newMulExpr(Value op1, Value op2)
247     {
248         return new JMulExpr(op1, op2);
249     }
250
251
252     /**
253         Constructs a LeExpr(Immediate, Immediate) grammar chunk.
254      */

255
256     public LeExpr newLeExpr(Value op1, Value op2)
257     {
258         return new JLeExpr(op1, op2);
259     }
260
261
262     /**
263         Constructs a GeExpr(Immediate, Immediate) grammar chunk.
264      */

265
266     public GeExpr newGeExpr(Value op1, Value op2)
267     {
268         return new JGeExpr(op1, op2);
269     }
270
271
272     /**
273         Constructs a EqExpr(Immediate, Immediate) grammar chunk.
274      */

275
276     public EqExpr newEqExpr(Value op1, Value op2)
277     {
278         return new JEqExpr(op1, op2);
279     }
280
281     /**
282         Constructs a DivExpr(Immediate, Immediate) grammar chunk.
283      */

284
285     public DivExpr newDivExpr(Value op1, Value op2)
286     {
287         return new JDivExpr(op1, op2);
288     }
289
290
291     /**
292         Constructs a CmplExpr(Immediate, Immediate) grammar chunk.
293      */

294
295     public CmplExpr newCmplExpr(Value op1, Value op2)
296     {
297         return new JCmplExpr(op1, op2);
298     }
299
300
301     /**
302         Constructs a CmpgExpr(Immediate, Immediate) grammar chunk.
303      */

304
305     public CmpgExpr newCmpgExpr(Value op1, Value op2)
306     {
307         return new JCmpgExpr(op1, op2);
308     }
309
310
311     /**
312         Constructs a CmpExpr(Immediate, Immediate) grammar chunk.
313      */

314
315     public CmpExpr newCmpExpr(Value op1, Value op2)
316     {
317         return new JCmpExpr(op1, op2);
318     }
319
320
321     /**
322         Constructs a GtExpr(Immediate, Immediate) grammar chunk.
323      */

324
325     public GtExpr newGtExpr(Value op1, Value op2)
326     {
327         return new JGtExpr(op1, op2);
328     }
329
330
331     /**
332         Constructs a LtExpr(Immediate, Immediate) grammar chunk.
333      */

334
335     public LtExpr newLtExpr(Value op1, Value op2)
336     {
337         return new JLtExpr(op1, op2);
338     }
339
340     /**
341         Constructs a AddExpr(Immediate, Immediate) grammar chunk.
342      */

343
344     public AddExpr newAddExpr(Value op1, Value op2)
345     {
346         return new JAddExpr(op1, op2);
347     }
348
349
350     /**
351         Constructs a AndExpr(Immediate, Immediate) grammar chunk.
352      */

353
354     public AndExpr newAndExpr(Value op1, Value op2)
355     {
356         return new JAndExpr(op1, op2);
357     }
358
359
360     /**
361         Constructs a NegExpr(Immediate, Immediate) grammar chunk.
362      */

363
364     public NegExpr newNegExpr(Value op)
365     {
366         return new JNegExpr(op);
367     }
368
369
370     /**
371         Constructs a LengthExpr(Immediate) grammar chunk.
372      */

373
374     public LengthExpr newLengthExpr(Value op)
375     {
376         return new JLengthExpr(op);
377     }
378
379
380     /**
381         Constructs a CastExpr(Immediate, Type) grammar chunk.
382      */

383
384     public CastExpr newCastExpr(Value op1, Type t)
385     {
386         return new JCastExpr(op1, t);
387     }
388
389     /**
390         Constructs a InstanceOfExpr(Immediate, Type)
391         grammar chunk.
392      */

393
394     public InstanceOfExpr newInstanceOfExpr(Value op1, Type t)
395     {
396         return new JInstanceOfExpr(op1, t);
397     }
398
399
400     /**
401         Constructs a NewExpr(RefType) grammar chunk.
402      */

403
404     public NewExpr newNewExpr(RefType type)
405     {
406         return new JNewExpr(type);
407     }
408
409
410     /**
411         Constructs a NewArrayExpr(Type, Immediate) grammar chunk.
412      */

413
414     public NewArrayExpr newNewArrayExpr(Type type, Value size)
415     {
416         return new JNewArrayExpr(type, size);
417     }
418
419     /**
420         Constructs a NewMultiArrayExpr(ArrayType, List of Immediate) grammar chunk.
421      */

422
423     public NewMultiArrayExpr newNewMultiArrayExpr(ArrayType type, List sizes)
424     {
425         return new JNewMultiArrayExpr(type, sizes);
426     }
427
428
429     /**
430         Constructs a NewStaticInvokeExpr(ArrayType, List of Immediate) grammar chunk.
431      */

432
433     public StaticInvokeExpr newStaticInvokeExpr(SootMethodRef method, List args)
434     {
435         return new JStaticInvokeExpr(method, args);
436     }
437
438
439     /**
440         Constructs a NewSpecialInvokeExpr(Local base, SootMethodRef method, List of Immediate) grammar chunk.
441      */

442
443     public SpecialInvokeExpr newSpecialInvokeExpr(Local base, SootMethodRef method, List args)
444     {
445         return new JSpecialInvokeExpr(base, method, args);
446     }
447
448
449     /**
450         Constructs a NewVirtualInvokeExpr(Local base, SootMethodRef method, List of Immediate) grammar chunk.
451      */

452
453     public VirtualInvokeExpr newVirtualInvokeExpr(Local base, SootMethodRef method, List args)
454     {
455         return new JVirtualInvokeExpr(base, method, args);
456     }
457
458
459     /**
460         Constructs a NewInterfaceInvokeExpr(Local base, SootMethodRef method, List of Immediate) grammar chunk.
461      */

462
463     public InterfaceInvokeExpr newInterfaceInvokeExpr(Local base, SootMethodRef method, List args)
464     {
465         return new JInterfaceInvokeExpr(base, method, args);
466     }
467
468
469         
470     /**
471         Constructs a NewStaticInvokeExpr(ArrayType, List of Immediate) grammar chunk. (no args)
472      */

473
474     public StaticInvokeExpr newStaticInvokeExpr(SootMethodRef method)
475     {
476         return new JStaticInvokeExpr(method, new ArrayList());
477     }
478
479
480     /**
481         Constructs a NewSpecialInvokeExpr(Local base, SootMethodRef method, List of Immediate) grammar chunk. (no args)
482      */

483
484     public SpecialInvokeExpr newSpecialInvokeExpr(Local base, SootMethodRef method)
485     {
486         return new JSpecialInvokeExpr(base, method, new ArrayList());
487     }
488
489
490     /**
491         Constructs a NewVirtualInvokeExpr(Local base, SootMethodRef method, List of Immediate) grammar chunk. (no args)
492      */

493
494     public VirtualInvokeExpr newVirtualInvokeExpr(Local base, SootMethodRef method)
495     {
496         return new JVirtualInvokeExpr(base, method, new ArrayList());
497     }
498
499
500     /**
501         Constructs a NewInterfaceInvokeExpr(Local base, SootMethodRef method, List of Immediate) grammar chunk. (no args)
502      */

503
504     public InterfaceInvokeExpr newInterfaceInvokeExpr(Local base, SootMethodRef method)
505     {
506         return new JInterfaceInvokeExpr(base, method, new ArrayList());
507     }
508
509     
510     /**
511         Constructs a NewStaticInvokeExpr(ArrayType, List of Immediate) grammar chunk.
512      */

513      
514     public StaticInvokeExpr newStaticInvokeExpr(SootMethodRef method, Value arg)
515     {
516         return new JStaticInvokeExpr(method, Arrays.asList(new Value[] {arg}));
517     }
518
519
520     /**
521         Constructs a NewSpecialInvokeExpr(Local base, SootMethodRef method, List of Immediate) grammar chunk.
522      */

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     /**
531         Constructs a NewVirtualInvokeExpr(Local base, SootMethodRef method, List of Immediate) grammar chunk.
532      */

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     /**
541         Constructs a NewInterfaceInvokeExpr(Local base, SootMethodRef method, List of Immediate) grammar chunk.
542      */

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     /**
551         Constructs a NewStaticInvokeExpr(ArrayType, List of Immediate) grammar chunk.
552      */

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     /**
561         Constructs a NewSpecialInvokeExpr(Local base, SootMethodRef method, List of Immediate) grammar chunk.
562      */

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     /**
571         Constructs a NewVirtualInvokeExpr(Local base, SootMethodRef method, List of Immediate) grammar chunk.
572      */

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     /**
581         Constructs a NewInterfaceInvokeExpr(Local base, SootMethodRef method, List of Immediate) grammar chunk.
582      */

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     /**
592         Constructs a ThrowStmt(Immediate) grammar chunk.
593      */

594
595     public ThrowStmt newThrowStmt(Value op)
596     {
597         return new JThrowStmt(op);
598     }
599
600
601     /**
602         Constructs a ExitMonitorStmt(Immediate) grammar chunk
603      */

604
605     public ExitMonitorStmt newExitMonitorStmt(Value op)
606     {
607         return new JExitMonitorStmt(op);
608     }
609
610
611     /**
612         Constructs a EnterMonitorStmt(Immediate) grammar chunk.
613      */

614
615     public EnterMonitorStmt newEnterMonitorStmt(Value op)
616     {
617         return new JEnterMonitorStmt(op);
618     }
619
620
621     /**
622         Constructs a BreakpointStmt() grammar chunk.
623      */

624
625     public BreakpointStmt newBreakpointStmt()
626     {
627         return new JBreakpointStmt();
628     }
629
630
631     /**
632         Constructs a GotoStmt(Stmt) grammar chunk.
633      */

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     /**
648         Constructs a NopStmt() grammar chunk.
649      */

650
651     public NopStmt newNopStmt()
652     {
653         return new JNopStmt();
654     }
655
656
657     /**
658         Constructs a ReturnVoidStmt() grammar chunk.
659      */

660
661     public ReturnVoidStmt newReturnVoidStmt()
662     {
663         return new JReturnVoidStmt();
664     }
665
666
667     /**
668         Constructs a ReturnStmt(Immediate) grammar chunk.
669      */

670
671     public ReturnStmt newReturnStmt(Value op)
672     {
673         return new JReturnStmt(op);
674     }
675
676
677     /**
678         Constructs a RetStmt(Local) grammar chunk.
679      */

680
681     public RetStmt newRetStmt(Value stmtAddress)
682     {
683         return new JRetStmt(stmtAddress);
684     }
685
686
687     /**
688         Constructs a IfStmt(Condition, Stmt) grammar chunk.
689      */

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     /**
703         Constructs a IdentityStmt(Local, IdentityRef) grammar chunk.
704      */

705
706     public IdentityStmt newIdentityStmt(Value local, Value identityRef)
707     {
708         return new JIdentityStmt(local, identityRef);
709     }
710
711
712     /**
713         Constructs a AssignStmt(Variable, RValue) grammar chunk.
714      */

715
716     public AssignStmt newAssignStmt(Value variable, Value rvalue)
717     {
718         return new JAssignStmt(variable, rvalue);
719     }
720
721
722     /**
723         Constructs a InvokeStmt(InvokeExpr) grammar chunk.
724      */

725
726     public InvokeStmt newInvokeStmt(Value op)
727     {
728         return new JInvokeStmt(op);
729     }
730
731
732     /**
733         Constructs a TableSwitchStmt(Immediate, int, int, List of Unit, Stmt) grammar chunk.
734      */

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     /**
748         Constructs a LookupSwitchStmt(Immediate, List of Immediate, List of Unit, Stmt) grammar chunk.
749      */

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     /**
763         Constructs a Local with the given name and type.
764     */

765
766     public Local newLocal(String JavaDoc name, Type t)
767     {
768         return new JimpleLocal(name.intern(), t);
769     }
770
771     /**
772         Constructs a new JTrap for the given exception on the given Stmt range with the given Stmt handler.
773     */

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     /**
787         Constructs a StaticFieldRef(SootFieldRef) grammar chunk.
788      */

789
790     public StaticFieldRef newStaticFieldRef(SootFieldRef f)
791     {
792         return new StaticFieldRef(f);
793     }
794
795
796     /**
797         Constructs a ThisRef(RefType) grammar chunk.
798      */

799
800     public ThisRef newThisRef(RefType t)
801     {
802         return new ThisRef(t);
803     }
804
805
806     /**
807         Constructs a ParameterRef(SootMethod, int) grammar chunk.
808      */

809
810     public ParameterRef newParameterRef(Type paramType, int number)
811     {
812         return new ParameterRef(paramType, number);
813     }
814
815     /**
816         Constructs a InstanceFieldRef(Local, SootFieldRef) grammar chunk.
817      */

818
819     public InstanceFieldRef newInstanceFieldRef(Value base, SootFieldRef f)
820     {
821         return new JInstanceFieldRef(base, f);
822     }
823
824
825     /**
826         Constructs a CaughtExceptionRef() grammar chunk.
827      */

828
829     public CaughtExceptionRef newCaughtExceptionRef()
830     {
831         return new JCaughtExceptionRef();
832     }
833
834
835     /**
836         Constructs a ArrayRef(Local, Immediate) grammar chunk.
837      */

838
839     public ArrayRef newArrayRef(Value base, Value index)
840     {
841         return new JArrayRef(base, index);
842     }
843
844     // Note: This is NOT used to create the variable box in JAssignStmt.
845
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     // Note: This is NOT used to create the rvalue box in JAssignStmt.
856
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     /** Returns an empty JimpleBody associated with method m. */
892     public JimpleBody newBody(SootMethod m)
893     {
894         return new JimpleBody(m);
895     }
896
897     /** Returns an empty JimpleBody with no associated method. */
898     public JimpleBody newBody()
899     {
900         return new JimpleBody();
901     }
902
903     /*
904      * Uncomment these stubs to make it compile with old code using Soot
905      * that does not know about SootField/MethodRefs.
906      */

907     /*
908     public StaticFieldRef newStaticFieldRef(SootField f) {
909         return newStaticFieldRef(f.makeRef());
910     }
911     public InstanceFieldRef newInstanceFieldRef(Value base, SootField f) {
912         return newInstanceFieldRef(base, f.makeRef());
913     }
914
915     public StaticInvokeExpr newStaticInvokeExpr(SootMethod method, List args) {
916         return newStaticInvokeExpr(method.makeRef(), args);
917     }
918     public SpecialInvokeExpr newSpecialInvokeExpr(Local base, SootMethod method, List args) {
919         return newSpecialInvokeExpr(base, method.makeRef(), args);
920     }
921     public VirtualInvokeExpr newVirtualInvokeExpr(Local base, SootMethod method, List args) {
922         return newVirtualInvokeExpr(base, method.makeRef(), args);
923     }
924
925     public InterfaceInvokeExpr newInterfaceInvokeExpr(Local base, SootMethod method, List args) {
926         return newInterfaceInvokeExpr(base, method.makeRef(), args);
927     }
928
929     public StaticInvokeExpr newStaticInvokeExpr(SootMethod method) {
930         return newStaticInvokeExpr(method.makeRef());
931     }
932     public SpecialInvokeExpr newSpecialInvokeExpr(Local base, SootMethod method) {
933         return newSpecialInvokeExpr(base, method.makeRef());
934     }
935     public VirtualInvokeExpr newVirtualInvokeExpr(Local base, SootMethod method) {
936         return newVirtualInvokeExpr(base, method.makeRef());
937     }
938     public InterfaceInvokeExpr newInterfaceInvokeExpr(Local base, SootMethod method) {
939         return newInterfaceInvokeExpr(base, method.makeRef());
940     }
941
942
943     public StaticInvokeExpr newStaticInvokeExpr(SootMethod method, Value arg) {
944         return newStaticInvokeExpr(method.makeRef(), arg);
945     }
946     public SpecialInvokeExpr newSpecialInvokeExpr(Local base, SootMethod method, Value arg) {
947         return newSpecialInvokeExpr(base, method.makeRef(), arg);
948     }
949     public VirtualInvokeExpr newVirtualInvokeExpr(Local base, SootMethod method, Value arg) {
950         return newVirtualInvokeExpr(base, method.makeRef(), arg);
951     }
952     public InterfaceInvokeExpr newInterfaceInvokeExpr(Local base, SootMethod method, Value arg) {
953         return newInterfaceInvokeExpr(base, method.makeRef(), arg);
954     }
955
956     public StaticInvokeExpr newStaticInvokeExpr(SootMethod method, Value arg1, Value arg2) {
957         return newStaticInvokeExpr(method.makeRef(), arg1, arg2);
958     }
959     public SpecialInvokeExpr newSpecialInvokeExpr(Local base, SootMethod method, Value arg1, Value arg2) {
960         return newSpecialInvokeExpr(base, method.makeRef(), arg1, arg2);
961     }
962     public VirtualInvokeExpr newVirtualInvokeExpr(Local base, SootMethod method, Value arg1, Value arg2) {
963         return newVirtualInvokeExpr(base, method.makeRef(), arg1, arg2);
964     }
965     public InterfaceInvokeExpr newInterfaceInvokeExpr(Local base, SootMethod method, Value arg1, Value arg2) {
966         return newInterfaceInvokeExpr(base, method.makeRef(), arg1, arg2);
967     }
968     */

969 }
970
Popular Tags