Fix issue when deleting script with no evalValue result

This commit is contained in:
Deukhoofd 2019-05-25 12:26:11 +02:00
parent fe2007b095
commit f1fbf7044b
No known key found for this signature in database
GPG Key ID: B4C087AC81641654
3 changed files with 6 additions and 0 deletions

View File

@ -22,6 +22,9 @@ void Evaluator::EvaluateBlockStatement(BoundBlockStatement* statement) {
}
void Evaluator::EvaluateExpressionStatement(BoundExpressionStatement *statement) {
// Delete previously saved value.
delete this->_scriptData->_lastValue;
// Save new value
this->_scriptData->_lastValue = this -> EvaluateExpression(statement->GetExpression());
}

View File

@ -30,6 +30,7 @@ class Evaluator {
public:
Evaluator(Script* script){
_scriptData = script;
_result = nullptr;
}
void Evaluate(BoundScriptStatement* statement);

View File

@ -15,6 +15,8 @@ Script Script::Create(string script) {
Script::Script() {
Diagnostics = new class Diagnostics();
_evaluator = new Evaluator(this);
_lastValue = nullptr;
BoundScript = nullptr;
}
void Script::Evaluate() {