forked from meinicke/VarexJ
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathStackHandlerTracker.java
More file actions
168 lines (115 loc) · 3.96 KB
/
StackHandlerTracker.java
File metadata and controls
168 lines (115 loc) · 3.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
package gov.nasa.jpf.vm.va;
import java.util.*;
import de.fosd.typechef.featureexpr.FeatureExpr;
public class StackHandlerTracker {
Integer numCopy;
Integer size;
Integer max;
Integer min;
Integer ave;
Integer gmax;
StackHandlerTracker() {
this.numCopy = 0;
this.size = 0;
this.max = 0;
this.min = 0;
this.ave = 0;
this.gmax = 0;
}
public void set(Integer size, Integer min, Integer max, Integer ave) {
this.size = size;
this.max = max;
this.min = min;
this.ave = ave;
}
/***
* StackHandler
* push pop isref INC
* set dup swap
*/
public void push(StackHandler sh, final FeatureExpr ctx, final Object value, final boolean isRef){
calculate(sh);
Log.getInstance().info("PUSH\n"+ sh.toString() + "\n" + this.toString());
}
public void pop(StackHandler sh, FeatureExpr ctx, final int n){
calculate(sh);
Log.getInstance().info("POP\n"+ sh.toString() + "\n" + this.toString());
}
public void set(StackHandler sh, final FeatureExpr ctx, final int offset, final int value, final boolean isRef){}
public void dup(StackHandler sh, final FeatureExpr ctx) {
calculate(sh);
Log.getInstance().info("DUP\n"+ sh.toString() + "\n" + this.toString());
}
public void isRef(StackHandler sh, final FeatureExpr ctx, final int offset) {}
public void set(final FeatureExpr ctx, final int offset, final int value, final boolean isRef) {}
public void getTop(StackHandler sh) {}
public void setTop(StackHandler sh, final FeatureExpr ctx, final int i) {}
public void clear(StackHandler sh, final FeatureExpr ctx) {}
public void getSlots(StackHandler sh, FeatureExpr ctx) {}
/***
* Stack operations
*
*
*/
public void dup_x1(StackHandler sh, final FeatureExpr ctx) {}
public void dup2_x2(StackHandler sh, final FeatureExpr ctx) {}
public void dup2_x1(StackHandler sh, final FeatureExpr ctx) {}
public void dup2(StackHandler sh, final FeatureExpr ctx) {}
public void dup_x2(StackHandler sh, final FeatureExpr ctx){}
public void swap(StackHandler sh, final FeatureExpr ctx) {}
public void getLength(StackHandler sh) {}
public void getStack(StackHandler sh) {}
public void getAllReferences(StackHandler sh) {}
public void getLocalWidth(StackHandler sh) {}
public void getMaxLocal(StackHandler sh) {}
public void IINC(StackHandler sh, FeatureExpr ctx, int index, final int increment){}
/***
* Stack
* stackcopy entrycopy
*
*/
public void stackcopy(Stack s) {
this.numCopy += s.top+1;
}
public void clear(Stack s){}
public void setRef(Stack s, int index, boolean ref){}
public void hasAnyRef(Stack s){}
public void getSlots(Stack s){}
public void get(Stack s, int index){}
public void peek(Stack s, int offset){}
public void push(Stack s, Integer value, boolean isRef){}
public void isRef(Stack s, int offset){}
public void isRefIndex(Stack s, int index){}
public void set(Stack s, int offset, int value, boolean isRef){}
public void setIndex(Stack s, int index, Integer value, boolean isRef){}
public void dup2_x1(Stack s){}
public void dup2(Stack s){}
public void dup(Stack s){}
public void dup_x2(Stack s){}
public void swap(Stack s){}
public void getReferences(Stack s){}
public void entrycopy(Stack s){}
public void calculate(StackHandler sh){
List<Integer> temp = sh.getTop().toList();
Integer len = temp.size();
Integer sum = temp.get(0) + 1;
max = temp.get(0) + 1;
min = temp.get(0) + 1;
for(int i = 1; i < len; i++){
if(temp.get(i) + 1 > max)
this.max = temp.get(i) + 1;
if(temp.get(i) + 1 < min){
this.min = temp.get(i) + 1;
}
sum += temp.get(i) + 1;
}
if(this.max > this.gmax){
this.gmax = this.max;
}
this.ave = sum/len;
this.size = len;
}
public String toString(){
return "The size is " + this.size + "\nMinimun elements is "+ this.min + "\nMaximum elements is " +this.max + "\nAverage is " + this.ave + "\nNumbers of copys " + this.numCopy + "\ngmax is "+ this.gmax+ "\n";
}
}