mirror of
https://github.com/zeek/zeek.git
synced 2025-10-13 12:08:20 +00:00
Scope: use class IntrusivePtr
This commit is contained in:
parent
36a26a7b43
commit
dc518c0fb4
3 changed files with 14 additions and 20 deletions
19
src/Scope.cc
19
src/Scope.cc
|
@ -16,9 +16,9 @@ static scope_list scopes;
|
|||
static Scope* top_scope;
|
||||
|
||||
|
||||
Scope::Scope(ID* id, attr_list* al)
|
||||
Scope::Scope(IntrusivePtr<ID> id, attr_list* al)
|
||||
:scope_id(std::move(id))
|
||||
{
|
||||
scope_id = id;
|
||||
attrs = al;
|
||||
return_type = 0;
|
||||
|
||||
|
@ -26,19 +26,15 @@ Scope::Scope(ID* id, attr_list* al)
|
|||
|
||||
if ( id )
|
||||
{
|
||||
BroType* id_type = id->Type();
|
||||
BroType* id_type = scope_id->Type();
|
||||
|
||||
if ( id_type->Tag() == TYPE_ERROR )
|
||||
return;
|
||||
else if ( id_type->Tag() != TYPE_FUNC )
|
||||
reporter->InternalError("bad scope id");
|
||||
|
||||
Ref(id);
|
||||
|
||||
FuncType* ft = id->Type()->AsFuncType();
|
||||
return_type = ft->YieldType();
|
||||
if ( return_type )
|
||||
Ref(return_type);
|
||||
return_type = {NewRef{}, ft->YieldType()};
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -55,9 +51,6 @@ Scope::~Scope()
|
|||
delete attrs;
|
||||
}
|
||||
|
||||
Unref(scope_id);
|
||||
Unref(return_type);
|
||||
|
||||
if ( inits )
|
||||
{
|
||||
for ( const auto& i : *inits )
|
||||
|
@ -198,9 +191,9 @@ void push_existing_scope(Scope* scope)
|
|||
scopes.push_back(scope);
|
||||
}
|
||||
|
||||
void push_scope(ID* id, attr_list* attrs)
|
||||
void push_scope(IntrusivePtr<ID> id, attr_list* attrs)
|
||||
{
|
||||
top_scope = new Scope(id, attrs);
|
||||
top_scope = new Scope(std::move(id), attrs);
|
||||
scopes.push_back(top_scope);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue