KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > soot > javaToJimple > AbstractJimpleBodyBuilder


1 /* Soot - a J*va Optimization Framework
2  * Copyright (C) 2004 Jennifer Lhotak
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
22 package soot.javaToJimple;
23
24 import java.util.*;
25
26 import soot.SootFieldRef;
27
28 public abstract class AbstractJimpleBodyBuilder {
29    
30     protected soot.jimple.JimpleBody body;
31
32     public void ext(AbstractJimpleBodyBuilder ext){
33         this.ext = ext;
34         if (ext.ext != null){
35             throw new RuntimeException JavaDoc("Extensions created in wrong order.");
36         }
37         ext.base = this.base;
38     }
39     public AbstractJimpleBodyBuilder ext(){
40         if (ext == null) return this;
41         return ext;
42     }
43     private AbstractJimpleBodyBuilder ext = null;
44     
45     public void base(AbstractJimpleBodyBuilder base){
46         this.base = base;
47     }
48     public AbstractJimpleBodyBuilder base(){
49         return base;
50     }
51     private AbstractJimpleBodyBuilder base = this;
52     
53     protected soot.jimple.JimpleBody createJimpleBody(polyglot.ast.Block block, List formals, soot.SootMethod sootMethod){
54         return ext().createJimpleBody(block, formals, sootMethod);
55     }
56     
57     protected soot.Value createExpr(polyglot.ast.Expr expr){
58         return ext().createExpr(expr);
59     }
60     
61     protected void createStmt(polyglot.ast.Stmt stmt){
62         ext().createStmt(stmt);
63     }
64
65     protected boolean needsAccessor(polyglot.ast.Expr expr){
66         return ext().needsAccessor(expr);
67     }
68     
69     protected soot.Local handlePrivateFieldAssignSet(polyglot.ast.Assign assign){
70         return ext().handlePrivateFieldAssignSet(assign);
71     }
72     
73     protected soot.Local handlePrivateFieldUnarySet(polyglot.ast.Unary unary){
74         return ext().handlePrivateFieldUnarySet(unary);
75     }
76     
77
78     protected soot.Value getAssignRightLocal(polyglot.ast.Assign assign, soot.Local leftLocal){
79         return ext().getAssignRightLocal(assign, leftLocal);
80     }
81    
82     protected soot.Value getSimpleAssignRightLocal(polyglot.ast.Assign assign){
83         return ext().getSimpleAssignRightLocal(assign);
84     }
85    
86     protected soot.Local handlePrivateFieldSet(polyglot.ast.Expr expr, soot.Value right, soot.Value base){
87         return ext().handlePrivateFieldSet(expr, right, base);
88     }
89
90     protected soot.SootMethodRef getSootMethodRef(polyglot.ast.Call call){
91         return ext().getSootMethodRef(call);
92     }
93
94     protected soot.Local generateLocal(soot.Type sootType){
95         return ext().generateLocal(sootType);
96     }
97
98     protected soot.Local generateLocal(polyglot.types.Type polyglotType){
99         return ext().generateLocal(polyglotType);
100     }
101
102     protected soot.Local getThis(soot.Type sootType){
103         return ext().getThis(sootType);
104     }
105
106     protected soot.Value getBaseLocal(polyglot.ast.Receiver receiver){
107         return ext().getBaseLocal(receiver);
108     }
109
110     protected soot.Value createLHS(polyglot.ast.Expr expr){
111         return ext().createLHS(expr);
112     }
113
114     protected soot.jimple.FieldRef getFieldRef(polyglot.ast.Field field){
115         return ext().getFieldRef(field);
116     }
117
118     protected soot.jimple.Constant getConstant(soot.Type sootType, int val){
119         return ext().getConstant(sootType, val);
120     }
121 }
122
Popular Tags