KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > soot > dava > internal > asg > AugmentedStmt


1 /* Soot - a J*va Optimization Framework
2  * Copyright (C) 2003 Jerome Miecznikowski
3  * Copyright (C) 2004-2005 Nomair A. Naeem
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the
17  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18  * Boston, MA 02111-1307, USA.
19  */

20
21 package soot.dava.internal.asg;
22 import soot.*;
23
24 import java.util.*;
25 import soot.util.*;
26 import soot.jimple.*;
27 import soot.dava.internal.SET.*;
28
29
30 public class AugmentedStmt
31 {
32     public List bpreds, bsuccs, cpreds, csuccs;
33     public SETNode myNode;
34
35     private IterableSet dominators, reachers;
36     private Stmt s;
37
38
39     public AugmentedStmt( Stmt s)
40     {
41     this.s = s;
42
43     dominators = new IterableSet();
44     reachers = new IterableSet();
45
46     reset_PredsSuccs();
47     }
48     
49     public void set_Stmt( Stmt s)
50     {
51     this.s = s;
52     }
53
54     public boolean add_BPred( AugmentedStmt bpred)
55     {
56     if (add_CPred( bpred) == false)
57         return false;
58
59     if (bpreds.contains( bpred)) {
60         cpreds.remove( bpred);
61         return false;
62     }
63
64     bpreds.add( bpred);
65     return true;
66     }
67
68     public boolean add_BSucc( AugmentedStmt bsucc)
69     {
70     if (add_CSucc( bsucc) == false)
71         return false;
72
73     if (bsuccs.contains( bsucc)) {
74         csuccs.remove( bsucc);
75         return false;
76     }
77     
78     bsuccs.add( bsucc);
79     return true;
80     }
81
82     public boolean add_CPred( AugmentedStmt cpred)
83     {
84     if (cpreds.contains( cpred) == false) {
85         cpreds.add( cpred);
86         return true;
87     }
88
89     return false;
90     }
91
92     public boolean add_CSucc( AugmentedStmt csucc)
93     {
94     if (csuccs.contains( csucc) == false) {
95         csuccs.add( csucc);
96         return true;
97     }
98
99     return false;
100     }
101
102     public boolean remove_BPred( AugmentedStmt bpred)
103     {
104     if (remove_CPred( bpred) == false)
105         return false;
106
107     if (bpreds.contains( bpred)) {
108         bpreds.remove( bpred);
109         return true;
110     }
111     
112     cpreds.add( bpred);
113     return false;
114     }
115     
116     public boolean remove_BSucc( AugmentedStmt bsucc)
117     {
118     if (remove_CSucc( bsucc) == false)
119         return false;
120
121     if (bsuccs.contains( bsucc)) {
122         bsuccs.remove( bsucc);
123         return true;
124     }
125     
126     csuccs.add( bsucc);
127     return false;
128     }
129
130     public boolean remove_CPred( AugmentedStmt cpred)
131     {
132     if (cpreds.contains( cpred)) {
133         cpreds.remove( cpred);
134         return true;
135     }
136
137     return false;
138     }
139
140     public boolean remove_CSucc( AugmentedStmt csucc)
141     {
142     if (csuccs.contains( csucc)) {
143         csuccs.remove( csucc);
144         return true;
145     }
146
147     return false;
148     }
149
150     public Stmt get_Stmt()
151     {
152     return s;
153     }
154
155     public IterableSet get_Dominators()
156     {
157     return dominators;
158     }
159
160     public IterableSet get_Reachers()
161     {
162     return reachers;
163     }
164
165     public void set_Reachability( IterableSet reachers)
166     {
167     this.reachers = reachers;
168     }
169
170     public void dump()
171     {
172     G.v().out.println( toString());
173     }
174
175     public String JavaDoc toString()
176     {
177     return "(" + s.toString() + " @ " + hashCode() + ")";
178     }
179
180     public void reset_PredsSuccs()
181     {
182     bpreds = new LinkedList();
183     bsuccs = new LinkedList();
184     cpreds = new LinkedList();
185     csuccs = new LinkedList();
186     }
187
188     public Object JavaDoc clone()
189     {
190     return new AugmentedStmt( (Stmt) s.clone());
191     }
192 }
193
Popular Tags