00001 package ca.mcgill.sable.soot.jimple; 00002 00003 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 00004 * Jimple, a 3-address code Java(TM) bytecode representation. * 00005 * Copyright (C) 1997, 1998 Raja Vallee-Rai (kor@sable.mcgill.ca) * 00006 * All rights reserved. * 00007 * * 00008 * Modifications by Patrick Lam (plam@sable.mcgill.ca) are * 00009 * Copyright (C) 1999 Patrick Lam. All rights reserved. * 00010 * * 00011 * Modifications by Etienne Gagnon (gagnon@sable.mcgill.ca) are * 00012 * Copyright (C) 1998 Etienne Gagnon (gagnon@sable.mcgill.ca). All * 00013 * rights reserved. * 00014 * * 00015 * This work was done as a project of the Sable Research Group, * 00016 * School of Computer Science, McGill University, Canada * 00017 * (http://www.sable.mcgill.ca/). It is understood that any * 00018 * modification not identified as such is not covered by the * 00019 * preceding statement. * 00020 * * 00021 * This work is free software; you can redistribute it and/or * 00022 * modify it under the terms of the GNU Library General Public * 00023 * License as published by the Free Software Foundation; either * 00024 * version 2 of the License, or (at your option) any later version. * 00025 * * 00026 * This work is distributed in the hope that it will be useful, * 00027 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00028 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * 00029 * Library General Public License for more details. * 00030 * * 00031 * You should have received a copy of the GNU Library General Public * 00032 * License along with this library; if not, write to the * 00033 * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * 00034 * Boston, MA 02111-1307, USA. * 00035 * * 00036 * Java is a trademark of Sun Microsystems, Inc. * 00037 * * 00038 * To submit a bug report, send a comment, or get the latest news on * 00039 * this project and other Sable Research Group projects, please * 00040 * visit the web site: http://www.sable.mcgill.ca/ * 00041 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ 00042 00043 /* 00044 Reference Version 00045 ----------------- 00046 This is the latest official version on which this file is based. 00047 The reference version is: $SootVersion: 1.beta.4 $ 00048 00049 Change History 00050 -------------- 00051 A) Notes: 00052 00053 Please use the following template. Most recent changes should 00054 appear at the top of the list. 00055 00056 - Modified on [date (March 1, 1900)] by [name]. [(*) if appropriate] 00057 [description of modification]. 00058 00059 Any Modification flagged with "(*)" was done as a project of the 00060 Sable Research Group, School of Computer Science, 00061 McGill University, Canada (http://www.sable.mcgill.ca/). 00062 00063 You should add your copyright, using the following template, at 00064 the top of this file, along with other copyrights. 00065 00066 * * 00067 * Modifications by [name] are * 00068 * Copyright (C) [year(s)] [your name (or company)]. All rights * 00069 * reserved. * 00070 * * 00071 00072 B) Changes: 00073 00074 - Modified on March 1, 1999 by Raja Vallee-Rai (rvalleerai@sable.mcgill.ca) (*) 00075 Temporarily took out the NextNextRef until the jsrs are fixed. 00076 00077 - Modified on February 3, 1999 by Patrick Lam (plam@sable.mcgill.ca) (*) 00078 Added changes in support of the Grimp intermediate 00079 representation (with aggregated-expressions). 00080 00081 - Modified on November 2, 1998 by Raja Vallee-Rai (kor@sable.mcgill.ca) (*) 00082 Repackaged all source files and performed extensive modifications. 00083 First initial release of Soot. 00084 00085 - Modified on September 12, 1998 by Raja Vallee-Rai (kor@sable.mcgill.ca (*) 00086 Changed PrintStream to PrintWriter. 00087 00088 - Modified on 31-Aug-1998 by Raja Vallee-Rai (kor@sable.mcgill.ca). (*) 00089 Minor print changes. 00090 00091 - Modified on 23-Jul-1998 by Raja Vallee-Rai (kor@sable.mcgill.ca). (*) 00092 Changed Hashtable to HashMap. 00093 00094 - Modified on July 5, 1998 by Etienne Gagnon (gagnon@sable.mcgill.ca). (*) 00095 Changed caseDefault to defaultCase, to avoid name conflicts (and conform 00096 to the standard). 00097 00098 - Modified on 15-Jun-1998 by Raja Vallee-Rai (kor@sable.mcgill.ca). (*) 00099 First internal release (Version 0.1). 00100 */ 00101 00102 import ca.mcgill.sable.soot.*; 00103 import ca.mcgill.sable.util.*; 00104 import java.io.*; 00105 00106 /** 00107 The JimpleRepresentation interface defines all the constructors for the components of the Jimple 00108 grammar for the Jimple body. <br><br> 00109 00110 Immediate -> Local | Constant <br> 00111 RValue -> Local | Constant | ConcreteRef | Expr<br> 00112 Variable -> Local | ArrayRef | InstanceFieldRef | StaticFieldRef <br> 00113 */ 00114 00115 00116 public interface JimpleRepresentation extends BodyRepresentation 00117 { 00118 public Body buildBodyOfFrom(SootMethod m, Body b, int buildBodyOptions); 00119 /** 00120 Constructs a AddExpr(Arg, Arg) grammar chunk. 00121 */ 00122 00123 public AddExpr newAddExpr(Value op1, Value op2); 00124 /** 00125 Constructs a AndExpr(Arg, Arg) grammar chunk. 00126 */ 00127 00128 public AndExpr newAndExpr(Value op1, Value op2); 00129 /** 00130 Constructs an empty ArgBox for a grammar chunk. 00131 */ 00132 public ValueBox newArgBox(Value op); 00133 /** 00134 Constructs a ArrayRef(Local, Immediate) grammar chunk. 00135 */ 00136 00137 public ArrayRef newArrayRef(Value base, Value index); 00138 /** 00139 Constructs a AssignStmt(Variable, RValue) grammar chunk. 00140 */ 00141 00142 public AssignStmt newAssignStmt(Value variable, Value rvalue); 00143 /** 00144 Constructs an empty JimpleBody for the given method. 00145 */ 00146 00147 public Body newBody(SootMethod m); 00148 /** 00149 Constructs a BreakpointStmt() grammar chunk. 00150 */ 00151 00152 public BreakpointStmt newBreakpointStmt(); 00153 /** 00154 Constructs a CastExpr(Immediate, Type) grammar chunk. 00155 */ 00156 00157 public CastExpr newCastExpr(Value op1, Type t); 00158 /** 00159 Constructs a CaughtExceptionRef() grammar chunk. 00160 */ 00161 00162 public CaughtExceptionRef newCaughtExceptionRef(JimpleBody b); 00163 /** 00164 Constructs a CmpExpr(Arg, Arg) grammar chunk. 00165 */ 00166 00167 public CmpExpr newCmpExpr(Value op1, Value op2); 00168 /** 00169 Constructs a CmpgExpr(Arg, Arg) grammar chunk. 00170 */ 00171 00172 public CmpgExpr newCmpgExpr(Value op1, Value op2); 00173 /** 00174 Constructs a CmplExpr(Arg, Arg) grammar chunk. 00175 */ 00176 00177 public CmplExpr newCmplExpr(Value op1, Value op2); 00178 public ValueBox newConditionExprBox(Value value); 00179 /** 00180 Constructs a DivExpr(Arg, Arg) grammar chunk. 00181 */ 00182 00183 public DivExpr newDivExpr(Value op1, Value op2); 00184 /** 00185 Constructs a EnterMonitorStmt(Immediate) grammar chunk. 00186 */ 00187 00188 public EnterMonitorStmt newEnterMonitorStmt(Value op); 00189 /** 00190 Constructs a EqExpr(Arg, Arg) grammar chunk. 00191 */ 00192 00193 public EqExpr newEqExpr(Value op1, Value op2); 00194 /** 00195 Constructs a ExitMonitorStmt(Immediate) grammar chunk 00196 */ 00197 00198 public ExitMonitorStmt newExitMonitorStmt(Value op); 00199 /** 00200 Constructs a GeExpr(Arg, Arg) grammar chunk. 00201 */ 00202 00203 public GeExpr newGeExpr(Value op1, Value op2); 00204 /** 00205 Constructs a GotoStmt(Stmt) grammar chunk. 00206 */ 00207 00208 public GotoStmt newGotoStmt(Unit target); 00209 /** 00210 Constructs a GtExpr(Arg, Arg) grammar chunk. 00211 */ 00212 00213 public GtExpr newGtExpr(Value op1, Value op2); 00214 public ValueBox newIdentityRefBox(Value value); 00215 /** 00216 Constructs a IdentityStmt(Local, IdentityRef) grammar chunk. 00217 */ 00218 00219 public IdentityStmt newIdentityStmt(Value local, Value identityRef); 00220 /** 00221 Constructs a IfStmt(Condition, Stmt) grammar chunk. 00222 */ 00223 00224 public IfStmt newIfStmt(Value condition, Unit target); 00225 public ValueBox newImmediateBox(Value value); 00226 /** 00227 Constructs a NextNextStmtRef() grammar chunk. 00228 */ 00229 00230 //public NextNextStmtRef newNextNextStmtRef(); 00231 00232 /** 00233 Constructs a InstanceFieldRef(Value, SootField) grammar chunk. 00234 */ 00235 00236 public InstanceFieldRef newInstanceFieldRef(Value base, SootField f); 00237 /** 00238 Constructs a InstanceOfExpr(Immediate, Type) 00239 grammar chunk. 00240 */ 00241 00242 public InstanceOfExpr newInstanceOfExpr(Value op1, Type t); 00243 /** 00244 Constructs a NewInterfaceInvokeExpr(Local base, SootMethod method, List of Immediate) grammar chunk. 00245 */ 00246 00247 public InterfaceInvokeExpr newInterfaceInvokeExpr(Local base, SootMethod method, List args); 00248 public ValueBox newInvokeExprBox(Value value); 00249 /** 00250 Constructs a InvokeStmt(InvokeExpr) grammar chunk. 00251 */ 00252 00253 public InvokeStmt newInvokeStmt(Value op); 00254 /** 00255 Constructs a LeExpr(Arg, Arg) grammar chunk. 00256 */ 00257 00258 public LeExpr newLeExpr(Value op1, Value op2); 00259 /** 00260 Constructs a LengthExpr(Immediate) grammar chunk. 00261 */ 00262 00263 public LengthExpr newLengthExpr(Value op); 00264 /** 00265 Constructs a Local with the given name and type. 00266 */ 00267 00268 public Local newLocal(String name, Type t); 00269 public ValueBox newLocalBox(Value value); 00270 /** 00271 Constructs a LookupSwitchStmt(Immediate, List of Immediate, List of Unit, Stmt) grammar chunk. 00272 */ 00273 00274 public LookupSwitchStmt newLookupSwitchStmt(Value key, List lookupValues, List targets, Unit defaultTarget); 00275 /** 00276 Constructs a LtExpr(Arg, Arg) grammar chunk. 00277 */ 00278 00279 public LtExpr newLtExpr(Value op1, Value op2); 00280 /** 00281 Constructs a MulExpr(Arg, Arg) grammar chunk. 00282 */ 00283 00284 public MulExpr newMulExpr(Value op1, Value op2); 00285 /** 00286 Constructs a NeExpr(Arg, Arg) grammar chunk. 00287 */ 00288 00289 public NeExpr newNeExpr(Value op1, Value op2); 00290 /** 00291 Constructs a NegExpr(Arg, Arg) grammar chunk. 00292 */ 00293 00294 public NegExpr newNegExpr(Value op); 00295 /** 00296 Constructs a NewArrayExpr(Type, Immediate) grammar chunk. 00297 */ 00298 00299 public NewArrayExpr newNewArrayExpr(Type type, Value size); 00300 /** 00301 Constructs a NewMultiArrayExpr(ArrayType, List of Immediate) grammar chunk. 00302 */ 00303 00304 public NewMultiArrayExpr newNewMultiArrayExpr(ArrayType type, List sizes); 00305 /** 00306 Constructs a NopStmt() grammar chunk. 00307 */ 00308 00309 public NopStmt newNopStmt(); 00310 /** 00311 Constructs a OrExpr(Arg, Arg) grammar chunk. 00312 */ 00313 00314 public OrExpr newOrExpr(Value op1, Value op2); 00315 /** 00316 Constructs a ParameterRef(SootMethod, int) grammar chunk. 00317 */ 00318 00319 public ParameterRef newParameterRef(SootMethod m, int number); 00320 /** 00321 Constructs a RemExpr(Arg, Arg) grammar chunk. 00322 */ 00323 00324 public RemExpr newRemExpr(Value op1, Value op2); 00325 /** 00326 Constructs a RetStmt(Local) grammar chunk. 00327 */ 00328 00329 public RetStmt newRetStmt(Value stmtAddress); 00330 /** 00331 Constructs a ReturnStmt(Immediate) grammar chunk. 00332 */ 00333 00334 public ReturnStmt newReturnStmt(Value op); 00335 /** 00336 Constructs a ReturnVoidStmt() grammar chunk. 00337 */ 00338 00339 public ReturnVoidStmt newReturnVoidStmt(); 00340 public ValueBox newRValueBox(Value value); 00341 /** 00342 Constructs a ShlExpr(Arg, Arg) grammar chunk. 00343 */ 00344 00345 public ShlExpr newShlExpr(Value op1, Value op2); 00346 /** 00347 Constructs a ShrExpr(Arg, Arg) grammar chunk. 00348 */ 00349 00350 public ShrExpr newShrExpr(Value op1, Value op2); 00351 /** 00352 Constructs a NewSpecialInvokeExpr(Local base, SootMethod method, List of Immediate) grammar chunk. 00353 */ 00354 00355 public SpecialInvokeExpr newSpecialInvokeExpr 00356 (Local base, SootMethod method, List args); 00357 /** 00358 Constructs a StaticFieldRef(SootField) grammar chunk. 00359 */ 00360 00361 public StaticFieldRef newStaticFieldRef(SootField f); 00362 /** 00363 Constructs a NewStaticInvokeExpr(ArrayType, List of Immediate) grammar chunk. 00364 */ 00365 00366 public StaticInvokeExpr newStaticInvokeExpr(SootMethod method, List args); 00367 public UnitBox newStmtBox(Unit unit); 00368 /** 00369 Constructs a SubExpr(Arg, Arg) grammar chunk. 00370 */ 00371 00372 public SubExpr newSubExpr(Value op1, Value op2); 00373 /** 00374 Constructs a TableSwitchStmt(Immediate, int, int, List of Unit, Stmt) grammar chunk. 00375 */ 00376 00377 public TableSwitchStmt newTableSwitchStmt(Value key, int lowIndex, int highIndex, List targets, Unit defaultTarget); 00378 /** 00379 Constructs a ThisRef(SootClass) grammar chunk. 00380 */ 00381 00382 public ThisRef newThisRef(SootClass c); 00383 /** 00384 Constructs a ThrowStmt(Immediate) grammar chunk. 00385 */ 00386 00387 public ThrowStmt newThrowStmt(Value op); 00388 /** 00389 Constructs a new Trap for the given exception on the given Stmt range with the given Stmt handler. 00390 */ 00391 00392 public Trap newTrap(SootClass exception, Unit beginStmt, Unit endStmt, Unit handlerStmt); 00393 /** 00394 Constructs a UshrExpr(Arg, Arg) grammar chunk. 00395 */ 00396 00397 public UshrExpr newUshrExpr(Value op1, Value op2); 00398 public ValueBox newVariableBox(Value value); 00399 /** 00400 Constructs a NewVirtualInvokeExpr(Local base, SootMethod method, List of Immediate) grammar chunk. 00401 */ 00402 00403 public VirtualInvokeExpr newVirtualInvokeExpr(Local base, SootMethod method, List args); 00404 /** 00405 Constructs a XorExpr(Arg, Arg) grammar chunk. 00406 */ 00407 00408 public XorExpr newXorExpr(Value op1, Value op2); 00409 }