mirror of
https://github.com/zeek/zeek.git
synced 2025-10-15 21:18:20 +00:00
convert scopes to be managed using IntrusivePtr's
This commit is contained in:
parent
f2f041b63b
commit
efd03d41f8
16 changed files with 41 additions and 48 deletions
|
@ -10,7 +10,7 @@
|
|||
namespace zeek::detail {
|
||||
|
||||
|
||||
void RD_Decorate::TraverseFunction(const Func* f, Scope* scope, StmtPtr body)
|
||||
void RD_Decorate::TraverseFunction(const Func* f, ScopePtr scope, StmtPtr body)
|
||||
{
|
||||
func_flavor = f->Flavor();
|
||||
|
||||
|
|
|
@ -54,11 +54,8 @@ public:
|
|||
{ }
|
||||
|
||||
// Traverses the given function body, using the first two
|
||||
// arguments for context. "scope" is a Scope* rather than
|
||||
// a ScopePtr because the various scope management functions
|
||||
// (e.g., push_existing_scope(), current_scope()) traffic in
|
||||
// Scope*'s.
|
||||
void TraverseFunction(const Func* f, Scope* scope, StmtPtr body);
|
||||
// arguments for context.
|
||||
void TraverseFunction(const Func* f, ScopePtr scope, StmtPtr body);
|
||||
|
||||
TraversalCode PreStmt(const Stmt*) override;
|
||||
TraversalCode PostStmt(const Stmt*) override;
|
||||
|
|
|
@ -28,9 +28,11 @@ void (*CPP_init_hook)() = nullptr;
|
|||
// Tracks all of the loaded functions (including event handlers and hooks).
|
||||
static std::vector<FuncInfo> funcs;
|
||||
|
||||
static ZAMCompiler* ZAM = nullptr;
|
||||
|
||||
|
||||
void optimize_func(ScriptFunc* f, std::shared_ptr<ProfileFunc> pf,
|
||||
ScopePtr scope_ptr, StmtPtr& body,
|
||||
ScopePtr scope, StmtPtr& body,
|
||||
AnalyOpt& analysis_options)
|
||||
{
|
||||
if ( reporter->Errors() > 0 )
|
||||
|
@ -57,7 +59,6 @@ void optimize_func(ScriptFunc* f, std::shared_ptr<ProfileFunc> pf,
|
|||
return;
|
||||
}
|
||||
|
||||
auto scope = scope_ptr.release();
|
||||
push_existing_scope(scope);
|
||||
|
||||
auto rc = std::make_shared<Reducer>();
|
||||
|
@ -162,8 +163,8 @@ void analyze_func(ScriptFuncPtr f)
|
|||
*analysis_options.only_func != f->Name() )
|
||||
return;
|
||||
|
||||
funcs.emplace_back(f, ScopePtr{NewRef{}, f->GetScope()},
|
||||
f->CurrentBody(), f->CurrentPriority());
|
||||
funcs.emplace_back(f, f->GetScope(), f->CurrentBody(),
|
||||
f->CurrentPriority());
|
||||
}
|
||||
|
||||
const FuncInfo* analyze_global_stmts(Stmt* stmts)
|
||||
|
@ -182,7 +183,7 @@ const FuncInfo* analyze_global_stmts(Stmt* stmts)
|
|||
StmtPtr stmts_p{NewRef{}, stmts};
|
||||
auto sf = make_intrusive<ScriptFunc>(id, stmts_p, empty_inits, sc->Length(), 0);
|
||||
|
||||
funcs.emplace_back(sf, ScopePtr{NewRef{}, sc}, stmts_p, 0);
|
||||
funcs.emplace_back(sf, sc, stmts_p, 0);
|
||||
|
||||
return &funcs.back();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue