-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFunctionEnvironment.java
More file actions
49 lines (35 loc) · 1.13 KB
/
Copy pathFunctionEnvironment.java
File metadata and controls
49 lines (35 loc) · 1.13 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
import java.util.Vector;
public class FunctionEnvironment {
static final int TABLESIZE = 503;
public FunctionEnvironment() {
htable = new HashTable(TABLESIZE);
}
public FunctionEntry find(String key) {
return (FunctionEntry) htable.find(key);
}
public int size() {
return htable.numelements();
}
public void addBuiltinFunctions() {
Vector formals;
formals = new Vector(0);
htable.insert("Read", new FunctionEntry(IntegerType.instance(), formals,
Label.AbsLabel("Read"), Label.AbsLabel("Readend")));
htable.insert("Println", new FunctionEntry(VoidType.instance(), formals,
Label.AbsLabel("Println"), Label.AbsLabel("Printlnend")));
formals = new Vector(1);
formals.addElement(IntegerType.instance());
htable.insert("Print", new FunctionEntry(VoidType.instance(),formals,
Label.AbsLabel("Print"), Label.AbsLabel("Printend")));
}
public void insert(String key, FunctionEntry entry) {
htable.insert(key,entry);
}
public void beginScope() {
htable.beginScope();
}
public void endScope() {
htable.endScope();
}
private HashTable htable;
}