-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFunctionInfo.java
More file actions
39 lines (32 loc) · 1.06 KB
/
FunctionInfo.java
File metadata and controls
39 lines (32 loc) · 1.06 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
import java.util.*;
public class FunctionInfo {
public String returnType;
public List<String> paramNames = new ArrayList<>();
public List<String> paramTypes;
public Map<String, VariableInfo> varTable;
public FunctionInfo(String returnType) {
this.returnType = returnType;
this.paramTypes = new ArrayList<>();
this.varTable = new HashMap<>();
}
public void addParam(String name, String type, int address) {
paramTypes.add(type);
paramNames.add(name);
varTable.put(name, new VariableInfo(type, address, "local"));
}
public void addParamType(String type) {
this.paramTypes.add(type);
}
public boolean addVariable(String name, VariableInfo info) {
if (varTable.containsKey(name))
return false;
varTable.put(name, info);
return true;
}
public VariableInfo getVariable(String name) {
return varTable.get(name);
}
public Set<String> getVariableNames() {
return Collections.unmodifiableSet(varTable.keySet());
}
}