KickJava   Java API By Example, From Geeks To Geeks.

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


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.jimple.*;
34 import soot.baf.*;
35 import soot.util.*;
36 import java.util.*;
37
38 public class BIncInst extends AbstractInst implements IncInst
39 {
40     ValueBox localBox;
41     ValueBox defLocalBox;
42     List useBoxes;
43   Constant mConstant;
44   List mDefBoxes;
45
46     private class LinkedBafLocalBox extends BafLocalBox
47     {
48         ValueBox otherBox = null;
49
50         private LinkedBafLocalBox(Value v)
51         {
52             super(v);
53         }
54
55         public void setOtherBox(ValueBox otherBox)
56         {
57             this.otherBox = otherBox;
58         }
59
60         public Value getValue()
61         {
62             Value toReturn = super.getValue();
63             
64             return toReturn;
65         }
66         
67         public void setValue(Value v)
68         {
69             super.setValue(v);
70             
71             if(otherBox != null)
72             {
73                 if(otherBox.getValue() != v)
74                     otherBox.setValue(v);
75             }
76         }
77     }
78        
79     public BIncInst(Local local, Constant constant)
80     {
81       mConstant = constant;
82       
83       localBox = new BafLocalBox(local);
84       
85       useBoxes = new ArrayList();
86       useBoxes.add(localBox);
87       useBoxes = Collections.unmodifiableList(useBoxes);
88
89       defLocalBox = new BafLocalBox(local);
90       
91       //((LinkedBafLocalBox) defLocalBox).setOtherBox(localBox);
92
//((LinkedBafLocalBox) localBox).setOtherBox(defLocalBox);
93

94       mDefBoxes = new ArrayList();
95       mDefBoxes.add(defLocalBox);
96       mDefBoxes = Collections.unmodifiableList(mDefBoxes);
97       
98     }
99
100     public int getInCount()
101     {
102         return 0;
103     }
104
105     public Object JavaDoc clone()
106     {
107       return new BIncInst( getLocal(), getConstant());
108     }
109
110   public int getInMachineCount()
111   {
112     return 0;
113   }
114     
115   public int getOutCount()
116   {
117     return 0;
118   }
119
120     public int getOutMachineCount()
121     {
122         return 0;
123     }
124     
125    
126
127   
128   public Constant getConstant()
129   {
130     return mConstant;
131   }
132   
133   public void setConstant(Constant aConstant)
134   {
135     mConstant = aConstant;
136   }
137
138
139
140   final public String JavaDoc getName() { return "inc.i"; }
141     final String JavaDoc getParameters()
142     { return " "+ localBox.getValue().toString(); }
143     protected void getParameters(UnitPrinter up ) {
144         up.literal(" ");
145         localBox.toString(up);
146     }
147     
148     public void apply(Switch sw)
149     {
150         ((InstSwitch) sw).caseIncInst(this);
151     }
152  
153     public void setLocal(Local l)
154     {
155         localBox.setValue(l);
156     }
157     
158     public Local getLocal()
159     {
160         return (Local) localBox.getValue();
161     }
162
163     public List getUseBoxes()
164     {
165         return useBoxes;
166     }
167     
168     public List getDefBoxes()
169     {
170         return mDefBoxes;
171     }
172
173   
174   public String JavaDoc toString()
175   {
176     return "inc.i" + " " +getLocal() + " " + getConstant() ;
177   }
178
179   public void toString( UnitPrinter up ) {
180       up.literal( "inc.i" );
181       up.literal( " " );
182       localBox.toString( up );
183       up.literal( " " );
184       up.constant( mConstant );
185   }
186
187     
188 }
189
Popular Tags