diff options
Diffstat (limited to 'src/Compiler/Environment.java')
-rw-r--r-- | src/Compiler/Environment.java | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/src/Compiler/Environment.java b/src/Compiler/Environment.java index 3ccf425..1bb0e88 100644 --- a/src/Compiler/Environment.java +++ b/src/Compiler/Environment.java @@ -12,21 +12,20 @@ public class Environment { } //Get a variable if it is defined, or report an error - public Object getVariable(String name){ - if(variableMap.containsKey(name)){ - return variableMap.get(name); + public Object getVariable(Token token){ + if(variableMap.containsKey(token.text)){ + return variableMap.get(token.text); } - Language.displayError("Undefined Variable"); + Language.displayError(token,"Undefined Variable"); 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); - return; + //Get a variable if it is defined, or report an error + public Boolean checkVariable(Token token){ + if(variableMap.containsKey(token.text)){ + return true; } - Language.displayError("Variable undefined"); + Language.displayError(token,"Undefined Variable"); throw new Error(); } } |