KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > soot > baf > internal > AbstractBranchInst


1 /* Soot - a J*va Optimization Framework
2  * Copyright (C) 1999 Patrick Lam, Patrick Pominville and 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.baf.internal;
31
32 import soot.*;
33 import soot.baf.*;
34 import soot.util.*;
35 import java.util.*;
36
37 public abstract class AbstractBranchInst extends AbstractInst
38 {
39     UnitBox targetBox;
40
41     List targetBoxes;
42
43     AbstractBranchInst(UnitBox targetBox)
44     {
45         this.targetBox = targetBox;
46
47         targetBoxes = new SingletonList(this.targetBox);
48     }
49
50     abstract public String JavaDoc getName();
51
52     public String JavaDoc toString()
53     {
54         return getName() + " " + getTarget();
55     }
56
57     public void toString( UnitPrinter up ) {
58         up.literal( getName() );
59         up.literal(" ");
60         targetBox.toString( up );
61     }
62     
63     public Unit getTarget()
64     {
65         return targetBox.getUnit();
66     }
67
68     public void setTarget(Unit target)
69     {
70         targetBox.setUnit(target);
71     }
72
73     public UnitBox getTargetBox()
74     {
75         return targetBox;
76     }
77
78     public List getUnitBoxes()
79     {
80         return targetBoxes;
81     }
82
83     abstract public void apply(Switch sw);
84
85     
86     public boolean branches()
87     {
88         return true;
89     }
90     
91
92 }
93
94
Popular Tags