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 java.util.*;
29:
30: /** A trap (exception catcher), used within Body
31: * classes. Intermediate representations must use an implementation
32: * of Trap to describe caught exceptions.
33: * */
34: public interface Trap extends UnitBoxOwner {
35: /** <p>Returns the first trapped unit, unless this <code>Trap</code>
36: * does not trap any units at all.</p>
37: *
38: * <p>If this is a degenerate <code>Trap</code> which
39: * traps no units (which can occur if all the units originally trapped by
40: * the exception handler have been optimized away), returns an
41: * untrapped unit. The returned unit will likely be the first unit
42: * remaining after the point where the trapped units were once
43: * located, but the only guarantee provided is that for such an
44: * empty trap, <code>getBeginUnit()</code> will return the same value
45: * as {@link #getEndUnit()}.</p>
46: */
47: public Unit getBeginUnit();
48:
49: /** <p>Returns the unit following the last trapped unit (that is, the
50: * first succeeding untrapped unit in the underlying
51: * <Code>Chain</code>), unless this <code>Trap</code> does not trap
52: * any units at all.</p>
53: *
54: * <p>In the case of a degenerate <code>Trap</code> which traps
55: * no units, returns the same untrapped unit as
56: * <code>getBeginUnit()</code></p>
57: *
58: * <p>Note that a weakness of marking the end of the trapped region
59: * with the first untrapped unit is that Soot has no good mechanism
60: * for describing a <code>Trap</code> which traps the last unit
61: * in a method.</p>
62: */
63: public Unit getEndUnit();
64:
65: /** Returns the unit handling the exception being trapped. */
66: public Unit getHandlerUnit();
67:
68: /** Returns the box holding the unit returned by {@link #getBeginUnit()}. */
69: public UnitBox getBeginUnitBox();
70:
71: /** Returns the box holding the unit returned by {@link #getEndUnit()}. */
72: public UnitBox getEndUnitBox();
73:
74: /** Returns the box holding the exception handler's unit. */
75: public UnitBox getHandlerUnitBox();
76:
77: /** Returns the boxes for first, last and handler units. */
78: public List<UnitBox> getUnitBoxes();
79:
80: /** Returns the exception being caught. */
81: public SootClass getException();
82:
83: /** Sets the value to be returned by {@link #getBeginUnit()} to
84: * <code>beginUnit</code>. */
85: public void setBeginUnit(Unit beginUnit);
86:
87: /** Sets the value to be returned by {@link #getEndUnit()} to
88: * <code>endUnit</code>. */
89: public void setEndUnit(Unit endUnit);
90:
91: /** Sets the unit handling the exception to <code>handlerUnit</code>. */
92: public void setHandlerUnit(Unit handlerUnit);
93:
94: /** Sets the exception being caught to <code>exception</code>. */
95: public void setException(SootClass exception);
96:
97: /** Performs a shallow clone of this trap. */
98: public Object clone();
99: }
|