Rework evaluation to use shared pointers, fix bugs

This commit is contained in:
2019-06-01 21:38:39 +02:00
parent 4408cf00cd
commit 6206fef4c5
17 changed files with 122 additions and 133 deletions

View File

@@ -7,18 +7,18 @@
#include "../EvalValues/EvalValue.hpp"
class EvaluationScope {
unordered_map<int, EvalValue*>* _scriptScope;
vector<unordered_map<int, EvalValue*>> _localScope;
unordered_map<int, shared_ptr<EvalValue>>* _scriptScope;
vector<unordered_map<int, shared_ptr<EvalValue>>> _localScope;
int _currentScope;
public:
explicit EvaluationScope(unordered_map<int, EvalValue*>* scriptVariables, int deepestScope);
~EvaluationScope();
explicit EvaluationScope(unordered_map<int, shared_ptr<EvalValue>>* scriptVariables, int deepestScope);
~EvaluationScope() = default;
void CreateVariable(int scope, int id, EvalValue* value);
void SetVariable(int scope, int id, EvalValue* value);
void CreateVariable(int scope, int id, shared_ptr<EvalValue> value);
void SetVariable(int scope, int id, shared_ptr<EvalValue> value);
void OuterScope();
void InnerScope();
EvalValue* GetVariable(int scope, int id);
shared_ptr<EvalValue> GetVariable(int scope, int id);
};