tidying for check_and_promote_expr

This commit is contained in:
Vern Paxson 2021-05-30 18:09:53 -07:00
parent 8044926e00
commit 1cbec158f3

View file

@ -5311,7 +5311,7 @@ ExprPtr check_and_promote_expr(Expr* const e, zeek::Type* t)
return nullptr;
}
return make_intrusive<ArithCoerceExpr>(IntrusivePtr{NewRef{}, e}, t_tag);
return make_intrusive<ArithCoerceExpr>(e_ptr, t_tag);
}
if ( t->Tag() == TYPE_RECORD && et->Tag() == TYPE_RECORD )
@ -5320,11 +5320,10 @@ ExprPtr check_and_promote_expr(Expr* const e, zeek::Type* t)
RecordType* et_r = et->AsRecordType();
if ( same_type(t, et) )
return {NewRef{}, e};
return e_ptr;
if ( record_promotion_compatible(t_r, et_r) )
return make_intrusive<RecordCoerceExpr>(
IntrusivePtr{NewRef{}, e},
return make_intrusive<RecordCoerceExpr>(e_ptr,
IntrusivePtr{NewRef{}, t_r});
t->Error("incompatible record types", e);
@ -5336,14 +5335,12 @@ ExprPtr check_and_promote_expr(Expr* const e, zeek::Type* t)
{
if ( t->Tag() == TYPE_TABLE && et->Tag() == TYPE_TABLE &&
et->AsTableType()->IsUnspecifiedTable() )
return make_intrusive<TableCoerceExpr>(
IntrusivePtr{NewRef{}, e},
return make_intrusive<TableCoerceExpr>(e_ptr,
IntrusivePtr{NewRef{}, t->AsTableType()});
if ( t->Tag() == TYPE_VECTOR && et->Tag() == TYPE_VECTOR &&
et->AsVectorType()->IsUnspecifiedVector() )
return make_intrusive<VectorCoerceExpr>(
IntrusivePtr{NewRef{}, e},
return make_intrusive<VectorCoerceExpr>(e_ptr,
IntrusivePtr{NewRef{}, t->AsVectorType()});
if ( t->Tag() != TYPE_ERROR && et->Tag() != TYPE_ERROR )
@ -5352,7 +5349,7 @@ ExprPtr check_and_promote_expr(Expr* const e, zeek::Type* t)
return nullptr;
}
return {NewRef{}, e};
return e_ptr;
}
bool check_and_promote_exprs(ListExpr* const elements, TypeList* types)