summaryrefslogtreecommitdiffstats
path: root/src/Compiler/Environment.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/Compiler/Environment.java')
-rw-r--r--src/Compiler/Environment.java3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/Compiler/Environment.java b/src/Compiler/Environment.java
index 0e682a4..3ccf425 100644
--- a/src/Compiler/Environment.java
+++ b/src/Compiler/Environment.java
@@ -5,11 +5,13 @@ import java.util.Map;
public class Environment {
private final Map<String,Object> variableMap = new HashMap<>();
+ //Define a variable inside the current environment
//Maybe check if variable is already defined?
public void defineVariable(String name,Object value){
variableMap.put(name, value);
}
+ //Get a variable if it is defined, or report an error
public Object getVariable(String name){
if(variableMap.containsKey(name)){
return variableMap.get(name);
@@ -18,6 +20,7 @@ public class Environment {
throw new Error();
}
+ //Assign a value to an existing variable
public void assignVariable(String name,Object value){
if(variableMap.containsKey(name)){
variableMap.put(name, value);