mirror of
https://github.com/zeek/zeek.git
synced 2025-10-09 18:18:19 +00:00
Merge branch 'intrusive_ptr' of https://github.com/MaxKellermann/zeek
* 'intrusive_ptr' of https://github.com/MaxKellermann/zeek: (32 commits) Scope: store IntrusivePtr in `local` Scope: pass IntrusivePtr to AddInit() DNS_Mgr: use class IntrusivePtr Scope: use class IntrusivePtr Attr: use class IntrusivePtr Expr: check_and_promote_expr() returns IntrusivePtr Frame: use class IntrusivePtr Val: RecordVal::LookupWithDefault() returns IntrusivePtr Type: RecordType::FieldDefault() returns IntrusivePtr Val: TableVal::Delete() returns IntrusivePtr Type: base_type() returns IntrusivePtr Type: init_type() returns IntrusivePtr Type: merge_types() returns IntrusivePtr Type: use class IntrusivePtr in VectorType Type: use class IntrusivePtr in EnumType Type: use class IntrusivePtr in FileType Type: use class IntrusivePtr in TypeDecl Type: make TypeDecl `final` and the dtor non-`virtual` Type: use class IntrusivePtr in TypeType Type: use class IntrusivePtr in FuncType ...
This commit is contained in:
commit
b62727a7fa
108 changed files with 1737 additions and 2067 deletions
30
src/Scope.cc
30
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,27 +26,20 @@ 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()};
|
||||
}
|
||||
}
|
||||
|
||||
Scope::~Scope()
|
||||
{
|
||||
for ( const auto& entry : local )
|
||||
Unref(entry.second);
|
||||
|
||||
if ( attrs )
|
||||
{
|
||||
for ( const auto& attr : *attrs )
|
||||
|
@ -55,9 +48,6 @@ Scope::~Scope()
|
|||
delete attrs;
|
||||
}
|
||||
|
||||
Unref(scope_id);
|
||||
Unref(return_type);
|
||||
|
||||
if ( inits )
|
||||
{
|
||||
for ( const auto& i : *inits )
|
||||
|
@ -108,7 +98,7 @@ void Scope::Describe(ODesc* d) const
|
|||
|
||||
for ( const auto& entry : local )
|
||||
{
|
||||
ID* id = entry.second;
|
||||
ID* id = entry.second.get();
|
||||
id->Describe(d);
|
||||
d->NL();
|
||||
}
|
||||
|
@ -118,7 +108,7 @@ TraversalCode Scope::Traverse(TraversalCallback* cb) const
|
|||
{
|
||||
for ( const auto& entry : local )
|
||||
{
|
||||
ID* id = entry.second;
|
||||
ID* id = entry.second.get();
|
||||
TraversalCode tc = id->Traverse(cb);
|
||||
HANDLE_TC_STMT_PRE(tc);
|
||||
}
|
||||
|
@ -183,11 +173,11 @@ IntrusivePtr<ID> install_ID(const char* name, const char* module_name,
|
|||
auto id = make_intrusive<ID>(full_name.data(), scope, is_export);
|
||||
|
||||
if ( SCOPE_FUNCTION != scope )
|
||||
global_scope()->Insert(std::move(full_name), IntrusivePtr{id}.release());
|
||||
global_scope()->Insert(std::move(full_name), id);
|
||||
else
|
||||
{
|
||||
id->SetOffset(top_scope->Length());
|
||||
top_scope->Insert(std::move(full_name), IntrusivePtr{id}.release());
|
||||
top_scope->Insert(std::move(full_name), id);
|
||||
}
|
||||
|
||||
return id;
|
||||
|
@ -198,9 +188,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