mirror of
https://github.com/zeek/zeek.git
synced 2025-10-07 09:08:20 +00:00
Type: init_type() returns IntrusivePtr
This commit is contained in:
parent
cf11d78483
commit
f0a357cadf
4 changed files with 10 additions and 10 deletions
|
@ -3112,7 +3112,7 @@ TableConstructorExpr::TableConstructorExpr(IntrusivePtr<ListExpr> constructor_li
|
|||
SetType(make_intrusive<TableType>(make_intrusive<TypeList>(IntrusivePtr{AdoptRef{}, base_type(TYPE_ANY)}), nullptr));
|
||||
else
|
||||
{
|
||||
SetType({AdoptRef{}, init_type(op.get())});
|
||||
SetType(init_type(op.get()));
|
||||
|
||||
if ( ! type )
|
||||
SetError();
|
||||
|
@ -3225,7 +3225,7 @@ SetConstructorExpr::SetConstructorExpr(IntrusivePtr<ListExpr> constructor_list,
|
|||
if ( op->AsListExpr()->Exprs().empty() )
|
||||
SetType(make_intrusive<::SetType>(make_intrusive<TypeList>(IntrusivePtr{AdoptRef{}, base_type(TYPE_ANY)}), nullptr));
|
||||
else
|
||||
SetType({AdoptRef{}, init_type(op.get())});
|
||||
SetType(init_type(op.get()));
|
||||
}
|
||||
|
||||
if ( ! type )
|
||||
|
|
10
src/Type.cc
10
src/Type.cc
|
@ -1983,7 +1983,7 @@ static BroType* reduce_type(BroType* t)
|
|||
return t;
|
||||
}
|
||||
|
||||
BroType* init_type(Expr* init)
|
||||
IntrusivePtr<BroType> init_type(Expr* init)
|
||||
{
|
||||
if ( init->Tag() != EXPR_LIST )
|
||||
{
|
||||
|
@ -1999,7 +1999,7 @@ BroType* init_type(Expr* init)
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
return t.release();
|
||||
return t;
|
||||
}
|
||||
|
||||
ListExpr* init_list = init->AsListExpr();
|
||||
|
@ -2017,7 +2017,7 @@ BroType* init_type(Expr* init)
|
|||
if ( e0->IsRecordElement(0) )
|
||||
// ListExpr's know how to build a record from their
|
||||
// components.
|
||||
return init_list->InitType().release();
|
||||
return init_list->InitType();
|
||||
|
||||
auto t = e0->InitType();
|
||||
|
||||
|
@ -2049,7 +2049,7 @@ BroType* init_type(Expr* init)
|
|||
|
||||
if ( t->Tag() == TYPE_TABLE && ! t->AsTableType()->IsSet() )
|
||||
// A list of table elements.
|
||||
return t.release();
|
||||
return t;
|
||||
|
||||
// A set. If the index type isn't yet a type list, make
|
||||
// it one, as that's what's required for creating a set type.
|
||||
|
@ -2060,7 +2060,7 @@ BroType* init_type(Expr* init)
|
|||
t = std::move(tl);
|
||||
}
|
||||
|
||||
return new SetType({AdoptRef{}, t.release()->AsTypeList()}, nullptr);
|
||||
return make_intrusive<SetType>(IntrusivePtr{AdoptRef{}, t.release()->AsTypeList()}, nullptr);
|
||||
}
|
||||
|
||||
bool is_atomic_type(const BroType* t)
|
||||
|
|
|
@ -725,7 +725,7 @@ IntrusivePtr<BroType> merge_types(const BroType* t1, const BroType* t2);
|
|||
IntrusivePtr<BroType> merge_type_list(ListExpr* elements);
|
||||
|
||||
// Given an expression, infer its type when used for an initialization.
|
||||
extern BroType* init_type(Expr* init);
|
||||
IntrusivePtr<BroType> init_type(Expr* init);
|
||||
|
||||
// Returns true if argument is an atomic type.
|
||||
bool is_atomic_type(const BroType* t);
|
||||
|
|
|
@ -64,7 +64,7 @@ static void make_var(ID* id, IntrusivePtr<BroType> t, init_class c,
|
|||
if ( id->Type() && id->Type()->Tag() != TYPE_ERROR )
|
||||
{
|
||||
if ( dt != VAR_REDEF &&
|
||||
(! init || ! do_init || (! t && ! (t = {AdoptRef{}, init_type(init.get())}))) )
|
||||
(! init || ! do_init || (! t && ! (t = init_type(init.get())))) )
|
||||
{
|
||||
id->Error("already defined", init.get());
|
||||
return;
|
||||
|
@ -103,7 +103,7 @@ static void make_var(ID* id, IntrusivePtr<BroType> t, init_class c,
|
|||
return;
|
||||
}
|
||||
|
||||
t = {AdoptRef{}, init_type(init.get())};
|
||||
t = init_type(init.get());
|
||||
if ( ! t )
|
||||
{
|
||||
id->SetType({AdoptRef{}, error_type()});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue