mirror of
https://github.com/zeek/zeek.git
synced 2025-10-08 17:48:21 +00:00
more robust treatment of arithmetic coercions
This commit is contained in:
parent
e06d988bfd
commit
292bd1b671
3 changed files with 22 additions and 29 deletions
|
@ -2075,8 +2075,13 @@ ExprPtr ArithCoerceExpr::Duplicate()
|
|||
|
||||
bool ArithCoerceExpr::WillTransform(Reducer* c) const
|
||||
{
|
||||
return op->Tag() == EXPR_CONST &&
|
||||
IsArithmetic(op->AsConstExpr()->Value()->GetType()->Tag());
|
||||
if ( op->Tag() != EXPR_CONST )
|
||||
return false;
|
||||
|
||||
if ( IsArithmetic(GetType()->Tag()) )
|
||||
return true;
|
||||
|
||||
return IsArithmetic(op->AsConstExpr()->Value()->GetType()->Tag());
|
||||
}
|
||||
|
||||
ExprPtr ArithCoerceExpr::Reduce(Reducer* c, StmtPtr& red_stmt)
|
||||
|
@ -2093,10 +2098,11 @@ ExprPtr ArithCoerceExpr::Reduce(Reducer* c, StmtPtr& red_stmt)
|
|||
|
||||
if ( op->Tag() == EXPR_CONST )
|
||||
{
|
||||
auto cv = op->AsConstExpr()->Value();
|
||||
auto tag = cv->GetType()->Tag();
|
||||
const auto& t = GetType();
|
||||
auto cv = op->AsConstExpr()->ValuePtr();
|
||||
const auto& ct = cv->GetType();
|
||||
|
||||
if ( IsArithmetic(tag) )
|
||||
if ( IsArithmetic(t->Tag()) || IsArithmetic(ct->Tag()) )
|
||||
return make_intrusive<ConstExpr>(FoldSingleVal(cv, t));
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue