mirror of
https://github.com/zeek/zeek.git
synced 2025-10-16 13:38:19 +00:00
WhenStmt/WhenInfo restructuring in support of ZAM "when" statements
This commit is contained in:
parent
7d5760ac74
commit
1dd2270272
5 changed files with 200 additions and 90 deletions
16
src/Var.cc
16
src/Var.cc
|
@ -768,11 +768,10 @@ TraversalCode OuterIDBindingFinder::PreStmt(const Stmt* stmt)
|
|||
if ( stmt->Tag() != STMT_WHEN )
|
||||
return TC_CONTINUE;
|
||||
|
||||
// The semantics of identifiers for the "when" statement are those
|
||||
// of the lambda it's transformed into.
|
||||
|
||||
auto ws = static_cast<const WhenStmt*>(stmt);
|
||||
ws->Info()->Lambda()->Traverse(this);
|
||||
|
||||
for ( auto& cl : ws->Info()->WhenExprLocals() )
|
||||
outer_id_references.insert(const_cast<ID*>(cl.get()));
|
||||
|
||||
return TC_ABORTSTMT;
|
||||
}
|
||||
|
@ -789,18 +788,19 @@ TraversalCode OuterIDBindingFinder::PreExpr(const Expr* expr)
|
|||
if ( expr->Tag() != EXPR_NAME )
|
||||
return TC_CONTINUE;
|
||||
|
||||
auto* e = static_cast<const NameExpr*>(expr);
|
||||
auto e = static_cast<const NameExpr*>(expr);
|
||||
auto id = e->Id();
|
||||
|
||||
if ( e->Id()->IsGlobal() )
|
||||
if ( id->IsGlobal() )
|
||||
return TC_CONTINUE;
|
||||
|
||||
for ( const auto& scope : scopes )
|
||||
if ( scope->Find(e->Id()->Name()) )
|
||||
if ( scope->Find(id->Name()) )
|
||||
// Shadowing is not allowed, so if it's found at inner scope, it's
|
||||
// not something we have to worry about also being at outer scope.
|
||||
return TC_CONTINUE;
|
||||
|
||||
outer_id_references.insert(e->Id());
|
||||
outer_id_references.insert(id);
|
||||
return TC_CONTINUE;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue