Switch FuncType capture-list storage to optional<vector<Capture>>

May help clarify overall mem-mgmt/ownership semantics.
This commit is contained in:
Jon Siwek 2021-01-11 15:57:58 -08:00
parent ab15a98b28
commit b08112b2e7
8 changed files with 44 additions and 41 deletions

View file

@ -622,8 +622,6 @@ FuncType::FuncType(RecordTypePtr arg_args,
}
prototypes.emplace_back(Prototype{false, "", args, std::move(offsets)});
captures = nullptr;
}
TypePtr FuncType::ShallowClone()
@ -657,16 +655,6 @@ string FuncType::FlavorString() const
}
}
FuncType::~FuncType()
{
if ( captures )
{
for ( auto c : *captures )
delete c;
delete captures;
}
}
int FuncType::MatchesIndex(detail::ListExpr* const index) const
{
return check_and_promote_args(index, args.get()) ?
@ -709,9 +697,9 @@ bool FuncType::CheckArgs(const std::vector<TypePtr>& args,
return success;
}
void FuncType::SetCaptures(std::vector<Capture*>* _captures)
void FuncType::SetCaptures(std::optional<CaptureList> _captures)
{
captures = _captures;
captures = std::move(_captures);
}
void FuncType::Describe(ODesc* d) const