1 package Analysis.Pointer;
4 import Analysis.Pointer.AllocFactory.AllocNode;
5 import Analysis.Disjoint.Canonical;
6 import Analysis.Disjoint.Taint;
7 import Analysis.Disjoint.TaintSet;
8 import Analysis.Pointer.MySet;
14 TempDescriptor srcvar;
19 public static final int SNGSNG=1;
20 public static final int SNGSUM=2;
21 public static final int SUMSNG=4;
22 public static final int SUMSUM=8;
23 public static final int NEW=16;
25 public String toString() {
27 return "<"+srcvar+", "+dst+">";
29 return "<"+src+", "+statuspredicate+", "+fd+", "+dst+">";
31 return "<"+src+", "+statuspredicate+", [], "+dst+">";
34 public static int mergeStatus(int stat1, int stat2) {
35 int status=stat1|stat2;
36 return ((status&NEW)==NEW)?NEW:status;
39 public boolean isNew() {
40 return (statuspredicate&NEW)==NEW;
46 public Edge(AllocNode src, FieldDescriptor fd, AllocNode dst) {
52 public Edge(AllocNode src, FieldDescriptor fd, AllocNode dst, int statuspredicate) {
56 this.statuspredicate=statuspredicate;
59 public Edge(TempDescriptor tmp, AllocNode dst) {
64 public AllocNode getDst() {
68 public int hashCode() {
69 int hashcode=dst.hashCode();
71 hashcode^=fd.hashCode();
74 hashcode^=(src.hashCode()<<3);
76 hashcode^=(srcvar.hashCode()<<3);
81 public Edge addTaint(Taint t) {
83 if (newe.taints==null)
84 newe.taints=TaintSet.factory(t);
86 newe.taints=newe.taints.add(t);
90 public void taintModify(Set<FlatSESEEnterNode> seseSet) {
92 taints=Canonical.removeSESETaints(taints, seseSet);
95 public TaintSet getTaints() {
99 public Edge changeTaintSet(TaintSet ts) {
105 public boolean equals(Object o) {
106 if (o instanceof Edge) {
109 return (srcvar==e.srcvar)&&(dst==e.dst);
111 return (src==e.src)&&(dst==e.dst)&&(fd==e.fd);
117 public Edge changeSrcVar(TempDescriptor tmp, TaintSet taintset) {
122 e.statuspredicate=NEW;
125 else if (taintset==null)
128 e.taints=taints.merge(taintset);
132 public Edge changeSrc(FieldDescriptor newfd, AllocNode srcnode) {
137 e.statuspredicate=NEW;
149 e.statuspredicate=statuspredicate;
155 public Edge merge(Edge e) {
159 newe.statuspredicate=mergeStatus(statuspredicate, e.statuspredicate);
160 if (e.taints!=null) {
161 if (newe.taints==null)
162 newe.taints=e.taints;
164 newe.taints=newe.taints.merge(taints);
169 public Edge rewrite(AllocNode single, AllocNode summary) {
178 public Edge rewrite(TempDescriptor orig, TempDescriptor newtmp) {
181 throw new Error("Mismatched temps");
186 public Edge makeStatus(AllocFactory factory) {
189 e.src=factory.getAllocNode(src, (statuspredicate|3)==0);
190 e.dst=factory.getAllocNode(dst, (statuspredicate|5)==0);
194 public boolean subsumes(Edge e) {
195 return subsumes(this.statuspredicate, e.statuspredicate)&&subsumes(this.taints, e.taints);
198 public static boolean subsumes(TaintSet ts1, TaintSet ts2) {
208 //Do a set comparison
210 return ts1.getTaints().containsAll(ts2.getTaints());
213 public static boolean subsumes(int status1, int status2) {
214 return ((status1&NEW)==NEW)||((status1|status2)==status1);
217 public Edge makeOld() {
228 e.statuspredicate=val;
232 public static void mergeEdgesInto(MySet<Edge> orig, MySet<Edge> merge) {
234 if (orig.contains(e)) {
235 Edge old=orig.get(e);
242 public static void mergeEdgeInto(MySet<Edge> orig, Edge e) {
243 if (orig.contains(e)) {
244 Edge old=orig.get(e);