Private
Public Access
Allow backtracking to the 0th stack
This commit is contained in:
1 parent
d397454c00
commit
7e31e40175
1 file changed
+6
-3
+6
-3
@@ -1,4 +1,5 @@
|
|||||||
using System.Collections.Generic;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace Advanced_Software_Engineering.Verbs.Value {
|
namespace Advanced_Software_Engineering.Verbs.Value {
|
||||||
public class ValueStorage {
|
public class ValueStorage {
|
||||||
@@ -37,7 +38,9 @@ namespace Advanced_Software_Engineering.Verbs.Value {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public IValue GetVariable(string name) {
|
public IValue GetVariable(string name) {
|
||||||
return GetVariable(name, currentStack);
|
if (currentStack > 0 && CheckVariableExists(name, currentStack)) return GetVariable(name, currentStack);
|
||||||
|
else if (CheckVariableExists(name, 0)) return GetVariable(name, 0);
|
||||||
|
else throw new Exception("Cannot find variable " + name);
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool CheckVariableExists(string name, int stack) {
|
public bool CheckVariableExists(string name, int stack) {
|
||||||
@@ -46,7 +49,7 @@ namespace Advanced_Software_Engineering.Verbs.Value {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public bool CheckVariableExists(string name) {
|
public bool CheckVariableExists(string name) {
|
||||||
return CheckVariableExists(name, currentStack);
|
return CheckVariableExists(name, currentStack) || CheckVariableExists(name, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user