mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 14:48:21 +00:00
GH-1034: Revert TypeList::Types() back to return a type_list* and mark it deprecated
This commit is contained in:
parent
a5a51de3c4
commit
e1338cc379
15 changed files with 82 additions and 71 deletions
3
NEWS
3
NEWS
|
@ -100,9 +100,6 @@ Changed Functionality
|
||||||
- The DCE/RPC operation string of "NetrLogonSamLogonWithFlags" has been
|
- The DCE/RPC operation string of "NetrLogonSamLogonWithFlags" has been
|
||||||
corrected from "NetrLogonSameLogonWithFlags".
|
corrected from "NetrLogonSameLogonWithFlags".
|
||||||
|
|
||||||
- ``TypeList::Types()`` and ``IndexType::IndexTypes()`` now return an
|
|
||||||
``std::vector`` instead of ``type_list*``
|
|
||||||
|
|
||||||
- ``AsRecord()`` and ``AsNonConstRecord()`` have changed to return
|
- ``AsRecord()`` and ``AsNonConstRecord()`` have changed to return
|
||||||
``std::vector<IntrusivePtr<Val>>*``.
|
``std::vector<IntrusivePtr<Val>>*``.
|
||||||
|
|
||||||
|
|
10
src/Attr.cc
10
src/Attr.cc
|
@ -394,7 +394,7 @@ void Attributes::CheckAttr(Attr* a)
|
||||||
if ( atype->Tag() == TYPE_FUNC )
|
if ( atype->Tag() == TYPE_FUNC )
|
||||||
{
|
{
|
||||||
FuncType* f = atype->AsFuncType();
|
FuncType* f = atype->AsFuncType();
|
||||||
if ( ! f->CheckArgs(tt->IndexTypes()) ||
|
if ( ! f->CheckArgs(tt->GetIndexTypes()) ||
|
||||||
! same_type(f->Yield(), ytype) )
|
! same_type(f->Yield(), ytype) )
|
||||||
Error("&default function type clash");
|
Error("&default function type clash");
|
||||||
|
|
||||||
|
@ -517,7 +517,7 @@ void Attributes::CheckAttr(Attr* a)
|
||||||
if (the_table->IsUnspecifiedTable())
|
if (the_table->IsUnspecifiedTable())
|
||||||
break;
|
break;
|
||||||
|
|
||||||
const auto& func_index_types = e_ft->ParamList()->Types();
|
const auto& func_index_types = e_ft->ParamList()->GetTypes();
|
||||||
// Keep backwards compatibility with idx: any idiom.
|
// Keep backwards compatibility with idx: any idiom.
|
||||||
if ( func_index_types.size() == 2 )
|
if ( func_index_types.size() == 2 )
|
||||||
{
|
{
|
||||||
|
@ -525,7 +525,7 @@ void Attributes::CheckAttr(Attr* a)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto& table_index_types = the_table->IndexTypes();
|
const auto& table_index_types = the_table->GetIndexTypes();
|
||||||
|
|
||||||
type_list expected_args(1 + static_cast<int>(table_index_types.size()));
|
type_list expected_args(1 + static_cast<int>(table_index_types.size()));
|
||||||
expected_args.push_back(type->AsTableType());
|
expected_args.push_back(type->AsTableType());
|
||||||
|
@ -564,8 +564,8 @@ void Attributes::CheckAttr(Attr* a)
|
||||||
if ( the_table->IsUnspecifiedTable() )
|
if ( the_table->IsUnspecifiedTable() )
|
||||||
break;
|
break;
|
||||||
|
|
||||||
const auto& args = c_ft->ParamList()->Types();
|
const auto& args = c_ft->ParamList()->GetTypes();
|
||||||
const auto& t_indexes = the_table->IndexTypes();
|
const auto& t_indexes = the_table->GetIndexTypes();
|
||||||
if ( args.size() != ( type->IsSet() ? 2 : 3 ) + t_indexes.size() )
|
if ( args.size() != ( type->IsSet() ? 2 : 3 ) + t_indexes.size() )
|
||||||
{
|
{
|
||||||
Error("&on_change function has incorrect number of arguments");
|
Error("&on_change function has incorrect number of arguments");
|
||||||
|
|
|
@ -23,9 +23,9 @@ CompositeHash::CompositeHash(IntrusivePtr<zeek::TypeList> composite_type)
|
||||||
// If the only element is a record, don't treat it as a
|
// If the only element is a record, don't treat it as a
|
||||||
// singleton, since it needs to be evaluated specially.
|
// singleton, since it needs to be evaluated specially.
|
||||||
|
|
||||||
if ( type->Types().size() == 1 )
|
if ( type->GetTypes().size() == 1 )
|
||||||
{
|
{
|
||||||
if ( type->Types()[0]->Tag() == zeek::TYPE_RECORD )
|
if ( type->GetTypes()[0]->Tag() == zeek::TYPE_RECORD )
|
||||||
{
|
{
|
||||||
is_complex_type = true;
|
is_complex_type = true;
|
||||||
is_singleton = false;
|
is_singleton = false;
|
||||||
|
@ -47,7 +47,7 @@ CompositeHash::CompositeHash(IntrusivePtr<zeek::TypeList> composite_type)
|
||||||
{
|
{
|
||||||
// Don't do any further key computations - we'll do them
|
// Don't do any further key computations - we'll do them
|
||||||
// via the singleton later.
|
// via the singleton later.
|
||||||
singleton_tag = type->Types()[0]->InternalType();
|
singleton_tag = type->GetTypes()[0]->InternalType();
|
||||||
size = 0;
|
size = 0;
|
||||||
key = nullptr;
|
key = nullptr;
|
||||||
}
|
}
|
||||||
|
@ -367,7 +367,7 @@ std::unique_ptr<HashKey> CompositeHash::MakeHashKey(const Val& argv, bool type_c
|
||||||
type_check = false; // no need to type-check again.
|
type_check = false; // no need to type-check again.
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto& tl = type->Types();
|
const auto& tl = type->GetTypes();
|
||||||
|
|
||||||
if ( type_check && v->GetType()->Tag() != zeek::TYPE_LIST )
|
if ( type_check && v->GetType()->Tag() != zeek::TYPE_LIST )
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
@ -625,7 +625,7 @@ int CompositeHash::SingleTypeKeySize(zeek::Type* bt, const Val* v,
|
||||||
|
|
||||||
int CompositeHash::ComputeKeySize(const Val* v, bool type_check, bool calc_static_size) const
|
int CompositeHash::ComputeKeySize(const Val* v, bool type_check, bool calc_static_size) const
|
||||||
{
|
{
|
||||||
const auto& tl = type->Types();
|
const auto& tl = type->GetTypes();
|
||||||
|
|
||||||
if ( v )
|
if ( v )
|
||||||
{
|
{
|
||||||
|
@ -712,7 +712,7 @@ int CompositeHash::SizeAlign(int offset, unsigned int size) const
|
||||||
IntrusivePtr<ListVal> CompositeHash::RecoverVals(const HashKey& k) const
|
IntrusivePtr<ListVal> CompositeHash::RecoverVals(const HashKey& k) const
|
||||||
{
|
{
|
||||||
auto l = make_intrusive<ListVal>(zeek::TYPE_ANY);
|
auto l = make_intrusive<ListVal>(zeek::TYPE_ANY);
|
||||||
const auto& tl = type->Types();
|
const auto& tl = type->GetTypes();
|
||||||
const char* kp = (const char*) k.Key();
|
const char* kp = (const char*) k.Key();
|
||||||
const char* const k_end = kp + k.Size();
|
const char* const k_end = kp + k.Size();
|
||||||
|
|
||||||
|
@ -1011,7 +1011,7 @@ const char* CompositeHash::RecoverOneVal(const HashKey& k, const char* kp0,
|
||||||
for ( int i = 0; i < n; ++i )
|
for ( int i = 0; i < n; ++i )
|
||||||
{
|
{
|
||||||
IntrusivePtr<Val> v;
|
IntrusivePtr<Val> v;
|
||||||
zeek::Type* it = tl->Types()[i].get();
|
zeek::Type* it = tl->GetTypes()[i].get();
|
||||||
kp1 = RecoverOneVal(k, kp1, k_end, it, &v, false);
|
kp1 = RecoverOneVal(k, kp1, k_end, it, &v, false);
|
||||||
lv->Append(std::move(v));
|
lv->Append(std::move(v));
|
||||||
}
|
}
|
||||||
|
|
14
src/Expr.cc
14
src/Expr.cc
|
@ -3086,7 +3086,7 @@ TableConstructorExpr::TableConstructorExpr(IntrusivePtr<ListExpr> constructor_li
|
||||||
if ( arg_attrs )
|
if ( arg_attrs )
|
||||||
attrs = make_intrusive<Attributes>(std::move(*arg_attrs), type, false, false);
|
attrs = make_intrusive<Attributes>(std::move(*arg_attrs), type, false, false);
|
||||||
|
|
||||||
const auto& indices = type->AsTableType()->GetIndices()->Types();
|
const auto& indices = type->AsTableType()->GetIndices()->GetTypes();
|
||||||
const expr_list& cle = op->AsListExpr()->Exprs();
|
const expr_list& cle = op->AsListExpr()->Exprs();
|
||||||
|
|
||||||
// check and promote all index expressions in ctor list
|
// check and promote all index expressions in ctor list
|
||||||
|
@ -3204,7 +3204,7 @@ SetConstructorExpr::SetConstructorExpr(IntrusivePtr<ListExpr> constructor_list,
|
||||||
if ( arg_attrs )
|
if ( arg_attrs )
|
||||||
attrs = make_intrusive<Attributes>(std::move(*arg_attrs), type, false, false);
|
attrs = make_intrusive<Attributes>(std::move(*arg_attrs), type, false, false);
|
||||||
|
|
||||||
const auto& indices = type->AsTableType()->GetIndices()->Types();
|
const auto& indices = type->AsTableType()->GetIndices()->GetTypes();
|
||||||
expr_list& cle = op->AsListExpr()->Exprs();
|
expr_list& cle = op->AsListExpr()->Exprs();
|
||||||
|
|
||||||
if ( indices.size() == 1 )
|
if ( indices.size() == 1 )
|
||||||
|
@ -4471,7 +4471,7 @@ IntrusivePtr<Val> ListExpr::InitVal(const zeek::Type* t, IntrusivePtr<Val> aggr)
|
||||||
if ( ! aggr && type->AsTypeList()->AllMatch(t, true) )
|
if ( ! aggr && type->AsTypeList()->AllMatch(t, true) )
|
||||||
{
|
{
|
||||||
auto v = make_intrusive<ListVal>(zeek::TYPE_ANY);
|
auto v = make_intrusive<ListVal>(zeek::TYPE_ANY);
|
||||||
const auto& tl = type->AsTypeList()->Types();
|
const auto& tl = type->AsTypeList()->GetTypes();
|
||||||
|
|
||||||
if ( exprs.length() != static_cast<int>(tl.size()) )
|
if ( exprs.length() != static_cast<int>(tl.size()) )
|
||||||
{
|
{
|
||||||
|
@ -4499,7 +4499,7 @@ IntrusivePtr<Val> ListExpr::InitVal(const zeek::Type* t, IntrusivePtr<Val> aggr)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto& tl = t->AsTypeList()->Types();
|
const auto& tl = t->AsTypeList()->GetTypes();
|
||||||
|
|
||||||
if ( exprs.length() != static_cast<int>(tl.size()) )
|
if ( exprs.length() != static_cast<int>(tl.size()) )
|
||||||
{
|
{
|
||||||
|
@ -4620,7 +4620,7 @@ IntrusivePtr<Val> ListExpr::AddSetInit(const zeek::Type* t, IntrusivePtr<Val> ag
|
||||||
else if ( expr->GetType()->Tag() == zeek::TYPE_LIST )
|
else if ( expr->GetType()->Tag() == zeek::TYPE_LIST )
|
||||||
element = expr->InitVal(it, nullptr);
|
element = expr->InitVal(it, nullptr);
|
||||||
else
|
else
|
||||||
element = expr->InitVal(it->Types()[0].get(), nullptr);
|
element = expr->InitVal(it->GetTypes()[0].get(), nullptr);
|
||||||
|
|
||||||
if ( ! element )
|
if ( ! element )
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
@ -4642,7 +4642,7 @@ IntrusivePtr<Val> ListExpr::AddSetInit(const zeek::Type* t, IntrusivePtr<Val> ag
|
||||||
if ( expr->GetType()->Tag() == zeek::TYPE_LIST )
|
if ( expr->GetType()->Tag() == zeek::TYPE_LIST )
|
||||||
element = check_and_promote(std::move(element), it, true);
|
element = check_and_promote(std::move(element), it, true);
|
||||||
else
|
else
|
||||||
element = check_and_promote(std::move(element), it->Types()[0].get(), true);
|
element = check_and_promote(std::move(element), it->GetTypes()[0].get(), true);
|
||||||
|
|
||||||
if ( ! element )
|
if ( ! element )
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
@ -4930,7 +4930,7 @@ IntrusivePtr<Expr> check_and_promote_expr(Expr* const e, zeek::Type* t)
|
||||||
bool check_and_promote_exprs(ListExpr* const elements, TypeList* types)
|
bool check_and_promote_exprs(ListExpr* const elements, TypeList* types)
|
||||||
{
|
{
|
||||||
expr_list& el = elements->Exprs();
|
expr_list& el = elements->Exprs();
|
||||||
const auto& tl = types->Types();
|
const auto& tl = types->GetTypes();
|
||||||
|
|
||||||
if ( tl.size() == 1 && tl[0]->Tag() == zeek::TYPE_ANY )
|
if ( tl.size() == 1 && tl[0]->Tag() == zeek::TYPE_ANY )
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -149,7 +149,7 @@ RuleConditionEval::RuleConditionEval(const char* func)
|
||||||
tl.Append(signature_state);
|
tl.Append(signature_state);
|
||||||
tl.Append(zeek::base_type(zeek::TYPE_STRING));
|
tl.Append(zeek::base_type(zeek::TYPE_STRING));
|
||||||
|
|
||||||
if ( ! f->CheckArgs(tl.Types()) )
|
if ( ! f->CheckArgs(tl.GetTypes()) )
|
||||||
rules_error("eval function parameters must be a 'signature_state' "
|
rules_error("eval function parameters must be a 'signature_state' "
|
||||||
"and a 'string' type", func);
|
"and a 'string' type", func);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1067,7 +1067,7 @@ ForStmt::ForStmt(id_list* arg_loop_vars, IntrusivePtr<Expr> loop_expr)
|
||||||
|
|
||||||
if ( e->GetType()->Tag() == TYPE_TABLE )
|
if ( e->GetType()->Tag() == TYPE_TABLE )
|
||||||
{
|
{
|
||||||
const auto& indices = e->GetType()->AsTableType()->IndexTypes();
|
const auto& indices = e->GetType()->AsTableType()->GetIndexTypes();
|
||||||
|
|
||||||
if ( static_cast<int>(indices.size()) != loop_vars->length() )
|
if ( static_cast<int>(indices.size()) != loop_vars->length() )
|
||||||
{
|
{
|
||||||
|
|
46
src/Type.cc
46
src/Type.cc
|
@ -168,6 +168,7 @@ void TypeList::Append(IntrusivePtr<Type> t)
|
||||||
if ( pure_type && ! same_type(t, pure_type) )
|
if ( pure_type && ! same_type(t, pure_type) )
|
||||||
reporter->InternalError("pure type-list violation");
|
reporter->InternalError("pure type-list violation");
|
||||||
|
|
||||||
|
types_list.push_back(t.get());
|
||||||
types.emplace_back(std::move(t));
|
types.emplace_back(std::move(t));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -176,6 +177,7 @@ void TypeList::AppendEvenIfNotPure(IntrusivePtr<Type> t)
|
||||||
if ( pure_type && ! same_type(t, pure_type) )
|
if ( pure_type && ! same_type(t, pure_type) )
|
||||||
pure_type = nullptr;
|
pure_type = nullptr;
|
||||||
|
|
||||||
|
types_list.push_back(t.get());
|
||||||
types.emplace_back(std::move(t));
|
types.emplace_back(std::move(t));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -220,12 +222,10 @@ unsigned int TypeList::MemoryAllocation() const
|
||||||
+ size;
|
+ size;
|
||||||
}
|
}
|
||||||
|
|
||||||
IndexType::~IndexType() = default;
|
|
||||||
|
|
||||||
int IndexType::MatchesIndex(zeek::detail::ListExpr* const index) const
|
int IndexType::MatchesIndex(zeek::detail::ListExpr* const index) const
|
||||||
{
|
{
|
||||||
// If we have a type indexed by subnets, addresses are ok.
|
// If we have a type indexed by subnets, addresses are ok.
|
||||||
const auto& types = indices->Types();
|
const auto& types = indices->GetTypes();
|
||||||
const expr_list& exprs = index->Exprs();
|
const expr_list& exprs = index->Exprs();
|
||||||
|
|
||||||
if ( types.size() == 1 && types[0]->Tag() == TYPE_SUBNET &&
|
if ( types.size() == 1 && types[0]->Tag() == TYPE_SUBNET &&
|
||||||
|
@ -242,7 +242,7 @@ void IndexType::Describe(ODesc* d) const
|
||||||
if ( ! d->IsBinary() )
|
if ( ! d->IsBinary() )
|
||||||
d->Add("[");
|
d->Add("[");
|
||||||
|
|
||||||
const auto& its = IndexTypes();
|
const auto& its = GetIndexTypes();
|
||||||
|
|
||||||
for ( auto i = 0u; i < its.size(); ++i )
|
for ( auto i = 0u; i < its.size(); ++i )
|
||||||
{
|
{
|
||||||
|
@ -273,7 +273,7 @@ void IndexType::DescribeReST(ODesc* d, bool roles_only) const
|
||||||
d->Add("` ");
|
d->Add("` ");
|
||||||
d->Add("[");
|
d->Add("[");
|
||||||
|
|
||||||
const auto& its = IndexTypes();
|
const auto& its = GetIndexTypes();
|
||||||
|
|
||||||
for ( auto i = 0u; i < its.size(); ++i )
|
for ( auto i = 0u; i < its.size(); ++i )
|
||||||
{
|
{
|
||||||
|
@ -311,7 +311,7 @@ void IndexType::DescribeReST(ODesc* d, bool roles_only) const
|
||||||
|
|
||||||
bool IndexType::IsSubNetIndex() const
|
bool IndexType::IsSubNetIndex() const
|
||||||
{
|
{
|
||||||
const auto& types = indices->Types();
|
const auto& types = indices->GetTypes();
|
||||||
if ( types.size() == 1 && types[0]->Tag() == TYPE_SUBNET )
|
if ( types.size() == 1 && types[0]->Tag() == TYPE_SUBNET )
|
||||||
return true;
|
return true;
|
||||||
return false;
|
return false;
|
||||||
|
@ -323,7 +323,7 @@ TableType::TableType(IntrusivePtr<TypeList> ind, IntrusivePtr<Type> yield)
|
||||||
if ( ! indices )
|
if ( ! indices )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const auto& tl = indices->Types();
|
const auto& tl = indices->GetTypes();
|
||||||
|
|
||||||
for ( const auto& tli : tl )
|
for ( const auto& tli : tl )
|
||||||
{
|
{
|
||||||
|
@ -352,7 +352,7 @@ IntrusivePtr<Type> TableType::ShallowClone()
|
||||||
bool TableType::IsUnspecifiedTable() const
|
bool TableType::IsUnspecifiedTable() const
|
||||||
{
|
{
|
||||||
// Unspecified types have an empty list of indices.
|
// Unspecified types have an empty list of indices.
|
||||||
return indices->Types().empty();
|
return indices->GetTypes().empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
SetType::SetType(IntrusivePtr<TypeList> ind, IntrusivePtr<zeek::detail::ListExpr> arg_elements)
|
SetType::SetType(IntrusivePtr<TypeList> ind, IntrusivePtr<zeek::detail::ListExpr> arg_elements)
|
||||||
|
@ -368,7 +368,7 @@ SetType::SetType(IntrusivePtr<TypeList> ind, IntrusivePtr<zeek::detail::ListExpr
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
TypeList* tl_type = elements->GetType()->AsTypeList();
|
TypeList* tl_type = elements->GetType()->AsTypeList();
|
||||||
const auto& tl = tl_type->Types();
|
const auto& tl = tl_type->GetTypes();
|
||||||
|
|
||||||
if ( tl.size() < 1 )
|
if ( tl.size() < 1 )
|
||||||
{
|
{
|
||||||
|
@ -493,7 +493,7 @@ bool FuncType::CheckArgs(const type_list* args, bool is_init) const
|
||||||
bool FuncType::CheckArgs(const std::vector<IntrusivePtr<Type>>& args,
|
bool FuncType::CheckArgs(const std::vector<IntrusivePtr<Type>>& args,
|
||||||
bool is_init) const
|
bool is_init) const
|
||||||
{
|
{
|
||||||
const auto& my_args = arg_types->Types();
|
const auto& my_args = arg_types->GetTypes();
|
||||||
|
|
||||||
if ( my_args.size() != args.size() )
|
if ( my_args.size() != args.size() )
|
||||||
{
|
{
|
||||||
|
@ -774,7 +774,7 @@ static string container_type_name(const Type* ft)
|
||||||
else
|
else
|
||||||
s = "table[";
|
s = "table[";
|
||||||
|
|
||||||
const auto& tl = ((const IndexType*) ft)->IndexTypes();
|
const auto& tl = ((const IndexType*) ft)->GetIndexTypes();
|
||||||
|
|
||||||
for ( auto i = 0u; i < tl.size(); ++i )
|
for ( auto i = 0u; i < tl.size(); ++i )
|
||||||
{
|
{
|
||||||
|
@ -1481,7 +1481,7 @@ bool same_type(const Type& arg_t1, const Type& arg_t2,
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ft1->CheckArgs(ft2->ParamList()->Types(), is_init);
|
return ft1->CheckArgs(ft2->ParamList()->GetTypes(), is_init);
|
||||||
}
|
}
|
||||||
|
|
||||||
case TYPE_RECORD:
|
case TYPE_RECORD:
|
||||||
|
@ -1507,8 +1507,8 @@ bool same_type(const Type& arg_t1, const Type& arg_t2,
|
||||||
|
|
||||||
case TYPE_LIST:
|
case TYPE_LIST:
|
||||||
{
|
{
|
||||||
const auto& tl1 = t1->AsTypeList()->Types();
|
const auto& tl1 = t1->AsTypeList()->GetTypes();
|
||||||
const auto& tl2 = t2->AsTypeList()->Types();
|
const auto& tl2 = t2->AsTypeList()->GetTypes();
|
||||||
|
|
||||||
if ( tl1.size() != tl2.size() )
|
if ( tl1.size() != tl2.size() )
|
||||||
return false;
|
return false;
|
||||||
|
@ -1597,7 +1597,7 @@ const Type* flatten_type(const Type* t)
|
||||||
if ( tl->IsPure() )
|
if ( tl->IsPure() )
|
||||||
return tl->GetPureType().get();
|
return tl->GetPureType().get();
|
||||||
|
|
||||||
const auto& types = tl->Types();
|
const auto& types = tl->GetTypes();
|
||||||
|
|
||||||
if ( types.size() == 0 )
|
if ( types.size() == 0 )
|
||||||
reporter->InternalError("empty type list in flatten_type");
|
reporter->InternalError("empty type list in flatten_type");
|
||||||
|
@ -1756,8 +1756,8 @@ IntrusivePtr<Type> merge_types(const IntrusivePtr<Type>& arg_t1,
|
||||||
const IndexType* it1 = (const IndexType*) t1;
|
const IndexType* it1 = (const IndexType*) t1;
|
||||||
const IndexType* it2 = (const IndexType*) t2;
|
const IndexType* it2 = (const IndexType*) t2;
|
||||||
|
|
||||||
const auto& tl1 = it1->IndexTypes();
|
const auto& tl1 = it1->GetIndexTypes();
|
||||||
const auto& tl2 = it2->IndexTypes();
|
const auto& tl2 = it2->GetIndexTypes();
|
||||||
IntrusivePtr<TypeList> tl3;
|
IntrusivePtr<TypeList> tl3;
|
||||||
|
|
||||||
if ( tl1.size() != tl2.size() )
|
if ( tl1.size() != tl2.size() )
|
||||||
|
@ -1859,8 +1859,8 @@ IntrusivePtr<Type> merge_types(const IntrusivePtr<Type>& arg_t1,
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto& l1 = tl1->Types();
|
const auto& l1 = tl1->GetTypes();
|
||||||
const auto& l2 = tl2->Types();
|
const auto& l2 = tl2->GetTypes();
|
||||||
|
|
||||||
if ( l1.size() == 0 || l2.size() == 0 )
|
if ( l1.size() == 0 || l2.size() == 0 )
|
||||||
{
|
{
|
||||||
|
@ -1927,7 +1927,7 @@ IntrusivePtr<Type> merge_types(const IntrusivePtr<Type>& arg_t1,
|
||||||
IntrusivePtr<Type> merge_type_list(zeek::detail::ListExpr* elements)
|
IntrusivePtr<Type> merge_type_list(zeek::detail::ListExpr* elements)
|
||||||
{
|
{
|
||||||
TypeList* tl_type = elements->GetType()->AsTypeList();
|
TypeList* tl_type = elements->GetType()->AsTypeList();
|
||||||
const auto& tl = tl_type->Types();
|
const auto& tl = tl_type->GetTypes();
|
||||||
|
|
||||||
if ( tl.size() < 1 )
|
if ( tl.size() < 1 )
|
||||||
{
|
{
|
||||||
|
@ -1959,8 +1959,8 @@ static Type* reduce_type(Type* t)
|
||||||
{
|
{
|
||||||
const auto& tl = t->AsTableType()->GetIndices();
|
const auto& tl = t->AsTableType()->GetIndices();
|
||||||
|
|
||||||
if ( tl->Types().size() == 1 )
|
if ( tl->GetTypes().size() == 1 )
|
||||||
return tl->Types()[0].get();
|
return tl->GetTypes()[0].get();
|
||||||
else
|
else
|
||||||
return tl.get();
|
return tl.get();
|
||||||
}
|
}
|
||||||
|
@ -1979,7 +1979,7 @@ IntrusivePtr<Type> init_type(zeek::detail::Expr* init)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
if ( t->Tag() == TYPE_LIST &&
|
if ( t->Tag() == TYPE_LIST &&
|
||||||
t->AsTypeList()->Types().size() != 1 )
|
t->AsTypeList()->GetTypes().size() != 1 )
|
||||||
{
|
{
|
||||||
init->Error("list used in scalar initialization");
|
init->Error("list used in scalar initialization");
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
20
src/Type.h
20
src/Type.h
|
@ -416,7 +416,13 @@ public:
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::vector<IntrusivePtr<Type>>& Types() const
|
~TypeList() override = default;
|
||||||
|
|
||||||
|
[[deprecated("Remove in v4.1. Use GetTypes() instead.")]]
|
||||||
|
const type_list* Types() const
|
||||||
|
{ return &types_list; }
|
||||||
|
|
||||||
|
const std::vector<IntrusivePtr<Type>>& GetTypes() const
|
||||||
{ return types; }
|
{ return types; }
|
||||||
|
|
||||||
bool IsPure() const { return pure_type != nullptr; }
|
bool IsPure() const { return pure_type != nullptr; }
|
||||||
|
@ -448,10 +454,14 @@ public:
|
||||||
protected:
|
protected:
|
||||||
IntrusivePtr<Type> pure_type;
|
IntrusivePtr<Type> pure_type;
|
||||||
std::vector<IntrusivePtr<Type>> types;
|
std::vector<IntrusivePtr<Type>> types;
|
||||||
|
|
||||||
|
// Remove in v4.1. This is used by Types(), which is deprecated.
|
||||||
|
type_list types_list;
|
||||||
};
|
};
|
||||||
|
|
||||||
class IndexType : public Type {
|
class IndexType : public Type {
|
||||||
public:
|
public:
|
||||||
|
|
||||||
int MatchesIndex(zeek::detail::ListExpr* index) const override;
|
int MatchesIndex(zeek::detail::ListExpr* index) const override;
|
||||||
|
|
||||||
const IntrusivePtr<TypeList>& GetIndices() const
|
const IntrusivePtr<TypeList>& GetIndices() const
|
||||||
|
@ -460,9 +470,13 @@ public:
|
||||||
[[deprecated("Remove in v4.1. Use GetIndices().")]]
|
[[deprecated("Remove in v4.1. Use GetIndices().")]]
|
||||||
TypeList* Indices() const { return indices.get(); }
|
TypeList* Indices() const { return indices.get(); }
|
||||||
|
|
||||||
const std::vector<IntrusivePtr<Type>>& IndexTypes() const
|
[[deprecated("Remove in v4.1. Use GetIndexTypes().")]]
|
||||||
|
const type_list* IndexTypes() const
|
||||||
{ return indices->Types(); }
|
{ return indices->Types(); }
|
||||||
|
|
||||||
|
const std::vector<IntrusivePtr<Type>>& GetIndexTypes() const
|
||||||
|
{ return indices->GetTypes(); }
|
||||||
|
|
||||||
const IntrusivePtr<Type>& Yield() const override
|
const IntrusivePtr<Type>& Yield() const override
|
||||||
{ return yield_type; }
|
{ return yield_type; }
|
||||||
|
|
||||||
|
@ -480,7 +494,7 @@ protected:
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
~IndexType() override;
|
~IndexType() override = default;
|
||||||
|
|
||||||
IntrusivePtr<TypeList> indices;
|
IntrusivePtr<TypeList> indices;
|
||||||
IntrusivePtr<Type> yield_type;
|
IntrusivePtr<Type> yield_type;
|
||||||
|
|
12
src/Val.cc
12
src/Val.cc
|
@ -275,7 +275,7 @@ IntrusivePtr<Val> Val::SizeVal() const
|
||||||
|
|
||||||
case zeek::TYPE_INTERNAL_OTHER:
|
case zeek::TYPE_INTERNAL_OTHER:
|
||||||
if ( type->Tag() == zeek::TYPE_FUNC )
|
if ( type->Tag() == zeek::TYPE_FUNC )
|
||||||
return val_mgr->Count(val.func_val->GetType()->ParamList()->Types().size());
|
return val_mgr->Count(val.func_val->GetType()->ParamList()->GetTypes().size());
|
||||||
|
|
||||||
if ( type->Tag() == zeek::TYPE_FILE )
|
if ( type->Tag() == zeek::TYPE_FILE )
|
||||||
return make_intrusive<DoubleVal>(val.file_val->Size());
|
return make_intrusive<DoubleVal>(val.file_val->Size());
|
||||||
|
@ -1357,7 +1357,7 @@ static void find_nested_record_types(const IntrusivePtr<zeek::Type>& t, std::set
|
||||||
return;
|
return;
|
||||||
case zeek::TYPE_LIST:
|
case zeek::TYPE_LIST:
|
||||||
{
|
{
|
||||||
for ( const auto& type : t->AsTypeList()->Types() )
|
for ( const auto& type : t->AsTypeList()->GetTypes() )
|
||||||
find_nested_record_types(type, found);
|
find_nested_record_types(type, found);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
@ -1384,7 +1384,7 @@ TableVal::TableVal(IntrusivePtr<zeek::TableType> t, IntrusivePtr<zeek::detail::A
|
||||||
if ( ! is_parsing )
|
if ( ! is_parsing )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for ( const auto& t : table_type->IndexTypes() )
|
for ( const auto& t : table_type->GetIndexTypes() )
|
||||||
{
|
{
|
||||||
std::set<zeek::RecordType*> found;
|
std::set<zeek::RecordType*> found;
|
||||||
// TODO: this likely doesn't have to be repeated for each new TableVal,
|
// TODO: this likely doesn't have to be repeated for each new TableVal,
|
||||||
|
@ -1770,7 +1770,7 @@ bool TableVal::ExpandAndInit(IntrusivePtr<Val> index, IntrusivePtr<Val> new_val)
|
||||||
ListVal* iv = index->AsListVal();
|
ListVal* iv = index->AsListVal();
|
||||||
if ( iv->BaseTag() != zeek::TYPE_ANY )
|
if ( iv->BaseTag() != zeek::TYPE_ANY )
|
||||||
{
|
{
|
||||||
if ( table_type->GetIndices()->Types().size() != 1 )
|
if ( table_type->GetIndices()->GetTypes().size() != 1 )
|
||||||
reporter->InternalError("bad singleton list index");
|
reporter->InternalError("bad singleton list index");
|
||||||
|
|
||||||
for ( int i = 0; i < iv->Length(); ++i )
|
for ( int i = 0; i < iv->Length(); ++i )
|
||||||
|
@ -2179,7 +2179,7 @@ ListVal* TableVal::ConvertToList(zeek::TypeTag t) const
|
||||||
|
|
||||||
IntrusivePtr<ListVal> TableVal::ToPureListVal() const
|
IntrusivePtr<ListVal> TableVal::ToPureListVal() const
|
||||||
{
|
{
|
||||||
const auto& tl = table_type->GetIndices()->Types();
|
const auto& tl = table_type->GetIndices()->GetTypes();
|
||||||
if ( tl.size() != 1 )
|
if ( tl.size() != 1 )
|
||||||
{
|
{
|
||||||
InternalWarning("bad index type in TableVal::ToPureListVal");
|
InternalWarning("bad index type in TableVal::ToPureListVal");
|
||||||
|
@ -2515,7 +2515,7 @@ double TableVal::CallExpireFunc(IntrusivePtr<ListVal> idx)
|
||||||
const Func* f = vf->AsFunc();
|
const Func* f = vf->AsFunc();
|
||||||
zeek::Args vl;
|
zeek::Args vl;
|
||||||
|
|
||||||
const auto& func_args = f->GetType()->ParamList()->Types();
|
const auto& func_args = f->GetType()->ParamList()->GetTypes();
|
||||||
// backwards compatibility with idx: any idiom
|
// backwards compatibility with idx: any idiom
|
||||||
bool any_idiom = func_args.size() == 2 && func_args.back()->Tag() == zeek::TYPE_ANY;
|
bool any_idiom = func_args.size() == 2 && func_args.back()->Tag() == zeek::TYPE_ANY;
|
||||||
|
|
||||||
|
|
|
@ -208,7 +208,7 @@ struct val_converter {
|
||||||
|
|
||||||
for ( auto& item : a )
|
for ( auto& item : a )
|
||||||
{
|
{
|
||||||
const auto& expected_index_types = tt->GetIndices()->Types();
|
const auto& expected_index_types = tt->GetIndices()->GetTypes();
|
||||||
broker::vector composite_key;
|
broker::vector composite_key;
|
||||||
auto indices = caf::get_if<broker::vector>(&item);
|
auto indices = caf::get_if<broker::vector>(&item);
|
||||||
|
|
||||||
|
@ -267,7 +267,7 @@ struct val_converter {
|
||||||
|
|
||||||
for ( auto& item : a )
|
for ( auto& item : a )
|
||||||
{
|
{
|
||||||
const auto& expected_index_types = tt->GetIndices()->Types();
|
const auto& expected_index_types = tt->GetIndices()->GetTypes();
|
||||||
broker::vector composite_key;
|
broker::vector composite_key;
|
||||||
auto indices = caf::get_if<broker::vector>(&item.first);
|
auto indices = caf::get_if<broker::vector>(&item.first);
|
||||||
|
|
||||||
|
@ -555,7 +555,7 @@ struct type_checker {
|
||||||
|
|
||||||
for ( const auto& item : a )
|
for ( const auto& item : a )
|
||||||
{
|
{
|
||||||
const auto& expected_index_types = tt->GetIndices()->Types();
|
const auto& expected_index_types = tt->GetIndices()->GetTypes();
|
||||||
auto indices = caf::get_if<broker::vector>(&item);
|
auto indices = caf::get_if<broker::vector>(&item);
|
||||||
vector<const broker::data*> indices_to_check;
|
vector<const broker::data*> indices_to_check;
|
||||||
|
|
||||||
|
@ -614,7 +614,7 @@ struct type_checker {
|
||||||
|
|
||||||
for ( auto& item : a )
|
for ( auto& item : a )
|
||||||
{
|
{
|
||||||
const auto& expected_index_types = tt->GetIndices()->Types();
|
const auto& expected_index_types = tt->GetIndices()->GetTypes();
|
||||||
auto indices = caf::get_if<broker::vector>(&item.first);
|
auto indices = caf::get_if<broker::vector>(&item.first);
|
||||||
vector<const broker::data*> indices_to_check;
|
vector<const broker::data*> indices_to_check;
|
||||||
|
|
||||||
|
|
|
@ -742,7 +742,7 @@ RecordVal* Manager::MakeEvent(val_list* args, Frame* frame)
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto& got_type = (*args)[i]->GetType();
|
const auto& got_type = (*args)[i]->GetType();
|
||||||
const auto& expected_type = func->GetType()->ParamList()->Types()[i - 1];
|
const auto& expected_type = func->GetType()->ParamList()->GetTypes()[i - 1];
|
||||||
|
|
||||||
if ( ! same_type(got_type, expected_type) )
|
if ( ! same_type(got_type, expected_type) )
|
||||||
{
|
{
|
||||||
|
@ -978,7 +978,7 @@ void Manager::ProcessEvent(const broker::topic& topic, broker::zeek::Event ev)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto& arg_types = handler->GetType(false)->ParamList()->Types();
|
const auto& arg_types = handler->GetType(false)->ParamList()->GetTypes();
|
||||||
|
|
||||||
if ( arg_types.size() != args.size() )
|
if ( arg_types.size() != args.size() )
|
||||||
{
|
{
|
||||||
|
|
|
@ -12,7 +12,7 @@ static bool is_string_set(const zeek::Type* type)
|
||||||
if ( ! type->IsSet() )
|
if ( ! type->IsSet() )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
const auto& index_types = type->AsSetType()->IndexTypes();
|
const auto& index_types = type->AsSetType()->GetIndexTypes();
|
||||||
|
|
||||||
if ( index_types.size() != 1 )
|
if ( index_types.size() != 1 )
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -332,7 +332,7 @@ bool Manager::CreateEventStream(RecordVal* fval)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto& args = etype->ParamList()->Types();
|
const auto& args = etype->ParamList()->GetTypes();
|
||||||
|
|
||||||
if ( args.size() < 2 )
|
if ( args.size() < 2 )
|
||||||
{
|
{
|
||||||
|
@ -482,7 +482,7 @@ bool Manager::CreateTableStream(RecordVal* fval)
|
||||||
|
|
||||||
// check if index fields match table description
|
// check if index fields match table description
|
||||||
size_t num = idx->NumFields();
|
size_t num = idx->NumFields();
|
||||||
const auto& tl = dst->GetType()->AsTableType()->IndexTypes();
|
const auto& tl = dst->GetType()->AsTableType()->GetIndexTypes();
|
||||||
size_t j;
|
size_t j;
|
||||||
|
|
||||||
for ( j = 0; j < tl.size(); ++j )
|
for ( j = 0; j < tl.size(); ++j )
|
||||||
|
@ -557,7 +557,7 @@ bool Manager::CreateTableStream(RecordVal* fval)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto& args = etype->ParamList()->Types();
|
const auto& args = etype->ParamList()->GetTypes();
|
||||||
|
|
||||||
if ( args.size() != 4 )
|
if ( args.size() != 4 )
|
||||||
{
|
{
|
||||||
|
@ -704,7 +704,7 @@ bool Manager::CheckErrorEventTypes(const std::string& stream_name, const Func* e
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto& args = etype->ParamList()->Types();
|
const auto& args = etype->ParamList()->GetTypes();
|
||||||
|
|
||||||
if ( args.size() != 3 )
|
if ( args.size() != 3 )
|
||||||
{
|
{
|
||||||
|
|
|
@ -277,7 +277,7 @@ bool Manager::CreateStream(EnumVal* id, RecordVal* sval)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto& args = etype->ParamList()->Types();
|
const auto& args = etype->ParamList()->GetTypes();
|
||||||
|
|
||||||
if ( args.size() != 1 )
|
if ( args.size() != 1 )
|
||||||
{
|
{
|
||||||
|
|
|
@ -15,7 +15,7 @@ static bool call_option_handlers_and_set_value(StringVal* name, const IntrusiveP
|
||||||
{
|
{
|
||||||
for ( auto handler_function : i->GetOptionHandlers() )
|
for ( auto handler_function : i->GetOptionHandlers() )
|
||||||
{
|
{
|
||||||
bool add_loc = handler_function->GetType()->ParamList()->Types().size() == 3;
|
bool add_loc = handler_function->GetType()->ParamList()->GetTypes().size() == 3;
|
||||||
zeek::Args vl;
|
zeek::Args vl;
|
||||||
vl.reserve(2 + add_loc);
|
vl.reserve(2 + add_loc);
|
||||||
vl.emplace_back(NewRef{}, name);
|
vl.emplace_back(NewRef{}, name);
|
||||||
|
@ -170,7 +170,7 @@ function Option::set_change_handler%(ID: string, on_change: any, priority: int &
|
||||||
return val_mgr->False();
|
return val_mgr->False();
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto& args = on_change->GetType()->AsFuncType()->ParamList()->Types();
|
const auto& args = on_change->GetType()->AsFuncType()->ParamList()->GetTypes();
|
||||||
if ( args.size() < 2 || args.size() > 3 )
|
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",
|
builtin_error(fmt("Wrong number of arguments for passed function in Option::on_change for ID '%s'; expected 2 or 3, got %zu",
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue