mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 14:48:21 +00:00
script optimization fix for new-style table constructors
This commit is contained in:
parent
5389ad69f8
commit
ee28609e74
1 changed files with 16 additions and 3 deletions
|
@ -2009,8 +2009,21 @@ bool TableConstructorExpr::HasReducedOps(Reducer* c) const
|
|||
for ( const auto& expr : exprs )
|
||||
{
|
||||
auto a = expr->AsAssignExpr();
|
||||
auto lhs = a->GetOp1();
|
||||
auto rhs = a->GetOp2();
|
||||
|
||||
// LHS is a list, not a singleton.
|
||||
if ( ! a->GetOp1()->HasReducedOps(c) || ! a->GetOp2()->IsSingleton(c) )
|
||||
if ( ! lhs->HasReducedOps(c) )
|
||||
return NonReduced(this);
|
||||
|
||||
// RHS might also be a list, if it's a table-of-sets or such.
|
||||
if ( rhs->Tag() == EXPR_LIST )
|
||||
{
|
||||
if ( ! rhs->HasReducedOps(c) )
|
||||
return NonReduced(this);
|
||||
}
|
||||
|
||||
else if ( ! rhs->IsSingleton(c) )
|
||||
return NonReduced(this);
|
||||
}
|
||||
|
||||
|
@ -2498,8 +2511,8 @@ bool ListExpr::HasReducedOps(Reducer* c) const
|
|||
{
|
||||
for ( const auto& expr : exprs )
|
||||
{
|
||||
// Ugly hack for record constructors.
|
||||
if ( expr->Tag() == EXPR_FIELD_ASSIGN )
|
||||
// Ugly hack for record and complex table constructors.
|
||||
if ( expr->Tag() == EXPR_FIELD_ASSIGN || expr->Tag() == EXPR_LIST )
|
||||
{
|
||||
if ( ! expr->HasReducedOps(c) )
|
||||
return false;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue