diff --git a/src/Expr.cc b/src/Expr.cc index a7903ad6cc..527bcb394b 100644 --- a/src/Expr.cc +++ b/src/Expr.cc @@ -4528,10 +4528,10 @@ IntrusivePtr ListExpr::InitType() const ti->AsTypeList(); if ( ! til->IsPure() || - ! til->AllMatch(til->PureType(), true) ) + ! til->AllMatch(til->GetPureType(), true) ) tl->Append({NewRef{}, til}); else - tl->Append({NewRef{}, til->PureType()}); + tl->Append(til->GetPureType()); } else tl->Append({NewRef{}, ti}); diff --git a/src/Type.cc b/src/Type.cc index a9b93f0036..14d922f256 100644 --- a/src/Type.cc +++ b/src/Type.cc @@ -1664,7 +1664,7 @@ const BroType* flatten_type(const BroType* t) const TypeList* tl = t->AsTypeList(); if ( tl->IsPure() ) - return tl->PureType(); + return tl->GetPureType().get(); const type_list* types = tl->Types(); diff --git a/src/Type.h b/src/Type.h index 2b077146e4..eebb27dc12 100644 --- a/src/Type.h +++ b/src/Type.h @@ -362,13 +362,20 @@ public: // Returns the underlying pure type, or nil if the list // is not pure or is empty. + const IntrusivePtr& GetPureType() const + { return pure_type; } + + [[deprecated("Remove in v4.1. Use GetPureType() instead.")]] BroType* PureType() { return pure_type.get(); } + [[deprecated("Remove in v4.1. Use GetPureType() instead.")]] const BroType* PureType() const { return pure_type.get(); } // True if all of the types match t, false otherwise. If // is_init is true, then the matching is done in the context // of an initialization. bool AllMatch(const BroType* t, bool is_init) const; + bool AllMatch(const IntrusivePtr& t, bool is_init) const + { return AllMatch(t.get(), is_init); } void Append(IntrusivePtr t); void AppendEvenIfNotPure(IntrusivePtr t); diff --git a/src/Val.cc b/src/Val.cc index 925a1c4c76..226ea376f0 100644 --- a/src/Val.cc +++ b/src/Val.cc @@ -1235,8 +1235,8 @@ IntrusivePtr ListVal::ToSetVal() const if ( tag == TYPE_ANY ) Internal("conversion of heterogeneous list to set"); - auto set_index = make_intrusive( - IntrusivePtr{NewRef{}, type->AsTypeList()->PureType()}); + const auto& pt = type->AsTypeList()->GetPureType(); + auto set_index = make_intrusive(pt); set_index->Append(base_type(tag)); auto s = make_intrusive(std::move(set_index), nullptr); auto t = make_intrusive(std::move(s)); diff --git a/src/input/Manager.cc b/src/input/Manager.cc index 250b790893..fedac9fcbe 100644 --- a/src/input/Manager.cc +++ b/src/input/Manager.cc @@ -812,7 +812,7 @@ bool Manager::IsCompatibleType(BroType* t, bool atomic_only) if ( ! t->IsSet() ) return false; - return IsCompatibleType(t->AsSetType()->Indices()->PureType(), true); + return IsCompatibleType(t->AsSetType()->Indices()->GetPureType().get(), true); } case TYPE_VECTOR: @@ -941,7 +941,7 @@ bool Manager::UnrollRecordType(vector *fields, const RecordType *rec, bool optional = false; if ( ty == TYPE_TABLE ) - st = rec->FieldType(i)->AsSetType()->Indices()->PureType()->Tag(); + st = rec->FieldType(i)->AsSetType()->Indices()->GetPureType()->Tag(); else if ( ty == TYPE_VECTOR ) st = rec->FieldType(i)->AsVectorType()->YieldType()->Tag(); @@ -2334,14 +2334,14 @@ Val* Manager::ValueToVal(const Stream* i, const Value* val, BroType* request_typ case TYPE_TABLE: { // all entries have to have the same type... - BroType* type = request_type->AsTableType()->Indices()->PureType(); - auto set_index = make_intrusive(IntrusivePtr{NewRef{}, type}); - set_index->Append({NewRef{}, type}); + const auto& type = request_type->AsTableType()->Indices()->GetPureType(); + auto set_index = make_intrusive(type); + set_index->Append(type); auto s = make_intrusive(std::move(set_index), nullptr); TableVal* t = new TableVal(std::move(s)); for ( int j = 0; j < val->val.set_val.size; j++ ) { - Val* assignval = ValueToVal(i, val->val.set_val.vals[j], type, have_error); + Val* assignval = ValueToVal(i, val->val.set_val.vals[j], type.get(), have_error); t->Assign(assignval, nullptr); Unref(assignval); // index is not consumed by assign. diff --git a/src/input/readers/config/Config.cc b/src/input/readers/config/Config.cc index f31226a69b..22433453fe 100644 --- a/src/input/readers/config/Config.cc +++ b/src/input/readers/config/Config.cc @@ -45,7 +45,7 @@ Config::Config(ReaderFrontend *frontend) : ReaderBackend(frontend) TypeTag primary = id->Type()->Tag(); TypeTag secondary = TYPE_VOID; if ( primary == TYPE_TABLE ) - secondary = id->Type()->AsSetType()->Indices()->PureType()->Tag(); + secondary = id->Type()->AsSetType()->Indices()->GetPureType()->Tag(); else if ( primary == TYPE_VECTOR ) secondary = id->Type()->AsVectorType()->YieldType()->Tag(); diff --git a/src/logging/Manager.cc b/src/logging/Manager.cc index a09c0fa0d4..8bb3ab1ce7 100644 --- a/src/logging/Manager.cc +++ b/src/logging/Manager.cc @@ -517,7 +517,7 @@ bool Manager::TraverseRecord(Stream* stream, Filter* filter, RecordType* rt, TypeTag st = TYPE_VOID; if ( t->Tag() == TYPE_TABLE ) - st = t->AsSetType()->Indices()->PureType()->Tag(); + st = t->AsSetType()->Indices()->GetPureType()->Tag(); else if ( t->Tag() == TYPE_VECTOR ) st = t->AsVectorType()->YieldType()->Tag(); diff --git a/src/threading/SerialTypes.cc b/src/threading/SerialTypes.cc index a115c37351..2d39fecf51 100644 --- a/src/threading/SerialTypes.cc +++ b/src/threading/SerialTypes.cc @@ -146,7 +146,7 @@ bool Value::IsCompatibleType(BroType* t, bool atomic_only) if ( ! t->IsSet() ) return false; - return IsCompatibleType(t->AsSetType()->Indices()->PureType(), true); + return IsCompatibleType(t->AsSetType()->Indices()->GetPureType().get(), true); } case TYPE_VECTOR: