mirror of
https://github.com/zeek/zeek.git
synced 2025-10-12 19:48:20 +00:00
fixes for treating WhileStmt's "loop_cond_pred_stmt" as a first-class citizen
This commit is contained in:
parent
9900a3468c
commit
d165db6909
1 changed files with 17 additions and 1 deletions
18
src/Stmt.cc
18
src/Stmt.cc
|
@ -1109,7 +1109,10 @@ WhileStmt::~WhileStmt() = default;
|
||||||
|
|
||||||
bool WhileStmt::IsPure() const
|
bool WhileStmt::IsPure() const
|
||||||
{
|
{
|
||||||
return loop_condition->IsPure() && body->IsPure();
|
if ( loop_condition->IsPure() && body->IsPure() )
|
||||||
|
return ! loop_cond_pred_stmt || loop_cond_pred_stmt->IsPure();
|
||||||
|
else
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void WhileStmt::StmtDescribe(ODesc* d) const
|
void WhileStmt::StmtDescribe(ODesc* d) const
|
||||||
|
@ -1119,6 +1122,13 @@ void WhileStmt::StmtDescribe(ODesc* d) const
|
||||||
if ( d->IsReadable() )
|
if ( d->IsReadable() )
|
||||||
d->Add("(");
|
d->Add("(");
|
||||||
|
|
||||||
|
if ( loop_cond_pred_stmt )
|
||||||
|
{
|
||||||
|
d->Add(" {");
|
||||||
|
loop_cond_pred_stmt->Describe(d);
|
||||||
|
d->Add("} ");
|
||||||
|
}
|
||||||
|
|
||||||
loop_condition->Describe(d);
|
loop_condition->Describe(d);
|
||||||
|
|
||||||
if ( d->IsReadable() )
|
if ( d->IsReadable() )
|
||||||
|
@ -1136,6 +1146,12 @@ TraversalCode WhileStmt::Traverse(TraversalCallback* cb) const
|
||||||
TraversalCode tc = cb->PreStmt(this);
|
TraversalCode tc = cb->PreStmt(this);
|
||||||
HANDLE_TC_STMT_PRE(tc);
|
HANDLE_TC_STMT_PRE(tc);
|
||||||
|
|
||||||
|
if ( loop_cond_pred_stmt )
|
||||||
|
{
|
||||||
|
tc = loop_cond_pred_stmt->Traverse(cb);
|
||||||
|
HANDLE_TC_STMT_PRE(tc);
|
||||||
|
}
|
||||||
|
|
||||||
tc = loop_condition->Traverse(cb);
|
tc = loop_condition->Traverse(cb);
|
||||||
HANDLE_TC_STMT_PRE(tc);
|
HANDLE_TC_STMT_PRE(tc);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue