Deprecate Val::Type(), replace with GetType()

This commit is contained in:
Jon Siwek 2020-05-11 12:14:54 -07:00
parent 737420c359
commit 1eb723fc9d
30 changed files with 270 additions and 255 deletions

2
NEWS
View file

@ -169,6 +169,8 @@ Deprecated Functionality
- ``opt_internal_val()`` is deprecated, use ``lookup_ID()`` or
``zeek::lookup_val()``.
- ``Val::Type()`` is deprecated, use ``Val::GetType``.
Zeek 3.1.0
==========

View file

@ -88,7 +88,7 @@ char* CompositeHash::SingleValHash(bool type_check, char* kp0,
if ( type_check )
{
InternalTypeTag vt = v->Type()->InternalType();
InternalTypeTag vt = v->GetType()->InternalType();
if ( vt != t )
return nullptr;
}
@ -138,7 +138,7 @@ char* CompositeHash::SingleValHash(bool type_check, char* kp0,
case TYPE_INTERNAL_VOID:
case TYPE_INTERNAL_OTHER:
{
switch ( v->Type()->Tag() ) {
switch ( v->GetType()->Tag() ) {
case TYPE_FUNC:
{
uint32_t* kp = AlignAndPadType<uint32_t>(kp0);
@ -240,15 +240,15 @@ char* CompositeHash::SingleValHash(bool type_check, char* kp0,
auto idx = kv.second;
Val* key = lv->Idx(idx).get();
if ( ! (kp1 = SingleValHash(type_check, kp1, key->Type(), key,
if ( ! (kp1 = SingleValHash(type_check, kp1, key->GetType().get(), key,
false)) )
return nullptr;
if ( ! v->Type()->IsSet() )
if ( ! v->GetType()->IsSet() )
{
auto val = tv->Lookup(key);
if ( ! (kp1 = SingleValHash(type_check, kp1, val->Type(),
if ( ! (kp1 = SingleValHash(type_check, kp1, val->GetType().get(),
val.get(), false)) )
return nullptr;
}
@ -261,7 +261,7 @@ char* CompositeHash::SingleValHash(bool type_check, char* kp0,
{
unsigned int* kp = AlignAndPadType<unsigned int>(kp0);
VectorVal* vv = v->AsVectorVal();
VectorType* vt = v->Type()->AsVectorType();
VectorType* vt = v->GetType()->AsVectorType();
*kp = vv->Size();
kp1 = reinterpret_cast<char*>(kp+1);
for ( unsigned int i = 0; i < vv->Size(); ++i )
@ -293,7 +293,7 @@ char* CompositeHash::SingleValHash(bool type_check, char* kp0,
for ( int i = 0; i < lv->Length(); ++i )
{
Val* v = lv->Idx(i).get();
if ( ! (kp1 = SingleValHash(type_check, kp1, v->Type(), v,
if ( ! (kp1 = SingleValHash(type_check, kp1, v->GetType().get(), v,
false)) )
return nullptr;
}
@ -341,7 +341,7 @@ HashKey* CompositeHash::ComputeHash(const Val* v, bool type_check) const
if ( is_singleton )
return ComputeSingletonHash(v, type_check);
if ( is_complex_type && v->Type()->Tag() != TYPE_LIST )
if ( is_complex_type && v->GetType()->Tag() != TYPE_LIST )
{
ListVal lv(TYPE_ANY);
@ -368,7 +368,7 @@ HashKey* CompositeHash::ComputeHash(const Val* v, bool type_check) const
const auto& tl = type->Types();
if ( type_check && v->Type()->Tag() != TYPE_LIST )
if ( type_check && v->GetType()->Tag() != TYPE_LIST )
return nullptr;
auto lv = v->AsListVal();
@ -389,7 +389,7 @@ HashKey* CompositeHash::ComputeHash(const Val* v, bool type_check) const
HashKey* CompositeHash::ComputeSingletonHash(const Val* v, bool type_check) const
{
if ( v->Type()->Tag() == TYPE_LIST )
if ( v->GetType()->Tag() == TYPE_LIST )
{
auto lv = v->AsListVal();
@ -399,7 +399,7 @@ HashKey* CompositeHash::ComputeSingletonHash(const Val* v, bool type_check) cons
v = lv->Idx(0).get();
}
if ( type_check && v->Type()->InternalType() != singleton_tag )
if ( type_check && v->GetType()->InternalType() != singleton_tag )
return nullptr;
switch ( singleton_tag ) {
@ -418,10 +418,10 @@ HashKey* CompositeHash::ComputeSingletonHash(const Val* v, bool type_check) cons
case TYPE_INTERNAL_VOID:
case TYPE_INTERNAL_OTHER:
if ( v->Type()->Tag() == TYPE_FUNC )
if ( v->GetType()->Tag() == TYPE_FUNC )
return new HashKey(v->AsFunc()->GetUniqueFuncID());
if ( v->Type()->Tag() == TYPE_PATTERN )
if ( v->GetType()->Tag() == TYPE_PATTERN )
{
const char* texts[2] = {
v->AsPattern()->PatternText(),
@ -460,7 +460,7 @@ int CompositeHash::SingleTypeKeySize(BroType* bt, const Val* v,
if ( type_check && v )
{
InternalTypeTag vt = v->Type()->InternalType();
InternalTypeTag vt = v->GetType()->InternalType();
if ( vt != t )
return 0;
}
@ -539,7 +539,7 @@ int CompositeHash::SingleTypeKeySize(BroType* bt, const Val* v,
for ( int i = 0; i < tv->Size(); ++i )
{
Val* key = lv->Idx(i).get();
sz = SingleTypeKeySize(key->Type(), key, type_check, sz, false,
sz = SingleTypeKeySize(key->GetType().get(), key, type_check, sz, false,
calc_static_size);
if ( ! sz )
return 0;
@ -547,7 +547,7 @@ int CompositeHash::SingleTypeKeySize(BroType* bt, const Val* v,
if ( ! bt->IsSet() )
{
auto val = tv->Lookup(key);
sz = SingleTypeKeySize(val->Type(), val.get(), type_check, sz,
sz = SingleTypeKeySize(val->GetType().get(), val.get(), type_check, sz,
false, calc_static_size);
if ( ! sz )
return 0;
@ -588,7 +588,7 @@ int CompositeHash::SingleTypeKeySize(BroType* bt, const Val* v,
ListVal* lv = const_cast<ListVal*>(v->AsListVal());
for ( int i = 0; i < lv->Length(); ++i )
{
sz = SingleTypeKeySize(lv->Idx(i)->Type(), lv->Idx(i).get(),
sz = SingleTypeKeySize(lv->Idx(i)->GetType().get(), lv->Idx(i).get(),
type_check, sz, false, calc_static_size);
if ( ! sz) return 0;
}
@ -628,7 +628,7 @@ int CompositeHash::ComputeKeySize(const Val* v, bool type_check, bool calc_stati
if ( v )
{
if ( type_check && v->Type()->Tag() != TYPE_LIST )
if ( type_check && v->GetType()->Tag() != TYPE_LIST )
return 0;
auto lv = v->AsListVal();
@ -851,12 +851,12 @@ const char* CompositeHash::RecoverOneVal(const HashKey* k, const char* kp0,
reporter->InternalError("failed to look up unique function id %" PRIu32 " in CompositeHash::RecoverOneVal()", *kp);
*pval = make_intrusive<Val>(f);
auto pvt = (*pval)->Type();
const auto& pvt = (*pval)->GetType();
if ( ! pvt )
reporter->InternalError("bad aggregate Val in CompositeHash::RecoverOneVal()");
else if ( t->Tag() != TYPE_FUNC && ! same_type(pvt, t) )
else if ( t->Tag() != TYPE_FUNC && ! same_type(pvt.get(), t) )
// ### Maybe fix later, but may be fundamentally
// un-checkable --US
reporter->InternalError("inconsistent aggregate Val in CompositeHash::RecoverOneVal()");

View file

@ -258,8 +258,8 @@ BreakCode DbgBreakpoint::HasHit()
return bcHit;
}
if ( ! IsIntegral(yes->Type()->Tag()) &&
! IsBool(yes->Type()->Tag()) )
if ( ! IsIntegral(yes->GetType()->Tag()) &&
! IsBool(yes->GetType()->Tag()) )
{
PrintHitMsg();
debug_msg("Breakpoint condition should return an integral type");

View file

@ -310,10 +310,10 @@ void NameExpr::ExprDescribe(ODesc* d) const
ConstExpr::ConstExpr(IntrusivePtr<Val> arg_val)
: Expr(EXPR_CONST), val(std::move(arg_val))
{
if ( val->Type()->Tag() == TYPE_LIST && val->AsListVal()->Length() == 1 )
if ( val->GetType()->Tag() == TYPE_LIST && val->AsListVal()->Length() == 1 )
val = val->AsListVal()->Idx(0);
SetType({NewRef{}, val->Type()});
SetType(val->GetType());
}
void ConstExpr::ExprDescribe(ODesc* d) const
@ -355,13 +355,14 @@ IntrusivePtr<Val> UnaryExpr::Eval(Frame* f) const
if ( is_vector(v.get()) && Tag() != EXPR_IS && Tag() != EXPR_CAST )
{
VectorVal* v_op = v->AsVectorVal();
VectorType* out_t;
if ( Type()->Tag() == TYPE_ANY )
out_t = v->Type()->AsVectorType();
else
out_t = Type()->AsVectorType();
IntrusivePtr<VectorType> out_t;
auto result = make_intrusive<VectorVal>(IntrusivePtr{NewRef{}, out_t});
if ( Type()->Tag() == TYPE_ANY )
out_t = v->GetType<VectorType>();
else
out_t = {NewRef{}, Type()->AsVectorType()};
auto result = make_intrusive<VectorVal>(std::move(out_t));
for ( unsigned int i = 0; i < v_op->Size(); ++i )
{
@ -524,15 +525,15 @@ void BinaryExpr::ExprDescribe(ODesc* d) const
IntrusivePtr<Val> BinaryExpr::Fold(Val* v1, Val* v2) const
{
InternalTypeTag it = v1->Type()->InternalType();
InternalTypeTag it = v1->GetType()->InternalType();
if ( it == TYPE_INTERNAL_STRING )
return StringFold(v1, v2);
if ( v1->Type()->Tag() == TYPE_PATTERN )
if ( v1->GetType()->Tag() == TYPE_PATTERN )
return PatternFold(v1, v2);
if ( v1->Type()->IsSet() )
if ( v1->GetType()->IsSet() )
return SetFold(v1, v2);
if ( it == TYPE_INTERNAL_ADDR )
@ -950,7 +951,7 @@ IntrusivePtr<Val> IncrExpr::DoSingleEval(Frame* f, Val* v) const
--k;
if ( k < 0 &&
v->Type()->InternalType() == TYPE_INTERNAL_UNSIGNED )
v->GetType()->InternalType() == TYPE_INTERNAL_UNSIGNED )
RuntimeError("count underflow");
}
@ -1071,7 +1072,7 @@ PosExpr::PosExpr(IntrusivePtr<Expr> arg_op)
IntrusivePtr<Val> PosExpr::Fold(Val* v) const
{
TypeTag t = v->Type()->Tag();
TypeTag t = v->GetType()->Tag();
if ( t == TYPE_DOUBLE || t == TYPE_INTERVAL || t == TYPE_INT )
return {NewRef{}, v};
@ -1109,9 +1110,9 @@ NegExpr::NegExpr(IntrusivePtr<Expr> arg_op)
IntrusivePtr<Val> NegExpr::Fold(Val* v) const
{
if ( v->Type()->Tag() == TYPE_DOUBLE )
return make_intrusive<Val>(- v->InternalDouble(), v->Type()->Tag());
else if ( v->Type()->Tag() == TYPE_INTERVAL )
if ( v->GetType()->Tag() == TYPE_DOUBLE )
return make_intrusive<Val>(- v->InternalDouble(), v->GetType()->Tag());
else if ( v->GetType()->Tag() == TYPE_INTERVAL )
return make_intrusive<IntervalVal>(- v->InternalDouble(), 1.0);
else
return val_mgr->Int(- v->CoerceToInt());
@ -1440,7 +1441,7 @@ IntrusivePtr<Val> DivideExpr::AddrFold(Val* v1, Val* v2) const
{
uint32_t mask;
if ( v2->Type()->Tag() == TYPE_COUNT )
if ( v2->GetType()->Tag() == TYPE_COUNT )
mask = static_cast<uint32_t>(v2->InternalUnsigned());
else
mask = static_cast<uint32_t>(v2->InternalInt());
@ -2026,7 +2027,10 @@ AssignExpr::AssignExpr(IntrusivePtr<Expr> arg_op1, IntrusivePtr<Expr> arg_op2,
if ( IsError() )
return;
SetType({NewRef{}, arg_val ? arg_val->Type() : op1->Type()});
if ( arg_val )
SetType(arg_val->GetType());
else
SetType({NewRef{}, op1->Type()});
if ( is_init )
{
@ -2368,7 +2372,7 @@ IntrusivePtr<Val> AssignExpr::InitVal(const BroType* t, IntrusivePtr<Val> aggr)
return nullptr;
}
if ( aggr->Type()->Tag() != TYPE_RECORD )
if ( aggr->GetType()->Tag() != TYPE_RECORD )
Internal("bad aggregate in AssignExpr::InitVal");
RecordVal* aggr_r = aggr->AsRecordVal();
@ -2390,12 +2394,12 @@ IntrusivePtr<Val> AssignExpr::InitVal(const BroType* t, IntrusivePtr<Val> aggr)
return nullptr;
}
if ( aggr->Type()->Tag() != TYPE_TABLE )
if ( aggr->GetType()->Tag() != TYPE_TABLE )
Internal("bad aggregate in AssignExpr::InitVal");
auto tv = cast_intrusive<TableVal>(std::move(aggr));
const TableType* tt = tv->Type()->AsTableType();
const auto& yt = tv->Type()->Yield();
const TableType* tt = tv->GetType()->AsTableType();
const auto& yt = tv->GetType()->Yield();
auto index = op1->InitVal(tt->Indices(), nullptr);
auto v = op2->InitVal(yt.get(), nullptr);
@ -2595,7 +2599,7 @@ IntrusivePtr<Val> IndexExpr::Eval(Frame* f) const
auto v_result = make_intrusive<VectorVal>(IntrusivePtr{NewRef{}, Type()->AsVectorType()});
// Booleans select each element (or not).
if ( IsBool(v_v2->Type()->Yield()->Tag()) )
if ( IsBool(v_v2->GetType()->Yield()->Tag()) )
{
if ( v_v1->Size() != v_v2->Size() )
{
@ -2648,7 +2652,7 @@ IntrusivePtr<Val> IndexExpr::Fold(Val* v1, Val* v2) const
IntrusivePtr<Val> v;
switch ( v1->Type()->Tag() ) {
switch ( v1->GetType()->Tag() ) {
case TYPE_VECTOR:
{
VectorVal* vect = v1->AsVectorVal();
@ -2659,7 +2663,7 @@ IntrusivePtr<Val> IndexExpr::Fold(Val* v1, Val* v2) const
else
{
size_t len = vect->Size();
auto result = make_intrusive<VectorVal>(IntrusivePtr{NewRef{}, vect->Type()->AsVectorType()});
auto result = make_intrusive<VectorVal>(vect->GetType<VectorType>());
bro_int_t first = get_slice_index(lv->Idx(0)->CoerceToInt(), len);
bro_int_t last = get_slice_index(lv->Idx(1)->CoerceToInt(), len);
@ -2749,7 +2753,7 @@ void IndexExpr::Assign(Frame* f, IntrusivePtr<Val> v)
// from the original value after the assignment already unref'd.
auto v_extra = v;
switch ( v1->Type()->Tag() ) {
switch ( v1->GetType()->Tag() ) {
case TYPE_VECTOR:
{
const ListVal* lv = v2->AsListVal();
@ -2779,7 +2783,7 @@ void IndexExpr::Assign(Frame* f, IntrusivePtr<Val> v)
{
ODesc d;
v->Describe(&d);
auto vt = v->Type();
const auto& vt = v->GetType();
auto vtt = vt->Tag();
std::string tn = vtt == TYPE_RECORD ? vt->GetName() : type_name(vtt);
RuntimeErrorWithCallStack(fmt(
@ -2801,7 +2805,7 @@ void IndexExpr::Assign(Frame* f, IntrusivePtr<Val> v)
{
ODesc d;
v->Describe(&d);
auto vt = v->Type();
const auto& vt = v->GetType();
auto vtt = vt->Tag();
std::string tn = vtt == TYPE_RECORD ? vt->GetName() : type_name(vtt);
RuntimeErrorWithCallStack(fmt(
@ -3656,7 +3660,7 @@ IntrusivePtr<Val> RecordCoerceExpr::InitVal(const BroType* t, IntrusivePtr<Val>
IntrusivePtr<Val> RecordCoerceExpr::Fold(Val* v) const
{
auto val = make_intrusive<RecordVal>(Type()->AsRecordType());
RecordType* val_type = val->Type()->AsRecordType();
RecordType* val_type = val->GetType()->AsRecordType();
RecordVal* rv = v->AsRecordVal();
@ -3668,7 +3672,7 @@ IntrusivePtr<Val> RecordCoerceExpr::Fold(Val* v) const
if ( ! rhs )
{
const Attr* def = rv->Type()->AsRecordType()->FieldDecl(
const Attr* def = rv->GetType()->AsRecordType()->FieldDecl(
map[i])->FindAttr(ATTR_DEFAULT);
if ( def )
@ -3684,7 +3688,7 @@ IntrusivePtr<Val> RecordCoerceExpr::Fold(Val* v) const
continue;
}
BroType* rhs_type = rhs->Type();
BroType* rhs_type = rhs->GetType().get();
BroType* field_type = val_type->GetFieldType(i).get();
if ( rhs_type->Tag() == TYPE_RECORD &&
@ -3710,12 +3714,12 @@ IntrusivePtr<Val> RecordCoerceExpr::Fold(Val* v) const
if ( const Attr* def = Type()->AsRecordType()->FieldDecl(i)->FindAttr(ATTR_DEFAULT) )
{
auto def_val = def->AttrExpr()->Eval(nullptr);
BroType* def_type = def_val->Type();
const auto& def_type = def_val->GetType();
const auto& field_type = Type()->AsRecordType()->GetFieldType(i);
if ( def_type->Tag() == TYPE_RECORD &&
field_type->Tag() == TYPE_RECORD &&
! same_type(def_type, field_type.get()) )
! same_type(def_type.get(), field_type.get()) )
{
auto tmp = def_val->AsRecordVal()->CoerceTo(
field_type->AsRecordType());
@ -3833,7 +3837,7 @@ IntrusivePtr<Val> FlattenExpr::Fold(Val* v) const
continue;
}
const RecordType* rv_t = rv->Type()->AsRecordType();
const RecordType* rv_t = rv->GetType()->AsRecordType();
if ( const Attr* fa = rv_t->FieldDecl(i)->FindAttr(ATTR_DEFAULT) )
l->Append(fa->AttrExpr()->Eval(nullptr));
@ -4020,14 +4024,14 @@ InExpr::InExpr(IntrusivePtr<Expr> arg_op1, IntrusivePtr<Expr> arg_op2)
IntrusivePtr<Val> InExpr::Fold(Val* v1, Val* v2) const
{
if ( v1->Type()->Tag() == TYPE_PATTERN )
if ( v1->GetType()->Tag() == TYPE_PATTERN )
{
RE_Matcher* re = v1->AsPattern();
const BroString* s = v2->AsString();
return val_mgr->Bool(re->MatchAnywhere(s) != 0);
}
if ( v2->Type()->Tag() == TYPE_STRING )
if ( v2->GetType()->Tag() == TYPE_STRING )
{
const BroString* s1 = v1->AsString();
const BroString* s2 = v2->AsString();
@ -4038,8 +4042,8 @@ IntrusivePtr<Val> InExpr::Fold(Val* v1, Val* v2) const
return val_mgr->Bool(res);
}
if ( v1->Type()->Tag() == TYPE_ADDR &&
v2->Type()->Tag() == TYPE_SUBNET )
if ( v1->GetType()->Tag() == TYPE_ADDR &&
v2->GetType()->Tag() == TYPE_SUBNET )
return val_mgr->Bool(v2->AsSubNetVal()->Contains(v1->AsAddr()));
bool res;
@ -4633,7 +4637,8 @@ IntrusivePtr<Val> ListExpr::InitVal(const BroType* t, IntrusivePtr<Val> aggr) co
loop_over_list(exprs, i)
{
Expr* e = exprs[i];
auto promoted_e = check_and_promote_expr(e, vec->Type()->AsVectorType()->Yield().get());
const auto& vyt = vec->GetType()->AsVectorType()->Yield();
auto promoted_e = check_and_promote_expr(e, vyt.get());
if ( promoted_e )
e = promoted_e.get();
@ -4670,9 +4675,9 @@ IntrusivePtr<Val> ListExpr::InitVal(const BroType* t, IntrusivePtr<Val> aggr) co
auto v = e->Eval(nullptr);
if ( ! same_type(v->Type(), t) )
if ( ! same_type(v->GetType().get(), t) )
{
v->Type()->Error("type clash in table initializer", t);
v->GetType()->Error("type clash in table initializer", t);
return nullptr;
}
@ -4686,11 +4691,11 @@ IntrusivePtr<Val> ListExpr::InitVal(const BroType* t, IntrusivePtr<Val> aggr) co
IntrusivePtr<Val> ListExpr::AddSetInit(const BroType* t, IntrusivePtr<Val> aggr) const
{
if ( aggr->Type()->Tag() != TYPE_TABLE )
if ( aggr->GetType()->Tag() != TYPE_TABLE )
Internal("bad aggregate in ListExpr::InitVal");
TableVal* tv = aggr->AsTableVal();
const TableType* tt = tv->Type()->AsTableType();
const TableType* tt = tv->GetType()->AsTableType();
const TypeList* it = tt->Indices();
for ( const auto& expr : exprs )
@ -4708,9 +4713,9 @@ IntrusivePtr<Val> ListExpr::AddSetInit(const BroType* t, IntrusivePtr<Val> aggr)
if ( ! element )
return nullptr;
if ( element->Type()->IsSet() )
if ( element->GetType()->IsSet() )
{
if ( ! same_type(element->Type(), t) )
if ( ! same_type(element->GetType().get(), t) )
{
element->Error("type clash in set initializer", t);
return nullptr;
@ -4875,12 +4880,12 @@ IntrusivePtr<Val> CastExpr::Eval(Frame* f) const
ODesc d;
d.Add("invalid cast of value with type '");
v->Type()->Describe(&d);
v->GetType()->Describe(&d);
d.Add("' to type '");
Type()->Describe(&d);
d.Add("'");
if ( same_type(v->Type(), bro_broker::DataVal::ScriptDataType()) &&
if ( same_type(v->GetType().get(), bro_broker::DataVal::ScriptDataType()) &&
! v->AsRecordVal()->Lookup(0) )
d.Add(" (nil $data field)");

View file

@ -198,7 +198,7 @@ Frame* Frame::Clone() const
static bool val_is_func(Val* v, BroFunc* func)
{
if ( v->Type()->Tag() != TYPE_FUNC )
if ( v->GetType()->Tag() != TYPE_FUNC )
return false;
return v->AsFunc() == func;
@ -357,7 +357,7 @@ broker::expected<broker::data> Frame::Serialize(const Frame* target, const id_li
Val* val = target->frame[location];
TypeTag tag = val->Type()->Tag();
TypeTag tag = val->GetType()->Tag();
auto expected = bro_broker::val_to_data(val);
if ( ! expected )

View file

@ -240,7 +240,7 @@ std::pair<bool, Val*> Func::HandlePluginResult(std::pair<bool, Val*> plugin_resu
break;
case FUNC_FLAVOR_HOOK:
if ( plugin_result.second->Type()->Tag() != TYPE_BOOL )
if ( plugin_result.second->GetType()->Tag() != TYPE_BOOL )
reporter->InternalError("plugin returned non-bool for hook %s", this->Name());
break;
@ -255,10 +255,10 @@ std::pair<bool, Val*> Func::HandlePluginResult(std::pair<bool, Val*> plugin_resu
reporter->InternalError("plugin returned non-void result for void method %s", this->Name());
}
else if ( plugin_result.second && plugin_result.second->Type()->Tag() != yt->Tag() && yt->Tag() != TYPE_ANY)
else if ( plugin_result.second && plugin_result.second->GetType()->Tag() != yt->Tag() && yt->Tag() != TYPE_ANY)
{
reporter->InternalError("plugin returned wrong type (got %d, expecting %d) for %s",
plugin_result.second->Type()->Tag(), yt->Tag(), this->Name());
plugin_result.second->GetType()->Tag(), yt->Tag(), this->Name());
}
break;
@ -859,7 +859,7 @@ static int get_func_priority(const attr_list& attrs)
continue;
}
if ( ! IsIntegral(v->Type()->Tag()) )
if ( ! IsIntegral(v->GetType()->Tag()) )
{
a->Error("expression is not of integral type");
continue;

View file

@ -158,10 +158,10 @@ void ID::UpdateValAttrs()
if ( ! attrs )
return;
if ( val && val->Type()->Tag() == TYPE_TABLE )
if ( val && val->GetType()->Tag() == TYPE_TABLE )
val->AsTableVal()->SetAttrs(attrs);
if ( val && val->Type()->Tag() == TYPE_FILE )
if ( val && val->GetType()->Tag() == TYPE_FILE )
val->AsFile()->SetAttrs(attrs.get());
if ( GetType()->Tag() == TYPE_FUNC )
@ -287,7 +287,7 @@ TraversalCode ID::Traverse(TraversalCallback* cb) const
}
// FIXME: Perhaps we should be checking at other than global scope.
else if ( val && IsFunc(val->Type()->Tag()) &&
else if ( val && IsFunc(val->GetType()->Tag()) &&
cb->current_scope == global_scope() )
{
tc = val->AsFunc()->Traverse(cb);

View file

@ -221,7 +221,7 @@ MD5Val::~MD5Val()
void HashVal::digest_one(EVP_MD_CTX* h, const Val* v)
{
if ( v->Type()->Tag() == TYPE_STRING )
if ( v->GetType()->Tag() == TYPE_STRING )
{
const BroString* str = v->AsString();
hash_update(h, str->Bytes(), str->Len());

View file

@ -43,11 +43,11 @@ void* PrefixTable::Insert(const IPAddr& addr, int width, void* data)
void* PrefixTable::Insert(const Val* value, void* data)
{
// [elem] -> elem
if ( value->Type()->Tag() == TYPE_LIST &&
if ( value->GetType()->Tag() == TYPE_LIST &&
value->AsListVal()->Length() == 1 )
value = value->AsListVal()->Idx(0).get();
switch ( value->Type()->Tag() ) {
switch ( value->GetType()->Tag() ) {
case TYPE_ADDR:
return Insert(value->AsAddr(), 128, data);
break;
@ -103,11 +103,11 @@ void* PrefixTable::Lookup(const IPAddr& addr, int width, bool exact) const
void* PrefixTable::Lookup(const Val* value, bool exact) const
{
// [elem] -> elem
if ( value->Type()->Tag() == TYPE_LIST &&
if ( value->GetType()->Tag() == TYPE_LIST &&
value->AsListVal()->Length() == 1 )
value = value->AsListVal()->Idx(0).get();
switch ( value->Type()->Tag() ) {
switch ( value->GetType()->Tag() ) {
case TYPE_ADDR:
return Lookup(value->AsAddr(), 128, exact);
break;
@ -119,7 +119,7 @@ void* PrefixTable::Lookup(const Val* value, bool exact) const
default:
reporter->InternalWarning("Wrong index type %d for PrefixTable",
value->Type()->Tag());
value->GetType()->Tag());
return nullptr;
}
}
@ -142,11 +142,11 @@ void* PrefixTable::Remove(const IPAddr& addr, int width)
void* PrefixTable::Remove(const Val* value)
{
// [elem] -> elem
if ( value->Type()->Tag() == TYPE_LIST &&
if ( value->GetType()->Tag() == TYPE_LIST &&
value->AsListVal()->Length() == 1 )
value = value->AsListVal()->Idx(0).get();
switch ( value->Type()->Tag() ) {
switch ( value->GetType()->Tag() ) {
case TYPE_ADDR:
return Remove(value->AsAddr(), 128);
break;

View file

@ -1290,7 +1290,7 @@ static bool val_to_maskedval(Val* v, maskedvalue_list* append_to,
{
MaskedValue* mval = new MaskedValue;
switch ( v->Type()->Tag() ) {
switch ( v->GetType()->Tag() ) {
case TYPE_PORT:
mval->val = v->AsPortVal()->Port();
mval->mask = 0xffffffff;
@ -1359,7 +1359,7 @@ void id_to_maskedvallist(const char* id, maskedvalue_list* append_to,
if ( ! v )
return;
if ( v->Type()->Tag() == TYPE_TABLE )
if ( v->GetType()->Tag() == TYPE_TABLE )
{
auto lv = v->AsTableVal()->ToPureListVal();
@ -1381,7 +1381,7 @@ char* id_to_str(const char* id)
if ( ! v )
goto error;
if ( v->Type()->Tag() != TYPE_STRING )
if ( v->GetType()->Tag() != TYPE_STRING )
{
rules_error("Identifier must refer to string");
goto error;
@ -1404,7 +1404,7 @@ uint32_t id_to_uint(const char* id)
if ( ! v )
return 0;
TypeTag t = v->Type()->Tag();
TypeTag t = v->GetType()->Tag();
if ( t == TYPE_BOOL || t == TYPE_COUNT || t == TYPE_ENUM ||
t == TYPE_INT || t == TYPE_PORT )

View file

@ -904,7 +904,7 @@ FragReassembler* NetSessions::NextFragment(double t, const IP_Hdr* ip,
Connection* NetSessions::FindConnection(Val* v)
{
BroType* vt = v->Type();
const auto& vt = v->GetType();
if ( ! IsRecord(vt->Tag()) )
return nullptr;

View file

@ -269,7 +269,7 @@ void ProfileLogger::Log()
if ( size > 100 * 1024 )
print = true;
if ( v->Type()->Tag() == TYPE_TABLE )
if ( v->GetType()->Tag() == TYPE_TABLE )
{
entries = v->AsTable()->Length();
total_table_entries += entries;

View file

@ -227,7 +227,7 @@ IntrusivePtr<Val> PrintStmt::DoExec(std::vector<IntrusivePtr<Val>> vals,
BroFile* f = print_stdout;
int offset = 0;
if ( vals.size() > 0 && (vals)[0]->Type()->Tag() == TYPE_FILE )
if ( vals.size() > 0 && (vals)[0]->GetType()->Tag() == TYPE_FILE )
{
f = (vals)[0]->AsFile();
if ( ! f->IsOpen() )
@ -724,7 +724,7 @@ bool SwitchStmt::AddCaseLabelValueMapping(const Val* v, int idx)
{
reporter->PushLocation(e->GetLocationInfo());
reporter->InternalError("switch expression type mismatch (%s/%s)",
type_name(v->Type()->Tag()), type_name(e->Type()->Tag()));
type_name(v->GetType()->Tag()), type_name(e->Type()->Tag()));
}
int* label_idx = case_label_value_map.Lookup(hk);
@ -768,7 +768,7 @@ std::pair<int, ID*> SwitchStmt::FindCaseLabelMatch(const Val* v) const
{
reporter->PushLocation(e->GetLocationInfo());
reporter->Error("switch expression type mismatch (%s/%s)",
type_name(v->Type()->Tag()), type_name(e->Type()->Tag()));
type_name(v->GetType()->Tag()), type_name(e->Type()->Tag()));
return std::make_pair(-1, nullptr);
}
@ -1179,7 +1179,7 @@ IntrusivePtr<Val> ForStmt::DoExec(Frame* f, Val* v, stmt_flow_type& flow) const
{
IntrusivePtr<Val> ret;
if ( v->Type()->Tag() == TYPE_TABLE )
if ( v->GetType()->Tag() == TYPE_TABLE )
{
TableVal* tv = v->AsTableVal();
const PDict<TableEntryVal>* loop_vals = tv->AsTable();
@ -1223,7 +1223,7 @@ IntrusivePtr<Val> ForStmt::DoExec(Frame* f, Val* v, stmt_flow_type& flow) const
}
}
else if ( v->Type()->Tag() == TYPE_VECTOR )
else if ( v->GetType()->Tag() == TYPE_VECTOR )
{
VectorVal* vv = v->AsVectorVal();
@ -1243,7 +1243,7 @@ IntrusivePtr<Val> ForStmt::DoExec(Frame* f, Val* v, stmt_flow_type& flow) const
break;
}
}
else if ( v->Type()->Tag() == TYPE_STRING )
else if ( v->GetType()->Tag() == TYPE_STRING )
{
StringVal* sval = v->AsStringVal();

View file

@ -411,7 +411,7 @@ bool Val::WouldOverflow(const BroType* from_type, const BroType* to_type, const
IntrusivePtr<TableVal> Val::GetRecordFields()
{
auto t = Type();
auto t = GetType().get();
if ( t->Tag() != TYPE_RECORD && t->Tag() != TYPE_TYPE )
{
@ -457,8 +457,8 @@ static void BuildJSON(threading::formatter::JSON::NullDoubleWriter& writer, Val*
}
rapidjson::Value j;
BroType* type = val->Type();
switch ( type->Tag() )
switch ( val->GetType()->Tag() )
{
case TYPE_BOOL:
writer.Bool(val->AsBool());
@ -525,7 +525,7 @@ static void BuildJSON(threading::formatter::JSON::NullDoubleWriter& writer, Val*
auto* table = val->AsTable();
auto* tval = val->AsTableVal();
if ( tval->Type()->IsSet() )
if ( tval->GetType()->IsSet() )
writer.StartArray();
else
writer.StartObject();
@ -539,7 +539,7 @@ static void BuildJSON(threading::formatter::JSON::NullDoubleWriter& writer, Val*
delete k;
Val* entry_key = lv->Length() == 1 ? lv->Idx(0).get() : lv.get();
if ( tval->Type()->IsSet() )
if ( tval->GetType()->IsSet() )
BuildJSON(writer, entry_key, only_loggable, re);
else
{
@ -558,7 +558,7 @@ static void BuildJSON(threading::formatter::JSON::NullDoubleWriter& writer, Val*
}
}
if ( tval->Type()->IsSet() )
if ( tval->GetType()->IsSet() )
writer.EndArray();
else
writer.EndObject();
@ -571,7 +571,7 @@ static void BuildJSON(threading::formatter::JSON::NullDoubleWriter& writer, Val*
writer.StartObject();
auto* rval = val->AsRecordVal();
auto rt = rval->Type()->AsRecordType();
auto rt = rval->GetType()->AsRecordType();
for ( auto i = 0; i < rt->NumFields(); ++i )
{
@ -1133,7 +1133,7 @@ PatternVal::~PatternVal()
bool PatternVal::AddTo(Val* v, bool /* is_first_init */) const
{
if ( v->Type()->Tag() != TYPE_PATTERN )
if ( v->GetType()->Tag() != TYPE_PATTERN )
{
v->Error("not a pattern");
return false;
@ -1213,13 +1213,13 @@ void ListVal::Append(IntrusivePtr<Val> v)
{
if ( type->AsTypeList()->IsPure() )
{
if ( v->Type()->Tag() != tag )
if ( v->GetType()->Tag() != tag )
Internal("heterogeneous list in ListVal::Append");
}
auto vt = v->Type();
const auto& vt = v->GetType();
vals.emplace_back(std::move(v));
type->AsTypeList()->Append({NewRef{}, vt});
type->AsTypeList()->Append(vt);
}
void ListVal::Append(Val* v)
@ -1436,9 +1436,8 @@ int TableVal::RecursiveSize() const
{
int n = AsTable()->Length();
if ( Type()->IsSet() ||
const_cast<TableType*>(Type()->AsTableType())->Yield()->Tag()
!= TYPE_TABLE )
if ( GetType()->IsSet() ||
GetType()->AsTableType()->Yield()->Tag() != TYPE_TABLE )
return n;
PDict<TableEntryVal>* v = val.table_val;
@ -1583,7 +1582,7 @@ bool TableVal::AddTo(Val* val, bool is_first_init) const
bool TableVal::AddTo(Val* val, bool is_first_init, bool propagate_ops) const
{
if ( val->Type()->Tag() != TYPE_TABLE )
if ( val->GetType()->Tag() != TYPE_TABLE )
{
val->Error("not a table");
return false;
@ -1591,9 +1590,9 @@ bool TableVal::AddTo(Val* val, bool is_first_init, bool propagate_ops) const
TableVal* t = val->AsTableVal();
if ( ! same_type(type.get(), t->Type()) )
if ( ! same_type(type.get(), t->GetType().get()) )
{
type->Error("table type clash", t->Type());
type->Error("table type clash", t->GetType().get());
return false;
}
@ -1629,7 +1628,7 @@ bool TableVal::AddTo(Val* val, bool is_first_init, bool propagate_ops) const
bool TableVal::RemoveFrom(Val* val) const
{
if ( val->Type()->Tag() != TYPE_TABLE )
if ( val->GetType()->Tag() != TYPE_TABLE )
{
val->Error("not a table");
return false;
@ -1637,9 +1636,9 @@ bool TableVal::RemoveFrom(Val* val) const
TableVal* t = val->AsTableVal();
if ( ! same_type(type.get(), t->Type()) )
if ( ! same_type(type.get(), t->GetType().get()) )
{
type->Error("table type clash", t->Type());
type->Error("table type clash", t->GetType().get());
return false;
}
@ -1748,7 +1747,7 @@ bool TableVal::IsSubsetOf(const TableVal* tv) const
bool TableVal::ExpandAndInit(IntrusivePtr<Val> index, IntrusivePtr<Val> new_val)
{
BroType* index_type = index->Type();
const auto& index_type = index->GetType();
if ( index_type->IsSet() )
{
@ -1783,7 +1782,7 @@ bool TableVal::ExpandAndInit(IntrusivePtr<Val> index, IntrusivePtr<Val> new_val)
// ### if CompositeHash::ComputeHash did flattening
// of 1-element lists (like ComputeSingletonHash does),
// then we could optimize here.
BroType* t = v->Type();
const auto& t = v->GetType();
if ( t->IsSet() || t->Tag() == TYPE_LIST )
break;
@ -1807,7 +1806,7 @@ IntrusivePtr<Val> TableVal::Default(Val* index)
if ( ! def_val )
{
const auto& ytype = Type()->Yield();
const auto& ytype = GetType()->Yield();
BroType* dtype = def_attr->AttrExpr()->Type();
if ( dtype->Tag() == TYPE_RECORD && ytype->Tag() == TYPE_RECORD &&
@ -1831,8 +1830,8 @@ IntrusivePtr<Val> TableVal::Default(Val* index)
return nullptr;
}
if ( def_val->Type()->Tag() != TYPE_FUNC ||
same_type(def_val->Type(), Type()->Yield().get()) )
if ( def_val->GetType()->Tag() != TYPE_FUNC ||
same_type(def_val->GetType().get(), GetType()->Yield().get()) )
{
if ( def_attr->AttrExpr()->IsConst() )
return def_val;
@ -1851,7 +1850,7 @@ IntrusivePtr<Val> TableVal::Default(Val* index)
const Func* f = def_val->AsFunc();
zeek::Args vl;
if ( index->Type()->Tag() == TYPE_LIST )
if ( index->GetType()->Tag() == TYPE_LIST )
{
auto lv = index->AsListVal();
vl.reserve(lv->Length());
@ -1945,7 +1944,7 @@ IntrusivePtr<TableVal> TableVal::LookupSubnetValues(const SubNetVal* search)
if ( ! subnets )
reporter->InternalError("LookupSubnetValues called on wrong table type");
auto nt = make_intrusive<TableVal>(IntrusivePtr{NewRef{}, this->Type()->AsTableType()});
auto nt = make_intrusive<TableVal>(this->GetType<TableType>());
auto matches = subnets->FindAll(search);
for ( auto element : matches )
@ -2017,7 +2016,7 @@ void TableVal::CallChangeFunc(const Val* index, Val* old_value, OnChangeType tpe
return;
}
if ( thefunc->Type()->Tag() != TYPE_FUNC )
if ( thefunc->GetType()->Tag() != TYPE_FUNC )
{
thefunc->Error("not a function");
return;
@ -2252,7 +2251,7 @@ void TableVal::Describe(ODesc* d) const
bool TableVal::ExpandCompoundAndInit(ListVal* lv, int k, IntrusivePtr<Val> new_val)
{
Val* ind_k_v = lv->Idx(k).get();
auto ind_k = ind_k_v->Type()->IsSet() ?
auto ind_k = ind_k_v->GetType()->IsSet() ?
ind_k_v->AsTableVal()->ToListVal() :
IntrusivePtr<ListVal>{NewRef{}, ind_k_v->AsListVal()};
@ -2303,7 +2302,7 @@ void TableVal::InitDefaultFunc(Frame* f)
if ( ! def_attr )
return;
const auto& ytype = Type()->Yield();
const auto& ytype = GetType()->Yield();
BroType* dtype = def_attr->AttrExpr()->Type();
if ( dtype->Tag() == TYPE_RECORD && ytype->Tag() == TYPE_RECORD &&
@ -2469,7 +2468,7 @@ double TableVal::CallExpireFunc(IntrusivePtr<ListVal> idx)
// Will have been reported already.
return 0;
if ( vf->Type()->Tag() != TYPE_FUNC )
if ( vf->GetType()->Tag() != TYPE_FUNC )
{
vf->Error("not a function");
return 0;
@ -2672,8 +2671,8 @@ RecordVal::RecordVal(RecordType* t, bool init_fields) : Val(IntrusivePtr{NewRef{
const auto& type = t->FieldDecl(i)->type;
if ( def && type->Tag() == TYPE_RECORD &&
def->Type()->Tag() == TYPE_RECORD &&
! same_type(def->Type(), type.get()) )
def->GetType()->Tag() == TYPE_RECORD &&
! same_type(def->GetType().get(), type.get()) )
{
auto tmp = def->AsRecordVal()->CoerceTo(type->AsRecordType());
@ -2707,7 +2706,7 @@ RecordVal::~RecordVal()
IntrusivePtr<Val> RecordVal::SizeVal() const
{
return val_mgr->Count(Type()->AsRecordType()->NumFields());
return val_mgr->Count(GetType()->AsRecordType()->NumFields());
}
void RecordVal::Assign(int field, IntrusivePtr<Val> new_val)
@ -2734,7 +2733,7 @@ IntrusivePtr<Val> RecordVal::LookupWithDefault(int field) const
if ( val )
return {NewRef{}, val};
return Type()->AsRecordType()->FieldDefault(field);
return GetType()->AsRecordType()->FieldDefault(field);
}
void RecordVal::ResizeParseTimeRecords(RecordType* rt)
@ -2769,7 +2768,7 @@ void RecordVal::DoneParsing()
IntrusivePtr<Val> RecordVal::Lookup(const char* field, bool with_default) const
{
int idx = Type()->AsRecordType()->FieldOffset(field);
int idx = GetType()->AsRecordType()->FieldOffset(field);
if ( idx < 0 )
reporter->InternalError("missing record field: %s", field);
@ -2779,16 +2778,16 @@ IntrusivePtr<Val> RecordVal::Lookup(const char* field, bool with_default) const
IntrusivePtr<RecordVal> RecordVal::CoerceTo(const RecordType* t, Val* aggr, bool allow_orphaning) const
{
if ( ! record_promotion_compatible(t->AsRecordType(), Type()->AsRecordType()) )
if ( ! record_promotion_compatible(t->AsRecordType(), GetType()->AsRecordType()) )
return nullptr;
if ( ! aggr )
aggr = new RecordVal(const_cast<RecordType*>(t->AsRecordType()));
RecordVal* ar = aggr->AsRecordVal();
RecordType* ar_t = aggr->Type()->AsRecordType();
RecordType* ar_t = aggr->GetType()->AsRecordType();
const RecordType* rv_t = Type()->AsRecordType();
const RecordType* rv_t = GetType()->AsRecordType();
int i;
for ( i = 0; i < rv_t->NumFields(); ++i )
@ -2816,7 +2815,7 @@ IntrusivePtr<RecordVal> RecordVal::CoerceTo(const RecordType* t, Val* aggr, bool
const auto& ft = ar_t->GetFieldType(t_i);
if ( ft->Tag() == TYPE_RECORD && ! same_type(ft.get(), v->Type()) )
if ( ft->Tag() == TYPE_RECORD && ! same_type(ft.get(), v->GetType().get()) )
{
auto rhs = make_intrusive<ConstExpr>(IntrusivePtr{NewRef{}, v});
auto e = make_intrusive<RecordCoerceExpr>(std::move(rhs),
@ -2843,7 +2842,7 @@ IntrusivePtr<RecordVal> RecordVal::CoerceTo(const RecordType* t, Val* aggr, bool
IntrusivePtr<RecordVal> RecordVal::CoerceTo(RecordType* t, bool allow_orphaning)
{
if ( same_type(Type(), t) )
if ( same_type(GetType().get(), t) )
return {NewRef{}, this};
return CoerceTo(t, nullptr, allow_orphaning);
@ -2851,14 +2850,14 @@ IntrusivePtr<RecordVal> RecordVal::CoerceTo(RecordType* t, bool allow_orphaning)
IntrusivePtr<TableVal> RecordVal::GetRecordFieldsVal() const
{
return Type()->AsRecordType()->GetRecordFieldsVal(this);
return GetType()->AsRecordType()->GetRecordFieldsVal(this);
}
void RecordVal::Describe(ODesc* d) const
{
const val_list* vl = AsRecord();
int n = vl->length();
auto record_type = Type()->AsRecordType();
auto record_type = GetType()->AsRecordType();
if ( d->IsBinary() || d->IsPortable() )
{
@ -2895,7 +2894,7 @@ void RecordVal::DescribeReST(ODesc* d) const
{
const val_list* vl = AsRecord();
int n = vl->length();
auto record_type = Type()->AsRecordType();
auto record_type = GetType()->AsRecordType();
d->Add("{");
d->PushIndent();
@ -2927,7 +2926,7 @@ IntrusivePtr<Val> RecordVal::DoClone(CloneState* state)
// record. As we cannot guarantee that it will ber zeroed out at the
// approproate time (as it seems to be guaranteed for the original record)
// we don't touch it.
auto rv = make_intrusive<RecordVal>(Type()->AsRecordType(), false);
auto rv = make_intrusive<RecordVal>(GetType()->AsRecordType(), false);
rv->origin = nullptr;
state->NewClone(this, rv);
@ -2999,7 +2998,7 @@ IntrusivePtr<Val> VectorVal::SizeVal() const
bool VectorVal::Assign(unsigned int index, IntrusivePtr<Val> element)
{
if ( element &&
! same_type(element->Type(), Type()->AsVectorType()->Yield().get(), false) )
! same_type(element->GetType().get(), GetType()->AsVectorType()->Yield().get(), false) )
return false;
Val* val_at_index = nullptr;
@ -3040,7 +3039,7 @@ bool VectorVal::AssignRepeat(unsigned int index, unsigned int how_many,
bool VectorVal::Insert(unsigned int index, Val* element)
{
if ( element &&
! same_type(element->Type(), Type()->AsVectorType()->Yield().get(), false) )
! same_type(element->GetType().get(), GetType()->AsVectorType()->Yield().get(), false) )
{
Unref(element);
return false;
@ -3078,7 +3077,7 @@ bool VectorVal::Remove(unsigned int index)
bool VectorVal::AddTo(Val* val, bool /* is_first_init */) const
{
if ( val->Type()->Tag() != TYPE_VECTOR )
if ( val->GetType()->Tag() != TYPE_VECTOR )
{
val->Error("not a vector");
return false;
@ -3086,9 +3085,9 @@ bool VectorVal::AddTo(Val* val, bool /* is_first_init */) const
VectorVal* v = val->AsVectorVal();
if ( ! same_type(type.get(), v->Type()) )
if ( ! same_type(type.get(), v->GetType().get()) )
{
type->Error("vector type clash", v->Type());
type->Error("vector type clash", v->GetType().get());
return false;
}
@ -3127,7 +3126,7 @@ unsigned int VectorVal::ResizeAtLeast(unsigned int new_num_elements)
IntrusivePtr<Val> VectorVal::DoClone(CloneState* state)
{
auto vv = make_intrusive<VectorVal>(IntrusivePtr{NewRef{}, Type()->AsVectorType()});
auto vv = make_intrusive<VectorVal>(GetType<VectorType>());
vv->val.vector_val->reserve(val.vector_val->size());
state->NewClone(this, vv);
@ -3166,7 +3165,7 @@ IntrusivePtr<Val> check_and_promote(IntrusivePtr<Val> v, const BroType* t,
if ( ! v )
return nullptr;
BroType* vt = v->Type();
BroType* vt = v->GetType().get();
vt = flatten_type(vt);
t = flatten_type(t);
@ -3275,17 +3274,17 @@ bool same_val(const Val* /* v1 */, const Val* /* v2 */)
bool is_atomic_val(const Val* v)
{
return is_atomic_type(v->Type());
return is_atomic_type(v->GetType().get());
}
bool same_atomic_val(const Val* v1, const Val* v2)
{
// This is a very preliminary implementation of same_val(),
// true only for equal, simple atomic values of same type.
if ( v1->Type()->Tag() != v2->Type()->Tag() )
if ( v1->GetType()->Tag() != v2->GetType()->Tag() )
return false;
switch ( v1->Type()->InternalType() ) {
switch ( v1->GetType()->InternalType() ) {
case TYPE_INTERNAL_INT:
return v1->InternalInt() == v2->InternalInt();
case TYPE_INTERNAL_UNSIGNED:
@ -3362,10 +3361,10 @@ IntrusivePtr<Val> cast_value_to_type(Val* v, BroType* t)
// Always allow casting to same type. This also covers casting 'any'
// to the actual type.
if ( same_type(v->Type(), t) )
if ( same_type(v->GetType().get(), t) )
return {NewRef{}, v};
if ( same_type(v->Type(), bro_broker::DataVal::ScriptDataType()) )
if ( same_type(v->GetType().get(), bro_broker::DataVal::ScriptDataType()) )
{
auto dv = v->AsRecordVal()->Lookup(0);
@ -3388,10 +3387,10 @@ bool can_cast_value_to_type(const Val* v, BroType* t)
// Always allow casting to same type. This also covers casting 'any'
// to the actual type.
if ( same_type(v->Type(), t) )
if ( same_type(v->GetType().get(), t) )
return true;
if ( same_type(v->Type(), bro_broker::DataVal::ScriptDataType()) )
if ( same_type(v->GetType().get(), bro_broker::DataVal::ScriptDataType()) )
{
auto dv = v->AsRecordVal()->Lookup(0);

View file

@ -180,9 +180,18 @@ public:
// Remove this value from the given value (if appropriate).
virtual bool RemoveFrom(Val* v) const;
[[deprecated("Remove in v4.1. Use GetType().")]]
BroType* Type() { return type.get(); }
[[deprecated("Remove in v4.1. Use GetType().")]]
const BroType* Type() const { return type.get(); }
const IntrusivePtr<BroType>& GetType() const
{ return type; }
template <class T>
IntrusivePtr<T> GetType() const
{ return cast_intrusive<T>(type); }
#define CONST_ACCESSOR(tag, ctype, accessor, name) \
const ctype name() const \
{ \
@ -1091,7 +1100,7 @@ extern void describe_vals(const std::vector<IntrusivePtr<Val>>& vals,
extern void delete_vals(val_list* vals);
// True if the given Val* has a vector type.
inline bool is_vector(Val* v) { return v->Type()->Tag() == TYPE_VECTOR; }
inline bool is_vector(Val* v) { return v->GetType()->Tag() == TYPE_VECTOR; }
// Returns v casted to type T if the type supports that. Returns null if not.
//

View file

@ -741,10 +741,10 @@ ListVal* internal_list_val(const char* name)
if ( v )
{
if ( v->Type()->Tag() == TYPE_LIST )
if ( v->GetType()->Tag() == TYPE_LIST )
return (ListVal*) v;
else if ( v->Type()->IsSet() )
else if ( v->GetType()->IsSet() )
{
TableVal* tv = v->AsTableVal();
auto lv = tv->ToPureListVal();
@ -812,7 +812,7 @@ IntrusivePtr<Func> zeek::lookup_func(const char* name)
if ( ! v )
return nullptr;
if ( ! IsFunc(v->Type()->Tag()) )
if ( ! IsFunc(v->GetType()->Tag()) )
reporter->InternalError("Expected variable '%s' to be a function", name);
return {NewRef{}, v->AsFunc()};

View file

@ -361,7 +361,7 @@ struct val_converter {
if ( ! rval )
return nullptr;
auto t = rval->Type();
const auto& t = rval->GetType();
if ( ! t )
return nullptr;
@ -705,7 +705,7 @@ struct type_checker {
if ( ! rval )
return false;
auto t = rval->Type();
const auto& t = rval->GetType();
if ( ! t )
return false;
@ -793,7 +793,7 @@ IntrusivePtr<Val> bro_broker::data_to_val(broker::data d, BroType* type)
broker::expected<broker::data> bro_broker::val_to_data(const Val* v)
{
switch ( v->Type()->Tag() ) {
switch ( v->GetType()->Tag() ) {
case TYPE_BOOL:
return {v->AsBool()};
case TYPE_INT:
@ -843,7 +843,7 @@ broker::expected<broker::data> bro_broker::val_to_data(const Val* v)
}
case TYPE_ENUM:
{
auto enum_type = v->Type()->AsEnumType();
auto enum_type = v->GetType()->AsEnumType();
auto enum_name = enum_type->Lookup(v->AsEnum());
return {broker::enum_value(enum_name ? enum_name : "<unknown enum>")};
}
@ -884,7 +884,7 @@ broker::expected<broker::data> bro_broker::val_to_data(const Val* v)
}
case TYPE_TABLE:
{
auto is_set = v->Type()->IsSet();
auto is_set = v->GetType()->IsSet();
auto table = v->AsTable();
auto table_val = v->AsTableVal();
broker::data rval;
@ -965,7 +965,7 @@ broker::expected<broker::data> bro_broker::val_to_data(const Val* v)
{
auto rec = v->AsRecordVal();
broker::vector rval;
size_t num_fields = v->Type()->AsRecordType()->NumFields();
size_t num_fields = v->GetType()->AsRecordType()->NumFields();
rval.reserve(num_fields);
for ( auto i = 0u; i < num_fields; ++i )
@ -1007,7 +1007,7 @@ broker::expected<broker::data> bro_broker::val_to_data(const Val* v)
}
default:
reporter->Error("unsupported Broker::Data type: %s",
type_name(v->Type()->Tag()));
type_name(v->GetType()->Tag()));
break;
}

View file

@ -429,7 +429,7 @@ bool Manager::PublishIdentifier(std::string topic, std::string id)
if ( ! data )
{
Error("Failed to publish ID with unsupported type: %s (%s)",
id.c_str(), type_name(val->Type()->Tag()));
id.c_str(), type_name(val->GetType()->Tag()));
return false;
}
@ -452,7 +452,7 @@ bool Manager::PublishLogCreate(EnumVal* stream, EnumVal* writer,
if ( peer_count == 0 )
return true;
auto stream_id = stream->Type()->AsEnumType()->Lookup(stream->AsEnum());
auto stream_id = stream->GetType()->AsEnumType()->Lookup(stream->AsEnum());
if ( ! stream_id )
{
@ -461,7 +461,7 @@ bool Manager::PublishLogCreate(EnumVal* stream, EnumVal* writer,
return false;
}
auto writer_id = writer->Type()->AsEnumType()->Lookup(writer->AsEnum());
auto writer_id = writer->GetType()->AsEnumType()->Lookup(writer->AsEnum());
if ( ! writer_id )
{
@ -507,7 +507,7 @@ bool Manager::PublishLogWrite(EnumVal* stream, EnumVal* writer, string path, int
return true;
auto stream_id_num = stream->AsEnum();
auto stream_id = stream->Type()->AsEnumType()->Lookup(stream_id_num);
auto stream_id = stream->GetType()->AsEnumType()->Lookup(stream_id_num);
if ( ! stream_id )
{
@ -516,7 +516,7 @@ bool Manager::PublishLogWrite(EnumVal* stream, EnumVal* writer, string path, int
return false;
}
auto writer_id = writer->Type()->AsEnumType()->Lookup(writer->AsEnum());
auto writer_id = writer->GetType()->AsEnumType()->Lookup(writer->AsEnum());
if ( ! writer_id )
{
@ -638,7 +638,7 @@ void Manager::Error(const char* format, ...)
bool Manager::AutoPublishEvent(string topic, Val* event)
{
if ( event->Type()->Tag() != TYPE_FUNC )
if ( event->GetType()->Tag() != TYPE_FUNC )
{
Error("Broker::auto_publish must operate on an event");
return false;
@ -667,7 +667,7 @@ bool Manager::AutoPublishEvent(string topic, Val* event)
bool Manager::AutoUnpublishEvent(const string& topic, Val* event)
{
if ( event->Type()->Tag() != TYPE_FUNC )
if ( event->GetType()->Tag() != TYPE_FUNC )
{
Error("Broker::auto_event_stop must operate on an event");
return false;
@ -713,7 +713,7 @@ RecordVal* Manager::MakeEvent(val_list* args, Frame* frame)
{
// Event val must come first.
if ( arg_val->Type()->Tag() != TYPE_FUNC )
if ( arg_val->GetType()->Tag() != TYPE_FUNC )
{
Error("attempt to convert non-event into an event type");
return rval;
@ -740,10 +740,10 @@ RecordVal* Manager::MakeEvent(val_list* args, Frame* frame)
continue;
}
auto got_type = (*args)[i]->Type();
const auto& got_type = (*args)[i]->GetType();
const auto& expected_type = func->FType()->ArgTypes()->Types()[i - 1];
if ( ! same_type(got_type, expected_type.get()) )
if ( ! same_type(got_type.get(), expected_type.get()) )
{
rval->Assign(0, nullptr);
Error("event parameter #%d type mismatch, got %s, expect %s", i,
@ -754,7 +754,7 @@ RecordVal* Manager::MakeEvent(val_list* args, Frame* frame)
IntrusivePtr<RecordVal> data_val;
if ( same_type(got_type, bro_broker::DataVal::ScriptDataType()) )
if ( same_type(got_type.get(), bro_broker::DataVal::ScriptDataType()) )
data_val = {NewRef{}, (*args)[i]->AsRecordVal()};
else
data_val = make_data_val((*args)[i]);

View file

@ -24,7 +24,7 @@ std::set<std::string> val_to_topic_set(Val* val)
{
std::set<std::string> rval;
if ( val->Type()->Tag() == TYPE_STRING )
if ( val->GetType()->Tag() == TYPE_STRING )
rval.emplace(val->AsString()->CheckString());
else
{
@ -53,7 +53,7 @@ static bool publish_event_args(val_list& args, const BroString* topic,
bro_broker::Manager::ScriptScopeGuard ssg;
auto rval = false;
if ( args[0]->Type()->Tag() == TYPE_RECORD )
if ( args[0]->GetType()->Tag() == TYPE_RECORD )
rval = broker_mgr->PublishEvent(topic->CheckString(),
args[0]->AsRecordVal());
else

View file

@ -224,7 +224,7 @@ ReaderBackend* Manager::CreateBackend(ReaderFrontend* frontend, EnumVal* tag)
// Create a new input reader object to be used at whomevers leisure later on.
bool Manager::CreateStream(Stream* info, RecordVal* description)
{
RecordType* rtype = description->Type()->AsRecordType();
RecordType* rtype = description->GetType()->AsRecordType();
if ( ! ( same_type(rtype, BifType::Record::Input::TableDescription, false)
|| same_type(rtype, BifType::Record::Input::EventDescription, false)
|| same_type(rtype, BifType::Record::Input::AnalysisDescription, false) ) )
@ -310,7 +310,7 @@ bool Manager::CreateStream(Stream* info, RecordVal* description)
bool Manager::CreateEventStream(RecordVal* fval)
{
RecordType* rtype = fval->Type()->AsRecordType();
RecordType* rtype = fval->GetType()->AsRecordType();
if ( ! same_type(rtype, BifType::Record::Input::EventDescription, false) )
{
reporter->Error("EventDescription argument not of right type");
@ -463,7 +463,7 @@ bool Manager::CreateEventStream(RecordVal* fval)
bool Manager::CreateTableStream(RecordVal* fval)
{
RecordType* rtype = fval->Type()->AsRecordType();
RecordType* rtype = fval->GetType()->AsRecordType();
if ( ! same_type(rtype, BifType::Record::Input::TableDescription, false) )
{
reporter->Error("TableDescription argument not of right type");
@ -486,7 +486,7 @@ bool Manager::CreateTableStream(RecordVal* fval)
// check if index fields match table description
int num = idx->NumFields();
const auto& tl = dst->Type()->AsTableType()->IndexTypes();
const auto& tl = dst->GetType()->AsTableType()->IndexTypes();
int j;
for ( j = 0; j < static_cast<int>(tl.size()); ++j )
@ -522,7 +522,7 @@ bool Manager::CreateTableStream(RecordVal* fval)
if ( val )
{
const auto& table_yield = dst->Type()->AsTableType()->Yield();
const auto& table_yield = dst->GetType()->AsTableType()->Yield();
const BroType* compare_type = val.get();
if ( want_record->InternalInt() == 0 )
@ -541,7 +541,7 @@ bool Manager::CreateTableStream(RecordVal* fval)
}
else
{
if ( ! dst->Type()->IsSet() )
if ( ! dst->GetType()->IsSet() )
{
reporter->Error("Input stream %s: 'destination' field is a table,"
" but 'val' field is not provided"
@ -748,7 +748,7 @@ bool Manager::CheckErrorEventTypes(const std::string& stream_name, const Func* e
bool Manager::CreateAnalysisStream(RecordVal* fval)
{
RecordType* rtype = fval->Type()->AsRecordType();
RecordType* rtype = fval->GetType()->AsRecordType();
if ( ! same_type(rtype, BifType::Record::Input::AnalysisDescription, false) )
{
@ -955,7 +955,7 @@ bool Manager::UnrollRecordType(vector<Field*> *fields, const RecordType *rec,
c = rec->FieldDecl(i)->FindAttr(ATTR_TYPE_COLUMN)->AttrExpr()->Eval(nullptr);
assert(c);
assert(c->Type()->Tag() == TYPE_STRING);
assert(c->GetType()->Tag() == TYPE_STRING);
secondary = c->AsStringVal()->AsString()->CheckString();
}
@ -1000,7 +1000,7 @@ Val* Manager::RecordValToIndexVal(RecordVal *r) const
{
IntrusivePtr<Val> idxval;
RecordType *type = r->Type()->AsRecordType();
RecordType *type = r->GetType()->AsRecordType();
int num_fields = type->NumFields();
@ -1845,10 +1845,10 @@ bool Manager::SendEvent(ReaderFrontend* reader, const string& name, const int nu
Val* v = ValueToVal(i, vals[j], convert_error);
vl.emplace_back(AdoptRef{}, v);
if ( v && ! convert_error && ! same_type(type->GetFieldType(j).get(), v->Type()) )
if ( v && ! convert_error && ! same_type(type->GetFieldType(j).get(), v->GetType().get()) )
{
convert_error = true;
type->GetFieldType(j)->Error("SendEvent types do not match", v->Type());
type->GetFieldType(j)->Error("SendEvent types do not match", v->GetType().get());
}
}

View file

@ -39,7 +39,7 @@ ReaderFrontend::ReaderFrontend(const ReaderBackend::ReaderInfo& arg_info, EnumVa
disabled = initialized = false;
info = new ReaderBackend::ReaderInfo(arg_info);
const char* t = type->Type()->AsEnumType()->Lookup(type->InternalInt());
const char* t = type->GetType()->AsEnumType()->Lookup(type->InternalInt());
name = copy_string(fmt("%s/%s", arg_info.source, t));
backend = input_mgr->CreateBackend(this, type);

View file

@ -229,7 +229,7 @@ void Manager::RemoveDisabledWriters(Stream* stream)
bool Manager::CreateStream(EnumVal* id, RecordVal* sval)
{
RecordType* rtype = sval->Type()->AsRecordType();
RecordType* rtype = sval->GetType()->AsRecordType();
if ( ! same_type(rtype, BifType::Record::Log::Stream, false) )
{
@ -309,7 +309,7 @@ bool Manager::CreateStream(EnumVal* id, RecordVal* sval)
streams[idx] = new Stream;
streams[idx]->id = id->Ref()->AsEnumVal();
streams[idx]->enabled = true;
streams[idx]->name = id->Type()->AsEnumType()->Lookup(idx);
streams[idx]->name = id->GetType()->AsEnumType()->Lookup(idx);
streams[idx]->event = event ? event_registry->Lookup(event->Name()) : nullptr;
streams[idx]->columns = columns->Ref()->AsRecordType();
@ -532,7 +532,7 @@ bool Manager::TraverseRecord(Stream* stream, Filter* filter, RecordType* rt,
bool Manager::AddFilter(EnumVal* id, RecordVal* fval)
{
RecordType* rtype = fval->Type()->AsRecordType();
RecordType* rtype = fval->GetType()->AsRecordType();
if ( ! same_type(rtype, BifType::Record::Log::Filter, false) )
{
@ -759,7 +759,7 @@ bool Manager::Write(EnumVal* id, RecordVal* columns_arg)
if ( ! v )
return false;
if ( v->Type()->Tag() != TYPE_STRING )
if ( v->GetType()->Tag() != TYPE_STRING )
{
reporter->Error("path_func did not return string");
return false;
@ -826,7 +826,7 @@ bool Manager::Write(EnumVal* id, RecordVal* columns_arg)
auto wi = w->second;
wi->hook_initialized = true;
PLUGIN_HOOK_VOID(HOOK_LOG_INIT,
HookLogInit(filter->writer->Type()->AsEnumType()->Lookup(filter->writer->InternalInt()),
HookLogInit(filter->writer->GetType()->AsEnumType()->Lookup(filter->writer->InternalInt()),
wi->instantiating_filter, filter->local,
filter->remote, *wi->info,
filter->num_fields,
@ -891,7 +891,7 @@ bool Manager::Write(EnumVal* id, RecordVal* columns_arg)
threading::Value** vals = RecordToFilterVals(stream, filter, columns.get());
if ( ! PLUGIN_HOOK_WITH_RESULT(HOOK_LOG_WRITE,
HookLogWrite(filter->writer->Type()->AsEnumType()->Lookup(filter->writer->InternalInt()),
HookLogWrite(filter->writer->GetType()->AsEnumType()->Lookup(filter->writer->InternalInt()),
filter->name, *info,
filter->num_fields,
filter->fields, vals),
@ -922,7 +922,7 @@ bool Manager::Write(EnumVal* id, RecordVal* columns_arg)
threading::Value* Manager::ValToLogVal(Val* val, BroType* ty)
{
if ( ! ty )
ty = val->Type();
ty = val->GetType().get();
if ( ! val )
return new threading::Value(ty->Tag(), false);
@ -938,7 +938,7 @@ threading::Value* Manager::ValToLogVal(Val* val, BroType* ty)
case TYPE_ENUM:
{
const char* s =
val->Type()->AsEnumType()->Lookup(val->InternalInt());
val->GetType()->AsEnumType()->Lookup(val->InternalInt());
if ( s )
{
@ -948,7 +948,7 @@ threading::Value* Manager::ValToLogVal(Val* val, BroType* ty)
else
{
val->Type()->Error("enum type does not contain value", val);
val->GetType()->Error("enum type does not contain value", val);
lval->val.string_val.data = copy_string("");
lval->val.string_val.length = 0;
}
@ -1038,7 +1038,7 @@ threading::Value* Manager::ValToLogVal(Val* val, BroType* ty)
{
lval->val.vector_val.vals[i] =
ValToLogVal(vec->Lookup(i),
vec->Type()->Yield().get());
vec->GetType()->Yield().get());
}
break;
@ -1206,7 +1206,7 @@ WriterFrontend* Manager::CreateWriter(EnumVal* id, EnumVal* writer, WriterBacken
{
winfo->hook_initialized = true;
PLUGIN_HOOK_VOID(HOOK_LOG_INIT,
HookLogInit(writer->Type()->AsEnumType()->Lookup(writer->InternalInt()),
HookLogInit(writer->GetType()->AsEnumType()->Lookup(writer->InternalInt()),
instantiating_filter, local, remote,
*winfo->info, num_fields, fields));
}

View file

@ -116,7 +116,7 @@ WriterFrontend::WriterFrontend(const WriterBackend::WriterInfo& arg_info, EnumVa
num_fields = 0;
fields = nullptr;
const char* w = arg_writer->Type()->AsEnumType()->Lookup(arg_writer->InternalInt());
const char* w = arg_writer->GetType()->AsEnumType()->Lookup(arg_writer->InternalInt());
name = copy_string(fmt("%s/%s", arg_info.path, w));
if ( local )

View file

@ -79,7 +79,7 @@ function Option::set%(ID: string, val: any, location: string &default=""%): bool
return val_mgr->False();
}
if ( same_type(val->Type(), bro_broker::DataVal::ScriptDataType()) )
if ( same_type(val->GetType().get(), bro_broker::DataVal::ScriptDataType()) )
{
auto dv = static_cast<bro_broker::DataVal*>(val->AsRecordVal()->Lookup(0));
auto val_from_data = dv->castTo(i->GetType().get());
@ -95,11 +95,11 @@ function Option::set%(ID: string, val: any, location: string &default=""%): bool
return val_mgr->Bool(rval);
}
if ( ! same_type(i->GetType().get(), val->Type()) )
if ( ! same_type(i->GetType().get(), val->GetType().get()) )
{
if ( i->GetType()->Tag() == TYPE_TABLE &&
val->Type()->Tag() == TYPE_TABLE &&
val->Type()->AsTableType()->IsUnspecifiedTable() )
val->GetType()->Tag() == TYPE_TABLE &&
val->GetType()->AsTableType()->IsUnspecifiedTable() )
{
// Just coerce an empty/unspecified table to the right type.
auto tv = make_intrusive<TableVal>(
@ -110,7 +110,7 @@ function Option::set%(ID: string, val: any, location: string &default=""%): bool
}
builtin_error(fmt("Incompatible type for set of ID '%s': got '%s', need '%s'",
ID->CheckString(), type_name(val->Type()->Tag()), type_name(i->GetType()->Tag())));
ID->CheckString(), type_name(val->GetType()->Tag()), type_name(i->GetType()->Tag())));
return val_mgr->False();
}
@ -157,20 +157,20 @@ function Option::set_change_handler%(ID: string, on_change: any, priority: int &
return val_mgr->False();
}
if ( on_change->Type()->Tag() != TYPE_FUNC )
if ( on_change->GetType()->Tag() != TYPE_FUNC )
{
builtin_error(fmt("Option::on_change needs function argument; got '%s' for ID '%s'",
type_name(on_change->Type()->Tag()), ID->CheckString()));
type_name(on_change->GetType()->Tag()), ID->CheckString()));
return val_mgr->False();
}
if ( on_change->Type()->AsFuncType()->Flavor() != FUNC_FLAVOR_FUNCTION )
if ( on_change->GetType()->AsFuncType()->Flavor() != FUNC_FLAVOR_FUNCTION )
{
builtin_error("Option::on_change needs function argument; not hook or event");
return val_mgr->False();
}
const auto& args = on_change->Type()->AsFuncType()->ArgTypes()->Types();
const auto& args = on_change->GetType()->AsFuncType()->ArgTypes()->Types();
if ( args.size() < 2 || args.size() > 3 )
{
builtin_error(fmt("Wrong number of arguments for passed function in Option::on_change for ID '%s'; expected 2 or 3, got %zu",
@ -199,10 +199,10 @@ function Option::set_change_handler%(ID: string, on_change: any, priority: int &
return val_mgr->False();
}
if ( ! same_type(on_change->Type()->AsFuncType()->Yield().get(), i->GetType().get()) )
if ( ! same_type(on_change->GetType()->AsFuncType()->Yield().get(), i->GetType().get()) )
{
builtin_error(fmt("Passed function needs to return type '%s' for ID '%s'; got '%s'",
type_name(i->GetType()->Tag()), ID->CheckString(), type_name(on_change->Type()->AsFuncType()->Yield()->Tag())));
type_name(i->GetType()->Tag()), ID->CheckString(), type_name(on_change->GetType()->AsFuncType()->Yield()->Tag())));
return val_mgr->False();
}

View file

@ -813,7 +813,7 @@ enum_body_elem:
set_location(@1, @3);
assert(cur_enum_type);
if ( $3->Type()->Tag() != TYPE_COUNT )
if ( $3->GetType()->Tag() != TYPE_COUNT )
reporter->Error("enumerator is not a count constant");
else
cur_enum_type->AddName(current_module, $1,
@ -1382,7 +1382,7 @@ attr:
{ $$ = new Attr(ATTR_DEPRECATED); }
| TOK_ATTR_DEPRECATED '=' TOK_CONSTANT
{
if ( IsString($3->Type()->Tag()) )
if ( IsString($3->GetType()->Tag()) )
$$ = new Attr(ATTR_DEPRECATED, make_intrusive<ConstExpr>(IntrusivePtr{AdoptRef{}, $3}));
else
{
@ -1869,7 +1869,7 @@ opt_deprecated:
|
TOK_ATTR_DEPRECATED '=' TOK_CONSTANT
{
if ( IsString($3->Type()->Tag()) )
if ( IsString($3->GetType()->Tag()) )
$$ = new ConstExpr({AdoptRef{}, $3});
else
{

View file

@ -284,9 +284,9 @@ void TopkVal::Encountered(Val* encountered)
// ok, let's see if we already know this one.
if ( numElements == 0 )
Typify(encountered->Type());
Typify(encountered->GetType().get());
else
if ( ! same_type(type, encountered->Type()) )
if ( ! same_type(type, encountered->GetType().get()) )
{
reporter->Error("Trying to add element to topk with differing type from other elements");
return;

View file

@ -146,10 +146,10 @@ function bloomfilter_add%(bf: opaque of bloomfilter, x: any%): any
%{
BloomFilterVal* bfv = static_cast<BloomFilterVal*>(bf);
if ( ! bfv->Type() && ! bfv->Typify(x->Type()) )
if ( ! bfv->Type() && ! bfv->Typify(x->GetType().get()) )
reporter->Error("failed to set Bloom filter type");
else if ( ! same_type(bfv->Type(), x->Type()) )
else if ( ! same_type(bfv->Type(), x->GetType().get()) )
reporter->Error("incompatible Bloom filter types");
else
@ -176,7 +176,7 @@ function bloomfilter_lookup%(bf: opaque of bloomfilter, x: any%): count
if ( ! bfv->Type() )
return val_mgr->Count(0);
else if ( ! same_type(bfv->Type(), x->Type()) )
else if ( ! same_type(bfv->Type(), x->GetType().get()) )
reporter->Error("incompatible Bloom filter types");
else

View file

@ -42,13 +42,13 @@ function hll_cardinality_add%(handle: opaque of cardinality, elem: any%): bool
%{
CardinalityVal* cv = static_cast<CardinalityVal*>(handle);
if ( ! cv->Type() && ! cv->Typify(elem->Type()) )
if ( ! cv->Type() && ! cv->Typify(elem->GetType().get()) )
{
reporter->Error("failed to set HLL type");
return val_mgr->False();
}
else if ( ! same_type(cv->Type(), elem->Type()) )
else if ( ! same_type(cv->Type(), elem->GetType().get()) )
{
reporter->Error("incompatible HLL data type");
return val_mgr->False();

View file

@ -1003,7 +1003,7 @@ int yywrap()
auto param_id = lookup_ID(param, GLOBAL_MODULE_NAME);
Val* v = param_id ? param_id->GetVal().get() : nullptr;
if ( v && v->Type() && v->Type()->Tag() == TYPE_STRING )
if ( v && v->GetType() && v->GetType()->Tag() == TYPE_STRING )
opt_quote = "\""; // use quotes
policy += std::string("redef ") + param + "="

View file

@ -69,8 +69,8 @@ static int check_fmt_type(TypeTag t, TypeTag ok[])
static void do_fmt(const char*& fmt, Val* v, ODesc* d)
{
TypeTag t = v->Type()->Tag();
InternalTypeTag it = v->Type()->InternalType();
TypeTag t = v->GetType()->Tag();
InternalTypeTag it = v->GetType()->InternalType();
bool zero_pad = false;
bool left_just = false;
@ -199,9 +199,9 @@ static void do_fmt(const char*& fmt, Val* v, ODesc* d)
{
bro_uint_t u = v->CoerceToUnsigned();
if ( v->Type()->IsNetworkOrder() )
if ( v->GetType()->IsNetworkOrder() )
{
if ( v->Type()->Tag() == TYPE_PORT )
if ( v->GetType()->Tag() == TYPE_PORT )
u = v->AsPortVal()->Port();
else
u = ntohl(uint32_t(u));
@ -409,8 +409,8 @@ static bool prepare_environment(TableVal* tbl, bool set)
const auto& key = idxs->Idx(i);
auto val = tbl->Lookup(key.get(), false);
if ( key->Type()->Tag() != TYPE_STRING ||
val->Type()->Tag() != TYPE_STRING )
if ( key->GetType()->Tag() != TYPE_STRING ||
val->GetType()->Tag() != TYPE_STRING )
{
builtin_error("system_env() needs a table[string] of string");
return false;
@ -488,7 +488,7 @@ function system%(str: string%): int
## .. zeek:see:: system safe_shell_quote piped_exec
function system_env%(str: string, env: table_string_of_string%): int
%{
if ( env->Type()->Tag() != TYPE_TABLE )
if ( env->GetType()->Tag() != TYPE_TABLE )
{
builtin_error("system_env() requires a table argument");
return val_mgr->Int(-1);
@ -804,8 +804,8 @@ function sha256_hash_finish%(handle: opaque of sha256%): string
## .. zeek:see::paraglob_match paraglob_equals paraglob_add
function paraglob_init%(v: any%) : opaque of paraglob
%{
if ( v->Type()->Tag() != TYPE_VECTOR ||
v->Type()->Yield()->Tag() != TYPE_STRING )
if ( v->GetType()->Tag() != TYPE_VECTOR ||
v->GetType()->Yield()->Tag() != TYPE_STRING )
{
// reporter->Error will throw an exception.
reporter->Error("paraglob requires a vector of strings for initialization.");
@ -1155,7 +1155,7 @@ function unique_id_from%(pool: int, prefix: string%) : string
## v: The set or table
function clear_table%(v: any%): any
%{
if ( v->Type()->Tag() == TYPE_TABLE )
if ( v->GetType()->Tag() == TYPE_TABLE )
v->AsTableVal()->RemoveAll();
else
builtin_error("clear_table() requires a table/set argument");
@ -1172,7 +1172,7 @@ function clear_table%(v: any%): any
## Returns: All the keys of the set or table that cover the subnet searched for.
function matching_subnets%(search: subnet, t: any%): subnet_vec
%{
if ( t->Type()->Tag() != TYPE_TABLE || ! t->Type()->AsTableType()->IsSubNetIndex() )
if ( t->GetType()->Tag() != TYPE_TABLE || ! t->GetType()->AsTableType()->IsSubNetIndex() )
{
reporter->Error("matching_subnets needs to be called on a set[subnet]/table[subnet].");
return nullptr;
@ -1191,7 +1191,7 @@ function matching_subnets%(search: subnet, t: any%): subnet_vec
## Returns: A new table that contains all the entries that cover the subnet searched for.
function filter_subnet_table%(search: subnet, t: any%): any
%{
if ( t->Type()->Tag() != TYPE_TABLE || ! t->Type()->AsTableType()->IsSubNetIndex() )
if ( t->GetType()->Tag() != TYPE_TABLE || ! t->GetType()->AsTableType()->IsSubNetIndex() )
{
reporter->Error("filter_subnet_table needs to be called on a set[subnet]/table[subnet].");
return nullptr;
@ -1211,7 +1211,7 @@ function filter_subnet_table%(search: subnet, t: any%): any
## Returns: True if the exact subnet is a member, false otherwise.
function check_subnet%(search: subnet, t: any%): bool
%{
if ( t->Type()->Tag() != TYPE_TABLE || ! t->Type()->AsTableType()->IsSubNetIndex() )
if ( t->GetType()->Tag() != TYPE_TABLE || ! t->GetType()->AsTableType()->IsSubNetIndex() )
{
reporter->Error("check_subnet needs to be called on a set[subnet]/table[subnet].");
return nullptr;
@ -1262,7 +1262,7 @@ function val_size%(v: any%): count
## Returns: The old size of *aggr*, or 0 if *aggr* is not a :zeek:type:`vector`.
function resize%(aggr: any, newsize: count%) : count
%{
if ( aggr->Type()->Tag() != TYPE_VECTOR )
if ( aggr->GetType()->Tag() != TYPE_VECTOR )
{
builtin_error("resize() operates on vectors");
return nullptr;
@ -1281,8 +1281,8 @@ function resize%(aggr: any, newsize: count%) : count
## .. zeek:see:: all_set
function any_set%(v: any%) : bool
%{
if ( v->Type()->Tag() != TYPE_VECTOR ||
v->Type()->Yield()->Tag() != TYPE_BOOL )
if ( v->GetType()->Tag() != TYPE_VECTOR ||
v->GetType()->Yield()->Tag() != TYPE_BOOL )
{
builtin_error("any_set() requires vector of bool");
return val_mgr->False();
@ -1310,8 +1310,8 @@ function any_set%(v: any%) : bool
## Missing elements count as false.
function all_set%(v: any%) : bool
%{
if ( v->Type()->Tag() != TYPE_VECTOR ||
v->Type()->Yield()->Tag() != TYPE_BOOL )
if ( v->GetType()->Tag() != TYPE_VECTOR ||
v->GetType()->Yield()->Tag() != TYPE_BOOL )
{
builtin_error("all_set() requires vector of bool");
return val_mgr->False();
@ -1403,13 +1403,13 @@ function sort%(v: any, ...%) : any
%{
IntrusivePtr<Val> rval{NewRef{}, v};
if ( v->Type()->Tag() != TYPE_VECTOR )
if ( v->GetType()->Tag() != TYPE_VECTOR )
{
builtin_error("sort() requires vector");
return rval;
}
const auto& elt_type = v->Type()->Yield();
const auto& elt_type = v->GetType()->Yield();
Func* comp = 0;
if ( @ARG@.size() > 2 )
@ -1418,7 +1418,7 @@ function sort%(v: any, ...%) : any
if ( @ARG@.size() == 2 )
{
Val* comp_val = @ARG@[1].get();
if ( ! IsFunc(comp_val->Type()->Tag()) )
if ( ! IsFunc(comp_val->GetType()->Tag()) )
{
builtin_error("second argument to sort() needs to be comparison function");
return rval;
@ -1472,13 +1472,13 @@ function order%(v: any, ...%) : index_vec
%{
auto result_v = make_intrusive<VectorVal>(lookup_type<VectorType>("index_vec"));
if ( v->Type()->Tag() != TYPE_VECTOR )
if ( v->GetType()->Tag() != TYPE_VECTOR )
{
builtin_error("order() requires vector");
return result_v;
}
const auto& elt_type = v->Type()->Yield();
const auto& elt_type = v->GetType()->Yield();
Func* comp = 0;
if ( @ARG@.size() > 2 )
@ -1487,7 +1487,7 @@ function order%(v: any, ...%) : index_vec
if ( @ARG@.size() == 2 )
{
Val* comp_val = @ARG@[1].get();
if ( ! IsFunc(comp_val->Type()->Tag()) )
if ( ! IsFunc(comp_val->GetType()->Tag()) )
{
builtin_error("second argument to order() needs to be comparison function");
return IntrusivePtr<Val>{NewRef{}, v};
@ -1603,7 +1603,7 @@ function cat_sep%(sep: string, def: string, ...%): string
d.Add(sep->CheckString(), 0);
Val* v = @ARG@[i].get();
if ( v->Type()->Tag() == TYPE_STRING && ! v->AsString()->Len() )
if ( v->GetType()->Tag() == TYPE_STRING && ! v->AsString()->Len() )
v = def;
v->Describe(&d);
@ -1842,7 +1842,7 @@ function record_type_to_vector%(rt: string%): string_vec
function type_name%(t: any%): string
%{
ODesc d;
t->Type()->Describe(&d);
t->GetType()->Describe(&d);
BroString* s = new BroString(1, d.TakeBytes(), d.Len());
s->SetUseFreeToDelete(true);
@ -1992,7 +1992,7 @@ function lookup_ID%(id: string%) : any
## Returns: A table that describes the fields of a record.
function record_fields%(rec: any%): record_field_table
%{
if ( rec->Type()->Tag() == TYPE_STRING )
if ( rec->GetType()->Tag() == TYPE_STRING )
{
auto id = global_scope()->Lookup(rec->AsStringVal()->ToStdString());
@ -2264,7 +2264,7 @@ function counts_to_addr%(v: index_vec%): addr
## Returns: The :zeek:type:`int` value that corresponds to the :zeek:type:`enum`.
function enum_to_int%(e: any%): int
%{
if ( e->Type()->Tag() != TYPE_ENUM )
if ( e->GetType()->Tag() != TYPE_ENUM )
{
builtin_error("enum_to_int() requires enum value");
return val_mgr->Int(-1);