KickJava   Java API By Example, From Geeks To Geeks.

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


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 import soot.*;
30 import java.util.*;
31
32 /**
33  * Kind of Stmt inside node, but global to the method.
34  * Used for synthetic summary of unalysed methods returning a fresh object.
35  */

36 public class PurityMethodNode implements PurityNode
37 {
38     /** Method that created the node */
39     private SootMethod id;
40
41     /** gives a unique id, for pretty-printing purposes */
42     private static Map nMap = new HashMap();
43     private static int n = 0;
44
45     PurityMethodNode(SootMethod id)
46     {
47     this.id = id;
48     if (!nMap.containsKey(id)) { nMap.put(id,new Integer JavaDoc(n)); n++; }
49     }
50
51     public String JavaDoc toString()
52     {
53     return "M_"+nMap.get(id);
54     //return ""+id;
55
}
56
57     public int hashCode()
58     { return id.hashCode(); }
59     
60     public boolean equals(Object JavaDoc o)
61     {
62     if (o instanceof PurityMethodNode) {
63         PurityMethodNode oo = (PurityMethodNode)o;
64         return id.equals(oo.id);
65     }
66     else return false;
67     }
68
69     public boolean isInside()
70     { return true; }
71
72     public boolean isLoad()
73     { return false; }
74
75     public boolean isParam()
76     { return false; }
77 }
78
Popular Tags