mirror of
https://github.com/zeek/zeek.git
synced 2025-10-09 18:18:19 +00:00
Merge remote-tracking branch 'origin/topic/vern/when-lambda'
* origin/topic/vern/when-lambda: explicitly provide the frame for evaluating a "when" timeout expression attempt to make "when" btest deterministic tests for new "when" semantics/errors update existing test suite usage of "when" statements to include captures update uses of "when" in base scripts to include captures captures for "when" statements update Triggers to IntrusivePtr's and simpler AST traversal introduce IDSet type, migrate associated "ID*" types to "const ID*" logic (other than in profiling) for assignments that yield separate values option for internal use to mark a function type as allowing non-expression returns removed some now-obsolete profiling functionality minor commenting clarifications
This commit is contained in:
commit
3d9d6e953b
56 changed files with 931 additions and 255 deletions
23
src/Var.cc
23
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 )
|
||||
|
@ -722,6 +741,10 @@ TraversalCode OuterIDBindingFinder::PostExpr(const Expr* expr)
|
|||
return TC_CONTINUE;
|
||||
}
|
||||
|
||||
// The following is only used for debugging AST duplication. If activated,
|
||||
// each AST is replaced with its duplicate. In the absence of a duplication
|
||||
// error, this shouldn't change any semantics, so running the test suite
|
||||
// with this variable set can find flaws in the duplication machinery.
|
||||
static bool duplicate_ASTs = getenv("ZEEK_DUPLICATE_ASTS");
|
||||
|
||||
void end_func(StmtPtr body, bool free_of_conditionals)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue