KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > soot > shimple > internal > SPiExpr


1 /* Soot - a J*va Optimization Framework
2  * Copyright (C) 2004 Navindra Umanee <navindra@cs.mcgill.ca>
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 package soot.shimple.internal;
21
22 import soot.*;
23 import soot.util.*;
24 import soot.shimple.*;
25 import soot.toolkits.scalar.*;
26 import java.util.*;
27
28 /**
29  * @author Navindra Umanee
30  **/

31 public class SPiExpr implements PiExpr
32 {
33     protected ValueUnitPair argBox;
34     protected Object JavaDoc targetKey;
35
36     public SPiExpr(Value v, Unit u, Object JavaDoc o)
37     {
38         argBox = new SValueUnitPair(v, u);
39         this.targetKey = o;
40     }
41     
42     public ValueUnitPair getArgBox()
43     {
44         return argBox;
45     }
46         
47     public Value getValue()
48     {
49         return argBox.getValue();
50     }
51     
52     public Unit getCondStmt()
53     {
54         return argBox.getUnit();
55     }
56
57     public Object JavaDoc getTargetKey()
58     {
59         return targetKey;
60     }
61     
62     public void setValue(Value value)
63     {
64         argBox.setValue(value);
65     }
66     
67     public void setCondStmt(Unit pred)
68     {
69         argBox.setUnit(pred);
70     }
71
72     public void setTargetKey(Object JavaDoc targetKey)
73     {
74         this.targetKey = targetKey;
75     }
76     
77     public List getUnitBoxes()
78     {
79         return Collections.singletonList(argBox);
80     }
81
82     public void clearUnitBoxes()
83     {
84         System.out.println("clear unit boxes");
85         argBox.setUnit(null);
86     }
87     
88     public boolean equivTo(Object JavaDoc o)
89     {
90         if(!(o instanceof SPiExpr))
91             return false;
92
93         return getArgBox().equivTo(((SPiExpr)o).getArgBox());
94     }
95
96     public int equivHashCode()
97     {
98         return getArgBox().equivHashCode() * 17;
99     }
100     
101     public void apply(Switch sw)
102     {
103         // *** FIXME:
104
throw new RuntimeException JavaDoc("Not Yet Implemented.");
105     }
106
107     public Object JavaDoc clone()
108     {
109         return new SPiExpr(getValue(), getCondStmt(), getTargetKey());
110     }
111
112     public String JavaDoc toString()
113     {
114         String JavaDoc s = Shimple.PI + "(" + getValue() + ")";
115         return s;
116     }
117     
118     public void toString(UnitPrinter up)
119     {
120         up.literal(Shimple.PI);
121         up.literal("(");
122         argBox.toString(up);
123         up.literal(" [");
124         up.literal(targetKey.toString());
125         up.literal("])");
126     }
127
128     public Type getType()
129     {
130         return getValue().getType();
131     }
132     
133     public List getUseBoxes()
134     {
135         return Collections.singletonList(argBox);
136     }
137 }
138
139
Popular Tags