mirror of
https://github.com/zeek/zeek.git
synced 2025-10-10 10:38:20 +00:00
Migrate TypeList to store IntrusivePtrs
This changes return types of TypeList::Types() and IndexType::IndexTypes() to return std::vector instead of type_list*
This commit is contained in:
parent
011866a908
commit
455fc29b1a
14 changed files with 271 additions and 248 deletions
19
src/Stmt.cc
19
src/Stmt.cc
|
@ -1069,28 +1069,29 @@ ForStmt::ForStmt(id_list* arg_loop_vars, IntrusivePtr<Expr> loop_expr)
|
|||
|
||||
if ( e->Type()->Tag() == TYPE_TABLE )
|
||||
{
|
||||
const type_list* indices = e->Type()->AsTableType()->IndexTypes();
|
||||
if ( indices->length() != loop_vars->length() )
|
||||
const auto& indices = e->Type()->AsTableType()->IndexTypes();
|
||||
|
||||
if ( static_cast<int>(indices.size()) != loop_vars->length() )
|
||||
{
|
||||
e->Error("wrong index size");
|
||||
return;
|
||||
}
|
||||
|
||||
for ( int i = 0; i < indices->length(); i++ )
|
||||
for ( auto i = 0u; i < indices.size(); i++ )
|
||||
{
|
||||
BroType* ind_type = (*indices)[i]->Ref();
|
||||
const auto& ind_type = indices[i];
|
||||
|
||||
if ( (*loop_vars)[i]->Type() )
|
||||
{
|
||||
if ( ! same_type((*loop_vars)[i]->Type(), ind_type) )
|
||||
(*loop_vars)[i]->Type()->Error("type clash in iteration", ind_type);
|
||||
if ( ! same_type((*loop_vars)[i]->Type(), ind_type.get()) )
|
||||
(*loop_vars)[i]->Type()->Error("type clash in iteration",
|
||||
ind_type.get());
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
add_local({NewRef{}, (*loop_vars)[i]},
|
||||
{NewRef{}, ind_type}, INIT_NONE,
|
||||
nullptr, nullptr, VAR_REGULAR);
|
||||
add_local({NewRef{}, (*loop_vars)[i]}, ind_type, INIT_NONE,
|
||||
nullptr, nullptr, VAR_REGULAR);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue