Rework evaluation to use shared pointers, fix bugs
This commit is contained in:
@@ -16,7 +16,7 @@ Script::Script() {
|
||||
_evaluator = new Evaluator(this);
|
||||
_lastValue = nullptr;
|
||||
BoundScript = nullptr;
|
||||
_scriptVariables = new unordered_map<int, EvalValue*>(0);
|
||||
_scriptVariables = new unordered_map<int, shared_ptr<EvalValue>>(0);
|
||||
}
|
||||
|
||||
void Script::Evaluate() {
|
||||
@@ -26,11 +26,7 @@ void Script::Evaluate() {
|
||||
Script::~Script() {
|
||||
delete this -> Diagnostics;
|
||||
delete this -> BoundScript;
|
||||
delete this -> _lastValue;
|
||||
delete this -> _evaluator;
|
||||
for (auto v : *this->_scriptVariables){
|
||||
delete v.second;
|
||||
}
|
||||
this->_scriptVariables->clear();
|
||||
delete this->_scriptVariables;
|
||||
}
|
||||
@@ -58,7 +54,7 @@ void Script::Parse(string script) {
|
||||
}
|
||||
|
||||
EvalValue *Script::GetVariable(const string &key) {
|
||||
return _scriptVariables -> at(HashedString(key).GetHash());
|
||||
return _scriptVariables -> at(HashedString(key).GetHash()).get();
|
||||
}
|
||||
|
||||
bool Script::HasVariable(const string &key) {
|
||||
|
||||
Reference in New Issue
Block a user