This commit was manufactured by cvs2svn to create tag 'buildscript'.
[IRC.git] /
1 package Analysis.TaskStateAnalysis;
2 import IR.*;
3 import Analysis.TaskStateAnalysis.*;
4 import IR.Tree.*;
5 import IR.Flat.*;
6 import java.util.*;
7 import Util.Edge;
8
9 /* Edge *****************/
10
11 public class FEdge extends Edge {
12
13     private String label;
14     private TaskDescriptor td;
15     private int parameterindex;
16     
17     // jzhou
18     private int executeTime;
19     private Hashtable<ClassDescriptor, NewObjInfo> newObjInfos;
20     private int probability;
21     private int invokeNum;
22     private int expInvokeNum;
23     
24     public class NewObjInfo {
25         int newRate;
26         int probability;
27         FlagState root;
28         int invokeNum;
29         
30         public NewObjInfo() {
31             newRate = 0;
32             probability = 0;
33             root = null;
34             invokeNum = 0;
35         }
36         
37         public NewObjInfo(int newRate, int probability) {
38             this.newRate = newRate;
39             this.probability = probability;
40         }
41         
42         public int getNewRate() {
43             return this.newRate;
44         }
45         
46         public void setNewRate(int newRate) {
47             this.newRate = newRate;
48         }
49         
50         public int getProbability() {
51             return this.probability;
52         }
53         
54         public void setProbability(int probability) {
55             this.probability = probability;
56         }
57         
58         public FlagState getRoot() {
59             return root;
60         }
61
62         public void setRoot(FlagState root) {
63             this.root = root;
64         }
65
66         public int getInvokeNum() {
67             return invokeNum;
68         }
69
70         public void incInvokeNum() {
71             this.invokeNum++;
72         }
73
74         public boolean equals(Object o) {
75             if (o instanceof NewObjInfo) {
76                 NewObjInfo e=(NewObjInfo)o;
77                 if (e.newRate == this.newRate &&
78                     e.probability == this.probability &&
79                     e.invokeNum == this.invokeNum &&
80                     e.root.equals(this.root)) {
81                     return true;
82                 }
83             }
84             return false;
85         }
86     }
87     
88     /** Class Constructor
89      * 
90      */
91     public FEdge(FlagState target, String label, TaskDescriptor td, int parameterindex) {
92         super(target);
93         this.label = label;
94         this.td=td;
95         this.parameterindex=parameterindex;
96         this.executeTime = -1;
97         this.newObjInfos = null;
98         this.probability = -1;
99         this.invokeNum = 0;
100         this.expInvokeNum = 0;
101     }
102
103     public int getProbability() {
104         return probability;
105     }
106
107     public void setProbability(int probability) {
108         this.probability = probability;
109     }
110
111     public String getLabel() {
112         return label;
113     }
114     
115     public int hashCode(){
116         int hashcode = label.hashCode()^target.hashCode()^source.hashCode()^parameterindex^executeTime;
117         if (td!=null)
118             hashcode^=td.hashCode();
119         if(newObjInfos != null) {
120             hashcode ^= newObjInfos.hashCode();
121         }
122         return hashcode;
123     }
124
125     public TaskDescriptor getTask() {
126         return td;
127     }
128
129     public int getIndex() {
130         return parameterindex;
131     }
132         
133     public boolean equals(Object o) {
134         if (o instanceof FEdge) {
135             FEdge e=(FEdge)o;
136             if (e.label.equals(label)&&
137                 e.target.equals(target)&&
138                 e.source.equals(source) &&
139                 e.td==td&&
140                 e.parameterindex==parameterindex &&
141                 e.executeTime == executeTime) {
142                 if(this.newObjInfos != null) {
143                     if(e.newObjInfos == null) {
144                         return false;
145                     } else {
146                         return e.newObjInfos.equals(this.newObjInfos);
147                     }
148                 }
149                 return true;
150             }
151         }
152         return false;
153     }
154     
155     public int getExeTime() {
156         return this.executeTime;
157     }
158     
159     public void setExeTime(int eTime) {
160         this.executeTime = eTime;
161     }
162     
163     public Hashtable<ClassDescriptor, NewObjInfo> getNewObjInfoHashtable() {
164         return this.newObjInfos;
165     }
166     
167     public NewObjInfo getNewObjInfo(ClassDescriptor cd) {
168         if(this.newObjInfos == null) {
169             return null;
170         }
171         return this.newObjInfos.get(cd);
172     }
173     
174     public void addNewObjInfo(ClassDescriptor cd, int newRate, int probability) {
175         if(this.newObjInfos == null) {
176             this.newObjInfos = new Hashtable<ClassDescriptor, NewObjInfo>();
177         }
178         this.newObjInfos.put(cd, new NewObjInfo(newRate, probability));
179     }
180     
181     public void process() {
182         this.invokeNum++;
183     }
184
185     public int getInvokeNum() {
186         return invokeNum;
187     }
188
189     public int getInvokeNumGap() {
190         return expInvokeNum - invokeNum;
191     }
192
193     public void setExpInvokeNum(int expInvokeNum) {
194         this.expInvokeNum = expInvokeNum;
195     }
196     
197 }