mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 14:48:21 +00:00
ZAM optimization for ?$ operator applied to non-optional fields
This commit is contained in:
parent
3505827982
commit
1d5bc841e0
2 changed files with 19 additions and 0 deletions
|
@ -1917,6 +1917,22 @@ ExprPtr HasFieldExpr::Duplicate()
|
|||
return SetSucc(new HasFieldExpr(op->Duplicate(), util::copy_string(field_name)));
|
||||
}
|
||||
|
||||
bool HasFieldExpr::IsReduced(Reducer* c) const
|
||||
{
|
||||
return op->GetType<RecordType>()->FieldHasAttr(field, ATTR_OPTIONAL);
|
||||
}
|
||||
|
||||
ExprPtr HasFieldExpr::Reduce(Reducer* c, StmtPtr& red_stmt)
|
||||
{
|
||||
if ( ! op->GetType<RecordType>()->FieldHasAttr(field, ATTR_OPTIONAL) )
|
||||
{
|
||||
auto true_constant = make_intrusive<ConstExpr>(val_mgr->True());
|
||||
return TransformMe(true_constant, c, red_stmt);
|
||||
}
|
||||
|
||||
return UnaryExpr::Reduce(c, red_stmt);
|
||||
}
|
||||
|
||||
ExprPtr RecordConstructorExpr::Duplicate()
|
||||
{
|
||||
auto op_l = op->Duplicate()->AsListExprPtr();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue