convert scopes to be managed using IntrusivePtr's

This commit is contained in:
Vern Paxson 2021-05-30 17:20:29 -07:00
parent f2f041b63b
commit efd03d41f8
16 changed files with 41 additions and 48 deletions

View file

@ -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();
}