aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2015-10-04 17:27:54 +0100
committerMichael Williamson <mike@zwobble.org>2015-10-04 17:27:54 +0100
commite8c8fe86c757bd1208427c0ad4f8134f1b1bff1f (patch)
treecf5dea583a0c0222af227aa439729422f274d1cd /src/main/java/org
parent87f73abf5e7dcec6a9f5ebd213f4a9eb0a5d45db (diff)
Throw exception if getting value of variable out of scope
Diffstat (limited to 'src/main/java/org')
-rw-r--r--src/main/java/org/zwobble/couscous/interpreter/Environment.java5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/main/java/org/zwobble/couscous/interpreter/Environment.java b/src/main/java/org/zwobble/couscous/interpreter/Environment.java
index 5985a94..d748654 100644
--- a/src/main/java/org/zwobble/couscous/interpreter/Environment.java
+++ b/src/main/java/org/zwobble/couscous/interpreter/Environment.java
@@ -18,8 +18,9 @@ public class Environment {
this.stackFrame = new HashMap<>(stackFrame);
}
- public InterpreterValue get(int referentId) {
- return stackFrame.get(referentId).get();
+ public InterpreterValue get(int variableId) {
+ checkVariable(variableId);
+ return stackFrame.get(variableId).get();
}
public void put(int variableId, InterpreterValue value) {