Implements variable usage, tweaks and fixes for variable assignment

This commit is contained in:
2019-05-30 15:23:48 +02:00
parent 257eb942c7
commit 6fad5a0a7d
17 changed files with 145 additions and 4 deletions

View File

@@ -57,7 +57,7 @@ BoundVariable *BoundScope::GetVariable(int scope, int identifier) {
}
return nullptr;
} else{
auto s = this->_localScope.at(scope);
auto s = this->_localScope.at(scope - 1);
auto find = s -> find(identifier);
if (find != s -> end()){
return find -> second;
@@ -72,7 +72,7 @@ VariableAssignment BoundScope::CreateExplicitLocal(int identifier, const ScriptT
return VariableAssignment(VariableAssignmentResult::ExplicitLocalVariableExists, nullptr);
}
scope -> insert({identifier, new BoundVariable(type)});
return VariableAssignment(VariableAssignmentResult::Ok, new BoundVariableKey(identifier, this->_currentScope - 1, true));
return VariableAssignment(VariableAssignmentResult::Ok, new BoundVariableKey(identifier, this->_currentScope, true));
}
VariableAssignment BoundScope::AssignVariable(int identifier, const ScriptType& type) {