001: /* Soot - a J*va Optimization Framework
002: * Copyright (C) 2003 Jerome Miecznikowski
003: * Copyright (C) 2004-2005 Nomair A. Naeem
004: *
005: * This library is free software; you can redistribute it and/or
006: * modify it under the terms of the GNU Lesser General Public
007: * License as published by the Free Software Foundation; either
008: * version 2.1 of the License, or (at your option) any later version.
009: *
010: * This library is distributed in the hope that it will be useful,
011: * but WITHOUT ANY WARRANTY; without even the implied warranty of
012: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
013: * Lesser General Public License for more details.
014: *
015: * You should have received a copy of the GNU Lesser General Public
016: * License along with this library; if not, write to the
017: * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
018: * Boston, MA 02111-1307, USA.
019: */
020:
021: package soot.dava.internal.asg;
022:
023: import soot.*;
024:
025: import java.util.*;
026: import soot.util.*;
027: import soot.jimple.*;
028: import soot.dava.internal.SET.*;
029:
030: public class AugmentedStmt {
031: public List bpreds, bsuccs, cpreds, csuccs;
032: public SETNode myNode;
033:
034: private final IterableSet dominators;
035: private IterableSet reachers;
036: private Stmt s;
037:
038: public AugmentedStmt(Stmt s) {
039: this .s = s;
040:
041: dominators = new IterableSet();
042: reachers = new IterableSet();
043:
044: reset_PredsSuccs();
045: }
046:
047: public void set_Stmt(Stmt s) {
048: this .s = s;
049: }
050:
051: public boolean add_BPred(AugmentedStmt bpred) {
052: if (add_CPred(bpred) == false)
053: return false;
054:
055: if (bpreds.contains(bpred)) {
056: cpreds.remove(bpred);
057: return false;
058: }
059:
060: bpreds.add(bpred);
061: return true;
062: }
063:
064: public boolean add_BSucc(AugmentedStmt bsucc) {
065: if (add_CSucc(bsucc) == false)
066: return false;
067:
068: if (bsuccs.contains(bsucc)) {
069: csuccs.remove(bsucc);
070: return false;
071: }
072:
073: bsuccs.add(bsucc);
074: return true;
075: }
076:
077: public boolean add_CPred(AugmentedStmt cpred) {
078: if (cpreds.contains(cpred) == false) {
079: cpreds.add(cpred);
080: return true;
081: }
082:
083: return false;
084: }
085:
086: public boolean add_CSucc(AugmentedStmt csucc) {
087: if (csuccs.contains(csucc) == false) {
088: csuccs.add(csucc);
089: return true;
090: }
091:
092: return false;
093: }
094:
095: public boolean remove_BPred(AugmentedStmt bpred) {
096: if (remove_CPred(bpred) == false)
097: return false;
098:
099: if (bpreds.contains(bpred)) {
100: bpreds.remove(bpred);
101: return true;
102: }
103:
104: cpreds.add(bpred);
105: return false;
106: }
107:
108: public boolean remove_BSucc(AugmentedStmt bsucc) {
109: if (remove_CSucc(bsucc) == false)
110: return false;
111:
112: if (bsuccs.contains(bsucc)) {
113: bsuccs.remove(bsucc);
114: return true;
115: }
116:
117: csuccs.add(bsucc);
118: return false;
119: }
120:
121: public boolean remove_CPred(AugmentedStmt cpred) {
122: if (cpreds.contains(cpred)) {
123: cpreds.remove(cpred);
124: return true;
125: }
126:
127: return false;
128: }
129:
130: public boolean remove_CSucc(AugmentedStmt csucc) {
131: if (csuccs.contains(csucc)) {
132: csuccs.remove(csucc);
133: return true;
134: }
135:
136: return false;
137: }
138:
139: public Stmt get_Stmt() {
140: return s;
141: }
142:
143: public IterableSet get_Dominators() {
144: return dominators;
145: }
146:
147: public IterableSet get_Reachers() {
148: return reachers;
149: }
150:
151: public void set_Reachability(IterableSet reachers) {
152: this .reachers = reachers;
153: }
154:
155: public void dump() {
156: G.v().out.println(toString());
157: }
158:
159: public String toString() {
160: return "(" + s.toString() + " @ " + hashCode() + ")";
161: }
162:
163: public void reset_PredsSuccs() {
164: bpreds = new LinkedList();
165: bsuccs = new LinkedList();
166: cpreds = new LinkedList();
167: csuccs = new LinkedList();
168: }
169:
170: public Object clone() {
171: return new AugmentedStmt((Stmt) s.clone());
172: }
173: }
|