blob: b4decd85ed84c237f0bc68a4d5dbf8a764db550b (
plain)
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
|
package org.zwobble.couscous.interpreter;
import java.util.HashMap;
import java.util.Map;
import org.zwobble.couscous.Project;
import org.zwobble.couscous.values.ConcreteType;
import org.zwobble.couscous.values.InterpreterValue;
public class Environment {
private final Map<Integer, InterpreterValue> stackFrame;
private final Project project;
public Environment(Project project, Map<Integer, InterpreterValue> stackFrame) {
this.project = project;
this.stackFrame = new HashMap<>(stackFrame);
}
public InterpreterValue get(int referentId) {
return stackFrame.get(referentId);
}
public void put(int referentId, InterpreterValue value) {
stackFrame.put(referentId, value);
}
public ConcreteType<?> findClass(String className) {
// TODO: handle missing classes
return project.findClass(className);
}
public Environment withStackFrame(Map<Integer, InterpreterValue> stackFrame) {
return new Environment(project, stackFrame);
}
}
|