mirror of
https://github.com/zeek/zeek.git
synced 2025-10-05 08:08:19 +00:00
Deprecate Val(double, TypeTag) ctor, add TimeVal/DoubleVal subclasses
This also updates all usages of the deprecated Val ctor to use either IntervalVal, TimeVal, or DoubleVal ctors. The reason for doing away with the old constructor is that using it with TYPE_INTERVAL isn't strictly correct since there exists a more specific subclass, IntervalVal, with overriden ValDescribe() method that ought to be used to print such values in a more descriptive way.
This commit is contained in:
parent
a431f6b45d
commit
5b4313b593
76 changed files with 847 additions and 782 deletions
14
src/Expr.cc
14
src/Expr.cc
|
@ -675,9 +675,11 @@ IntrusivePtr<Val> BinaryExpr::Fold(Val* v1, Val* v2) const
|
|||
const auto& ret_type = IsVector(GetType()->Tag()) ? GetType()->Yield() : GetType();
|
||||
|
||||
if ( ret_type->Tag() == TYPE_INTERVAL )
|
||||
return make_intrusive<IntervalVal>(d3, 1.0);
|
||||
else if ( ret_type->InternalType() == TYPE_INTERNAL_DOUBLE )
|
||||
return make_intrusive<Val>(d3, ret_type->Tag());
|
||||
return make_intrusive<IntervalVal>(d3);
|
||||
else if ( ret_type->Tag() == TYPE_TIME )
|
||||
return make_intrusive<TimeVal>(d3);
|
||||
else if ( ret_type->Tag() == TYPE_DOUBLE )
|
||||
return make_intrusive<DoubleVal>(d3);
|
||||
else if ( ret_type->InternalType() == TYPE_INTERNAL_UNSIGNED )
|
||||
return val_mgr->Count(u3);
|
||||
else if ( ret_type->Tag() == TYPE_BOOL )
|
||||
|
@ -1097,9 +1099,9 @@ NegExpr::NegExpr(IntrusivePtr<Expr> arg_op)
|
|||
IntrusivePtr<Val> NegExpr::Fold(Val* v) const
|
||||
{
|
||||
if ( v->GetType()->Tag() == TYPE_DOUBLE )
|
||||
return make_intrusive<Val>(- v->InternalDouble(), v->GetType()->Tag());
|
||||
return make_intrusive<DoubleVal>(- v->InternalDouble());
|
||||
else if ( v->GetType()->Tag() == TYPE_INTERVAL )
|
||||
return make_intrusive<IntervalVal>(- v->InternalDouble(), 1.0);
|
||||
return make_intrusive<IntervalVal>(- v->InternalDouble());
|
||||
else
|
||||
return val_mgr->Int(- v->CoerceToInt());
|
||||
}
|
||||
|
@ -3461,7 +3463,7 @@ IntrusivePtr<Val> ArithCoerceExpr::FoldSingleVal(Val* v, InternalTypeTag t) cons
|
|||
{
|
||||
switch ( t ) {
|
||||
case TYPE_INTERNAL_DOUBLE:
|
||||
return make_intrusive<Val>(v->CoerceToDouble(), TYPE_DOUBLE);
|
||||
return make_intrusive<DoubleVal>(v->CoerceToDouble());
|
||||
|
||||
case TYPE_INTERNAL_INT:
|
||||
return val_mgr->Int(v->CoerceToInt());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue