KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > soot > jimple > toolkits > annotation > purity > PurityEdge


1 /* Soot - a J*va Optimization Framework
2  * Copyright (C) 2005 Antoine Mine
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  * Implementation of the paper "A Combined Pointer and Purity Analysis for
22  * Java Programs" by Alexandru Salcianu and Martin Rinard, within the
23  * Soot Optimization Framework.
24  *
25  * by Antoine Mine, 2005/01/24
26  */

27
28 package soot.jimple.toolkits.annotation.purity;
29
30 /**
31  * An edge in a purity graph.
32  * Each edge has a soruce PurityNode, a taget PurityNode, and a field label
33  * (we use a String here).
34  * To represent an array element, the convention is to use the [] field label.
35  * Edges are mmuable and hashable. They compare equal only if they link
36  * equal nodes and have equal labels.
37  *
38  */

39 public class PurityEdge
40 {
41     private String JavaDoc field;
42     private PurityNode source, target;
43     private boolean inside;
44
45     PurityEdge(PurityNode source, String JavaDoc field, PurityNode target, boolean inside)
46     {
47     this.source = source;
48     this.field = field;
49     this.target = target;
50     this.inside = inside;
51     }
52
53     public String JavaDoc getField() { return field; }
54     public PurityNode getTarget() { return target; }
55     public PurityNode getSource() { return source; }
56     public boolean isInside() { return inside; }
57
58     public int hashCode()
59     { return field.hashCode()+target.hashCode()+source.hashCode()+(inside?69:0); }
60
61     public boolean equals(Object JavaDoc o)
62     {
63     if (!(o instanceof PurityEdge)) return false;
64     PurityEdge e = (PurityEdge)o;
65     return source.equals(e.source) && field.equals(e.field)
66         && target.equals(e.target) && inside==e.inside;
67     }
68
69     public String JavaDoc toString()
70     {
71     if (inside)
72         return source.toString()+" = "+field+" => "+target.toString();
73     else
74         return source.toString()+" - "+field+" -> "+target.toString();
75     
76     }
77 }
78
79
Popular Tags