Fixed memory issue when assigning new method options
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Deukhoofd 2019-07-27 18:30:05 +02:00
parent ccc6e297f2
commit 82c82ae93d
Signed by: Deukhoofd
GPG Key ID: ADF2E9256009EDCE
2 changed files with 8 additions and 7 deletions

View File

@ -25,15 +25,15 @@ namespace Porygon::Evaluation {
public:
EvaluationScriptFunctionOption(shared_ptr<const BoundBlockStatement> innerBlock, shared_ptr<EvaluationScope> scope)
: _innerBlock(std::move(innerBlock)), _scope(std::move(scope)) {
: GenericFunctionOption(), _innerBlock(std::move(innerBlock)), _scope(std::move(scope)) {
}
~EvaluationScriptFunctionOption() final = default;
~EvaluationScriptFunctionOption() final{};
inline std::shared_ptr<const BoundBlockStatement> GetInnerBlock() const {
[[nodiscard]] inline std::shared_ptr<const BoundBlockStatement> GetInnerBlock() const {
return _innerBlock;
}
inline const std::shared_ptr<EvaluationScope> &GetScope() const {
[[nodiscard]] inline const std::shared_ptr<EvaluationScope> &GetScope() const {
return _scope;
}
};
@ -50,7 +50,8 @@ namespace Porygon::Evaluation {
public:
GenericFunctionEvalValue(shared_ptr<const GenericFunctionScriptType> type, size_t hash)
: _type(move(type)),
_hash(hash), _options(make_shared<vector<shared_ptr<GenericFunctionOption>>>()){
_hash(hash),
_options(make_shared<vector<shared_ptr<GenericFunctionOption>>>()){
}
GenericFunctionEvalValue(const GenericFunctionEvalValue& _) = delete;

View File

@ -108,9 +108,9 @@ namespace Porygon::Evaluation {
auto value = EvalValuePointer(p);
this->_evaluationScope->CreateVariable(key, value);
} else {
auto var = (GenericFunctionEvalValue*)this -> _evaluationScope ->GetVariable(key).Get();
auto var = (GenericFunctionEvalValue*)this -> _evaluationScope ->GetVariable(key).Take();
var->RegisterOption(option);
//this->_evaluationScope->SetVariable(key, var);
delete var;
}
}