mirror of
https://github.com/zeek/zeek.git
synced 2025-10-04 15:48:19 +00:00
Deprecate TypeList::PureType(), replace with TypeList::GetPureType()
This commit is contained in:
parent
9ab7150883
commit
011866a908
8 changed files with 21 additions and 14 deletions
|
@ -4528,10 +4528,10 @@ IntrusivePtr<BroType> 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});
|
||||
|
|
|
@ -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();
|
||||
|
||||
|
|
|
@ -362,13 +362,20 @@ public:
|
|||
|
||||
// Returns the underlying pure type, or nil if the list
|
||||
// is not pure or is empty.
|
||||
const IntrusivePtr<BroType>& 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<BroType>& t, bool is_init) const
|
||||
{ return AllMatch(t.get(), is_init); }
|
||||
|
||||
void Append(IntrusivePtr<BroType> t);
|
||||
void AppendEvenIfNotPure(IntrusivePtr<BroType> t);
|
||||
|
|
|
@ -1235,8 +1235,8 @@ IntrusivePtr<TableVal> ListVal::ToSetVal() const
|
|||
if ( tag == TYPE_ANY )
|
||||
Internal("conversion of heterogeneous list to set");
|
||||
|
||||
auto set_index = make_intrusive<TypeList>(
|
||||
IntrusivePtr{NewRef{}, type->AsTypeList()->PureType()});
|
||||
const auto& pt = type->AsTypeList()->GetPureType();
|
||||
auto set_index = make_intrusive<TypeList>(pt);
|
||||
set_index->Append(base_type(tag));
|
||||
auto s = make_intrusive<SetType>(std::move(set_index), nullptr);
|
||||
auto t = make_intrusive<TableVal>(std::move(s));
|
||||
|
|
|
@ -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<Field*> *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<TypeList>(IntrusivePtr{NewRef{}, type});
|
||||
set_index->Append({NewRef{}, type});
|
||||
const auto& type = request_type->AsTableType()->Indices()->GetPureType();
|
||||
auto set_index = make_intrusive<TypeList>(type);
|
||||
set_index->Append(type);
|
||||
auto s = make_intrusive<SetType>(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.
|
||||
|
|
|
@ -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();
|
||||
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue