Implements variable usage, tweaks and fixes for variable assignment
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
EvaluationScope::EvaluationScope(unordered_map<int, EvalValue *> *scriptVariables, int deepestScope) {
|
||||
_scriptScope = scriptVariables;
|
||||
_localScope = vector<unordered_map<int, EvalValue*>>(deepestScope);
|
||||
_currentScope = -1;
|
||||
}
|
||||
|
||||
EvaluationScope::~EvaluationScope() {
|
||||
@@ -27,5 +28,21 @@ void EvaluationScope::SetVariable(int scope, int id, EvalValue *value) {
|
||||
}
|
||||
|
||||
EvalValue *EvaluationScope::GetVariable(int scope, int id) {
|
||||
if (scope == 0){
|
||||
return _scriptScope->at(id);
|
||||
}
|
||||
return _localScope[scope - 1][id];
|
||||
}
|
||||
|
||||
void EvaluationScope::OuterScope() {
|
||||
_currentScope++;
|
||||
}
|
||||
|
||||
void EvaluationScope::InnerScope() {
|
||||
auto scope = this->_localScope[_currentScope];
|
||||
for (auto v: scope){
|
||||
delete v.second;
|
||||
}
|
||||
_currentScope--;
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user