parsing of new []-style captures, and creation of associated data structures

This commit is contained in:
Vern Paxson 2021-01-04 13:58:20 -08:00
parent f673f85acc
commit 955384291d
3 changed files with 107 additions and 13 deletions

View file

@ -622,6 +622,8 @@ FuncType::FuncType(RecordTypePtr arg_args,
}
prototypes.emplace_back(Prototype{false, "", args, std::move(offsets)});
captures = nullptr;
}
TypePtr FuncType::ShallowClone()
@ -632,6 +634,7 @@ TypePtr FuncType::ShallowClone()
f->yield = yield;
f->flavor = flavor;
f->prototypes = prototypes;
f->captures = captures;
return f;
}
@ -654,7 +657,15 @@ string FuncType::FlavorString() const
}
}
FuncType::~FuncType() = default;
FuncType::~FuncType()
{
if ( captures )
{
for ( auto c : *captures )
delete c;
delete captures;
}
}
int FuncType::MatchesIndex(detail::ListExpr* const index) const
{
@ -698,6 +709,11 @@ bool FuncType::CheckArgs(const std::vector<TypePtr>& args,
return success;
}
void FuncType::SetCaptures(std::vector<Capture*>* _captures)
{
captures = _captures;
}
void FuncType::Describe(ODesc* d) const
{
if ( d->IsReadable() )