Fix modules without return type throwing segmentation fault
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2019-09-12 21:50:48 +02:00
parent 80f3af22ac
commit 3a9f1f976a
3 changed files with 38 additions and 5 deletions

View File

@@ -25,7 +25,7 @@ Porygon::Script::Script(const u16string& s, ScriptOptions* options)
: Diagnostics(make_shared<Diagnostics::DiagnosticsHolder>(s)),
_boundScript(nullptr),
_scriptVariables(new map<Utilities::HashedString, EvalValuePointer>()),
_scriptTypes(new unordered_map<Utilities::HashedString, shared_ptr<ScriptType>>{}),
_scriptTypes(new unordered_map<Utilities::HashedString, shared_ptr<const ScriptType>>{}),
_scriptOptions(options)
{
_evaluator = new Evaluator(this -> _scriptVariables, this -> GetScriptOptions());
@@ -63,7 +63,7 @@ void Porygon::Script::Parse(const u16string& script) {
delete v.second;
}
for (const auto& v : variableTypes){
this->_scriptTypes -> insert({v.first, nullptr});
this->_scriptTypes -> insert({v.first, v.second});
}
scriptScope.clear();
variableTypes.clear();
@@ -109,7 +109,7 @@ Porygon::Script::Script(shared_ptr<BoundScriptStatement> boundScript,
: _boundScript(std::move(boundScript)),
Diagnostics(std::move(diagnostics)),
_scriptVariables(new map<Utilities::HashedString, EvalValuePointer>()),
_scriptTypes(new unordered_map<Utilities::HashedString, shared_ptr<ScriptType>>{}),
_scriptTypes(new unordered_map<Utilities::HashedString, shared_ptr<const ScriptType>>{}),
_scriptOptions(nullptr)
{
_evaluator = new Evaluator(_scriptVariables, this -> GetScriptOptions());

View File

@@ -19,7 +19,7 @@ namespace Porygon{
class Script {
Evaluator* _evaluator;
map<Utilities::HashedString, EvalValuePointer>* _scriptVariables;
unordered_map<Utilities::HashedString, shared_ptr<ScriptType>>* _scriptTypes;
unordered_map<Utilities::HashedString, shared_ptr<const ScriptType>>* _scriptTypes;
shared_ptr<Binder::BoundScriptStatement> _boundScript;
shared_ptr<const ScriptType> _returnType = nullptr;
ScriptOptions* _scriptOptions;