KickJava   Java API By Example, From Geeks To Geeks.

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


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 class BIdentityInst extends AbstractInst
38     implements IdentityInst
39 {
40     ValueBox leftBox;
41     ValueBox rightBox;
42
43     List defBoxes;
44     
45    
46     
47
48     public Value getLeftOp()
49     {
50         return leftBox.getValue();
51     }
52   
53   public int getInCount()
54   {
55         return 0;
56     }
57
58   public int getInMachineCount()
59   {
60         return 0;
61     }
62     
63     public int getOutCount()
64     {
65         return 0;
66     }
67
68     public int getOutMachineCount()
69     {
70         return 0;
71     }
72
73     public Value getRightOp()
74     {
75         return rightBox.getValue();
76     }
77
78     public ValueBox getLeftOpBox()
79     {
80         return leftBox;
81     }
82
83     public ValueBox getRightOpBox()
84     {
85         return rightBox;
86     }
87
88     public List getDefBoxes()
89     {
90         return defBoxes;
91     }
92
93     public List getUseBoxes()
94     {
95         List list = new ArrayList();
96
97         list.addAll(rightBox.getValue().getUseBoxes());
98         list.add(rightBox);
99         list.addAll(leftBox.getValue().getUseBoxes());
100
101         return list;
102     }
103
104     public BIdentityInst(Value local, Value identityValue)
105     {
106         this(Baf.v().newLocalBox(local),
107              Baf.v().newIdentityRefBox(identityValue));
108     }
109
110     protected BIdentityInst(ValueBox localBox, ValueBox identityValueBox)
111     {
112         this.leftBox = localBox; this.rightBox = identityValueBox;
113
114         defBoxes = new ArrayList();
115         defBoxes.add(leftBox);
116         defBoxes = Collections.unmodifiableList(defBoxes);
117     }
118
119
120     public Object JavaDoc clone()
121     {
122             return new BIdentityInst(getLeftOp(), getRightOp());
123     }
124
125     public String JavaDoc toString()
126     {
127         return leftBox.getValue().toString() + " := " + rightBox.getValue().toString();
128     }
129
130     public void toString( UnitPrinter up ) {
131         leftBox.toString(up);
132         up.literal(" := ");
133         rightBox.toString(up);
134     }
135
136     final public String JavaDoc getName() { return ":="; }
137
138     public void setLeftOp(Value local)
139     {
140         leftBox.setValue(local);
141     }
142
143     public void setRightOp(Value identityRef)
144     {
145         rightBox.setValue(identityRef);
146     }
147
148     public void apply(Switch sw)
149     {
150         ((InstSwitch) sw).caseIdentityInst(this);
151     }
152 }
153
154
155
156
Popular Tags