-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTempCounter.java
More file actions
65 lines (48 loc) · 1.36 KB
/
TempCounter.java
File metadata and controls
65 lines (48 loc) · 1.36 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
import SymbolTypes.Methods;
import SymbolTypes.SymbolTable;
import java.util.HashMap;
import java.util.Set;
public class TempCounter {
HashMap<String, SymbolTable> Symboltable;
int counter = 0;
int argcounter = 0;
int labelcounter = 0;
public TempCounter(HashMap<String, SymbolTable> Symboltable) {
this.Symboltable = Symboltable;
}
public void maxArgs() {
int maxArgs = 0;
int tempArgs = 0;
Set<String> classNames = this.Symboltable.keySet();
for (String classname : classNames) {
Set<String> methods = this.Symboltable.get(classname).getMethodsMap().keySet();
for (String methodname : methods) {
if ((tempArgs = this.Symboltable.get(classname).getMethodsMap().get(methodname).args.size()) > maxArgs) {
maxArgs = tempArgs;
}
}
}
counter = maxArgs;
}
public int getTemp() {
counter++;
return counter;
}
public int getArgTemp() {
argcounter++;
return argcounter;
}
public int getLabelTemp() {
labelcounter++;
return labelcounter;
}
public void resetCounter() {
counter = 0;
}
public void resetArgCounter() {
argcounter = 0;
}
public void resetLabelCounter() {
labelcounter = 0;
}
}