Private
Public Access
ValueStorage now removes stacks after lowering stack count
This commit is contained in:
1 parent
c7ab58d0bb
commit
8dffaa1326
1 file changed
+6
-11
+6
-11
@@ -6,16 +6,13 @@ namespace Advanced_Software_Engineering.Verbs.Value {
|
||||
|
||||
protected int currentStack;
|
||||
protected Dictionary<int, Dictionary<string, IValue>> Variables = new Dictionary<int, Dictionary<string, IValue>>();
|
||||
protected List<IValue> VariableList = new List<IValue>();
|
||||
|
||||
public ValueStorage() {
|
||||
Reset();
|
||||
}
|
||||
|
||||
public void Reset() {
|
||||
//for every ivalue
|
||||
Variables = new Dictionary<int, Dictionary<string, IValue>>();
|
||||
//for (int index = 0; index < VariableList.Count; index++) VariableList[index] = null;
|
||||
SetStack(0);
|
||||
}
|
||||
|
||||
@@ -30,8 +27,11 @@ namespace Advanced_Software_Engineering.Verbs.Value {
|
||||
}
|
||||
|
||||
public void DecreaseStack() {
|
||||
currentStack--;
|
||||
SetStack(currentStack);
|
||||
if (currentStack > 0) {
|
||||
Variables.Remove(currentStack);
|
||||
currentStack--;
|
||||
SetStack(currentStack);
|
||||
}
|
||||
}
|
||||
|
||||
public void SetVariable(string name, int stack, IValue value) {
|
||||
@@ -39,12 +39,7 @@ namespace Advanced_Software_Engineering.Verbs.Value {
|
||||
else {
|
||||
if (CheckVariableExists(name, stack)) Variables[stack][name] = value;
|
||||
else if (CheckVariableExists(name, 0)) Variables[0][name] = value;
|
||||
else// if(value == null) {
|
||||
Variables[stack][name] = value;
|
||||
//VariableList.Add(Variables[stack][name]);
|
||||
//} else {
|
||||
// throw new Exception("Tried setting a variable that was not declared");
|
||||
//}
|
||||
else Variables[stack][name] = value;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user