diff --git a/src/EventRegistry.h b/src/EventRegistry.h index caa9a64153..dae7d82885 100644 --- a/src/EventRegistry.h +++ b/src/EventRegistry.h @@ -216,6 +216,16 @@ public: */ void AddFunc(detail::ScriptFuncPtr f); + /** + * @return The name associated with the group. + */ + const auto& GetName() const { return name; } + + /** + * @return The type of group. + */ + const auto& GetEventGroupKind() const { return kind; } + private: void UpdateFuncBodies(); diff --git a/src/Func.h b/src/Func.h index 8ec5405bbf..948b0fa7bd 100644 --- a/src/Func.h +++ b/src/Func.h @@ -265,9 +265,7 @@ public: */ void ReplaceBody(const detail::StmtPtr& old_body, detail::StmtPtr new_body); - StmtPtr CurrentBody() const { return current_body.stmts; } - int CurrentPriority() const { return current_body.priority; } - auto CurrentEventGroups() const { return current_body.groups; } + auto CurrentBody() const { return current_body; } /** * Returns the function's frame size. diff --git a/src/script_opt/Inline.cc b/src/script_opt/Inline.cc index 73d78d3b92..da06aba9ec 100644 --- a/src/script_opt/Inline.cc +++ b/src/script_opt/Inline.cc @@ -299,7 +299,11 @@ void Inliner::CoalesceEventHandlers(ScriptFuncPtr func, const std::vector(inlined_func.get(), merged_body, true); funcs.back().SetProfile(std::move(pf)); diff --git a/src/script_opt/ScriptOpt.cc b/src/script_opt/ScriptOpt.cc index 3d2bd494bd..b873aebcc5 100644 --- a/src/script_opt/ScriptOpt.cc +++ b/src/script_opt/ScriptOpt.cc @@ -41,7 +41,7 @@ void analyze_func(ScriptFuncPtr f) { // Even if we're analyzing only a subset of the scripts, we still // track all functions here because the inliner will need the full list. ASSERT(f->GetScope()); - funcs.emplace_back(f, f->GetScope(), f->CurrentBody(), f->CurrentPriority()); + funcs.emplace_back(f, f->GetScope(), f->CurrentBody()); } void analyze_lambda(LambdaExpr* l) { @@ -78,7 +78,8 @@ void analyze_global_stmts(Stmt* stmts) { global_stmts->SetScope(sc); global_stmts_ind = funcs.size(); - funcs.emplace_back(global_stmts, sc, stmts->ThisPtr(), 0); + Func::Body body{.stmts = stmts->ThisPtr(), .priority = 0}; + funcs.emplace_back(global_stmts, sc, body); } std::pair get_global_stmts() { diff --git a/src/script_opt/ScriptOpt.h b/src/script_opt/ScriptOpt.h index 4a2f79d586..ff0c0861b2 100644 --- a/src/script_opt/ScriptOpt.h +++ b/src/script_opt/ScriptOpt.h @@ -154,19 +154,20 @@ using ScriptFuncPtr = IntrusivePtr; // Info we need for tracking an instance of a function. class FuncInfo { public: - FuncInfo(ScriptFuncPtr _func, ScopePtr _scope, StmtPtr _body, int _priority) - : func(std::move(_func)), scope(std::move(_scope)), body(std::move(_body)), priority(_priority) {} + FuncInfo(ScriptFuncPtr _func, ScopePtr _scope, Func::Body _body) + : func(std::move(_func)), scope(std::move(_scope)), body(std::move(_body)) {} ScriptFunc* Func() const { return func.get(); } const ScriptFuncPtr& FuncPtr() const { return func; } const ScopePtr& Scope() const { return scope; } - const StmtPtr& Body() const { return body; } - int Priority() const { return priority; } + const StmtPtr& Body() const { return body.stmts; } + int Priority() const { return body.priority; } + auto EventGroups() const { return body.groups; } const ProfileFunc* Profile() const { return pf.get(); } std::shared_ptr ProfilePtr() const { return pf; } void SetScope(ScopePtr new_scope) { scope = std::move(new_scope); } - void SetBody(StmtPtr new_body) { body = std::move(new_body); } + void SetBody(StmtPtr new_body) { body.stmts = std::move(new_body); } void SetProfile(std::shared_ptr _pf) { pf = std::move(_pf); } bool ShouldAnalyze() const { return should_analyze; } @@ -183,9 +184,8 @@ public: protected: ScriptFuncPtr func; ScopePtr scope; - StmtPtr body; + Func::Body body; std::shared_ptr pf; - int priority; // Whether to analyze this function at all, per optimization selection // via --optimize-file/--optimize-func. If those flags aren't used,