Rework of memory handling in Evaluation
Some checks failed
continuous-integration/drone/push Build is failing
Some checks failed
continuous-integration/drone/push Build is failing
This commit is contained in:
@@ -42,15 +42,15 @@ namespace Porygon::Evaluation {
|
||||
protected:
|
||||
const shared_ptr<const GenericFunctionScriptType> _type;
|
||||
const size_t _hash;
|
||||
vector<shared_ptr<GenericFunctionOption>>* _options;
|
||||
shared_ptr<vector<shared_ptr<GenericFunctionOption>>> _options;
|
||||
GenericFunctionEvalValue(shared_ptr<const GenericFunctionScriptType> type, size_t hash,
|
||||
shared_ptr<vector<shared_ptr<GenericFunctionOption>>> options)
|
||||
:_type(std::move(type)), _hash(hash), _options(std::move(options))
|
||||
{}
|
||||
public:
|
||||
GenericFunctionEvalValue(shared_ptr<const GenericFunctionScriptType> type, size_t hash)
|
||||
: _type(move(type)),
|
||||
_hash(hash), _options(new vector<shared_ptr<GenericFunctionOption>>()){
|
||||
}
|
||||
|
||||
~GenericFunctionEvalValue() final{
|
||||
delete _options;
|
||||
_hash(hash), _options(make_shared<vector<shared_ptr<GenericFunctionOption>>>()){
|
||||
}
|
||||
|
||||
GenericFunctionEvalValue(const GenericFunctionEvalValue& _) = delete;
|
||||
@@ -58,19 +58,16 @@ namespace Porygon::Evaluation {
|
||||
GenericFunctionEvalValue& operator =(GenericFunctionEvalValue v) = delete;
|
||||
|
||||
[[nodiscard]]
|
||||
shared_ptr<const EvalValue> Clone() const final {
|
||||
auto t = make_shared<GenericFunctionEvalValue>(_type, _hash);
|
||||
for (const auto& o: *_options){
|
||||
t->_options->push_back(o);
|
||||
}
|
||||
return t;
|
||||
EvalValue* Clone() const final {
|
||||
return new GenericFunctionEvalValue(_type, _hash, _options);
|
||||
}
|
||||
|
||||
inline void RegisterOption(GenericFunctionOption* option) const{
|
||||
_options->push_back(shared_ptr<GenericFunctionOption>(option));
|
||||
}
|
||||
|
||||
inline std::shared_ptr<const ScriptType> GetType() const {
|
||||
[[nodiscard]]
|
||||
inline std::shared_ptr<const GenericFunctionScriptType> GetType() const {
|
||||
return _type;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user