01: /* Soot - a J*va Optimization Framework
02: * Copyright (C) 1997-1999 Raja Vallee-Rai
03: *
04: * This library is free software; you can redistribute it and/or
05: * modify it under the terms of the GNU Lesser General Public
06: * License as published by the Free Software Foundation; either
07: * version 2.1 of the License, or (at your option) any later version.
08: *
09: * 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: package soot;
27:
28: import soot.tagkit.*;
29: import soot.util.*;
30: import java.util.*;
31: import java.io.*;
32:
33: /** A code fragment (eg Stmt or Inst), used within Body
34: * classes. Intermediate representations must use an implementation
35: * of Unit for their code. In general, a unit denotes
36: * some sort of unit for execution.
37: */
38: public interface Unit extends Switchable, Host, Serializable, Context {
39: /** Returns a list of Boxes containing Values used in this Unit. */
40: public List<ValueBox> getUseBoxes();
41:
42: /** Returns a list of Boxes containing Values defined in this Unit. */
43: public List<ValueBox> getDefBoxes();
44:
45: /** Returns a list of Boxes containing Units defined in this Unit; typically
46: * branch targets. */
47: public List<UnitBox> getUnitBoxes();
48:
49: /** Returns a list of Boxes pointing to this Unit. */
50: public List<UnitBox> getBoxesPointingToThis();
51:
52: /** Adds a box to the list returned by getBoxesPointingToThis. */
53: public void addBoxPointingToThis(UnitBox b);
54:
55: /** Removes a box from the list returned by getBoxesPointingToThis. */
56: public void removeBoxPointingToThis(UnitBox b);
57:
58: /** Clears any pointers to and from this Unit's UnitBoxes. */
59: public void clearUnitBoxes();
60:
61: /** Returns a list of Boxes containing any Value either used or defined
62: * in this Unit. */
63: public List getUseAndDefBoxes();
64:
65: public Object clone();
66:
67: /** Returns true if execution after this statement may continue at the following statement.
68: * GotoStmt will return false but IfStmt will return true. */
69: public boolean fallsThrough();
70:
71: /** Returns true if execution after this statement does not necessarily continue at the following statement. GotoStmt and IfStmt will both return true. */
72: public boolean branches();
73:
74: public void toString(UnitPrinter up);
75:
76: /**
77: * Redirects jumps to this Unit to newLocation. In general, you shouldn't
78: * have to use this directly.
79: *
80: * @see PatchingChain#getNonPatchingChain()
81: * @see soot.shimple.Shimple#redirectToPreds(Chain, Unit)
82: * @see soot.shimple.Shimple#redirectPointers(Unit, Unit)
83: **/
84: public void redirectJumpsToThisTo(Unit newLocation);
85: }
|