#include "EvaluationScope.hpp" #include EvaluationScope::EvaluationScope(unordered_map> *scriptVariables, int deepestScope) { _scriptScope = scriptVariables; _localScope = unordered_map>(deepestScope); } void EvaluationScope::CreateVariable(BoundVariableKey* key, const shared_ptr &value) { if (key->GetScopeId() == 0){ _scriptScope -> at(key->GetIdentifier()) = value; } else{ auto insert = _localScope.insert({key->GetHash(), value}); if (!insert.second){ _localScope[key->GetHash()] = value; } } } void EvaluationScope::SetVariable(BoundVariableKey* key, const shared_ptr &value) { if (key->GetScopeId() == 0){ _scriptScope -> at(key->GetIdentifier()) = value; } else{ _localScope[key->GetHash()] = value; } } shared_ptr EvaluationScope::GetVariable(BoundVariableKey* key) { if (key->GetScopeId() == 0){ return _scriptScope -> at(key->GetIdentifier()); } else{ return _localScope[key->GetHash()]; } }