mirror of
https://github.com/zeek/zeek.git
synced 2025-10-10 02:28:21 +00:00
captures for "when" statements
update Triggers to IntrusivePtr's and simpler AST traversal introduce IDSet type, migrate associated "ID*" types to "const ID*"
This commit is contained in:
parent
fa142438fe
commit
f895008c34
24 changed files with 648 additions and 202 deletions
19
src/Var.cc
19
src/Var.cc
|
@ -680,6 +680,7 @@ class OuterIDBindingFinder : public TraversalCallback
|
|||
public:
|
||||
OuterIDBindingFinder(ScopePtr s) { scopes.emplace_back(s); }
|
||||
|
||||
TraversalCode PreStmt(const Stmt*) override;
|
||||
TraversalCode PreExpr(const Expr*) override;
|
||||
TraversalCode PostExpr(const Expr*) override;
|
||||
|
||||
|
@ -687,6 +688,24 @@ public:
|
|||
std::unordered_set<ID*> outer_id_references;
|
||||
};
|
||||
|
||||
TraversalCode OuterIDBindingFinder::PreStmt(const Stmt* stmt)
|
||||
{
|
||||
if ( stmt->Tag() != STMT_WHEN )
|
||||
return TC_CONTINUE;
|
||||
|
||||
auto ws = static_cast<const WhenStmt*>(stmt);
|
||||
auto lambda = ws->Info()->Lambda();
|
||||
|
||||
if ( ! lambda )
|
||||
// Old-style semantics.
|
||||
return TC_CONTINUE;
|
||||
|
||||
// The semantics of identifiers for the "when" statement are those
|
||||
// of the lambda it's transformed into.
|
||||
lambda->Traverse(this);
|
||||
return TC_ABORTSTMT;
|
||||
}
|
||||
|
||||
TraversalCode OuterIDBindingFinder::PreExpr(const Expr* expr)
|
||||
{
|
||||
if ( expr->Tag() == EXPR_LAMBDA )
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue