mirror of
https://github.com/zeek/zeek.git
synced 2025-10-10 02:28:21 +00:00
Switch FuncType capture-list storage to optional<vector<Capture>>
May help clarify overall mem-mgmt/ownership semantics.
This commit is contained in:
parent
ab15a98b28
commit
b08112b2e7
8 changed files with 44 additions and 41 deletions
19
src/parse.y
19
src/parse.y
|
@ -1315,7 +1315,24 @@ begin_lambda:
|
|||
{
|
||||
auto id = zeek::detail::current_scope()->GenerateTemporary("anonymous-function");
|
||||
zeek::detail::begin_func(id, zeek::detail::current_module.c_str(), zeek::FUNC_FLAVOR_FUNCTION, false, {zeek::AdoptRef{}, $2});
|
||||
$2->SetCaptures($1);
|
||||
|
||||
std::optional<zeek::FuncType::CaptureList> captures;
|
||||
|
||||
if ( $1 )
|
||||
{
|
||||
captures = zeek::FuncType::CaptureList{};
|
||||
captures->reserve($1->size());
|
||||
|
||||
for ( auto c : *$1 )
|
||||
{
|
||||
captures->emplace_back(*c);
|
||||
delete c;
|
||||
}
|
||||
|
||||
delete $1;
|
||||
}
|
||||
|
||||
$2->SetCaptures(std::move(captures));
|
||||
$$ = id.release();
|
||||
}
|
||||
;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue