mirror of
https://github.com/zeek/zeek.git
synced 2025-10-15 04:58:21 +00:00
use Ingredients directly for constructing functions
This commit is contained in:
parent
b6464814c9
commit
82588ca311
3 changed files with 17 additions and 10 deletions
|
@ -123,6 +123,14 @@ std::string render_call_stack()
|
|||
return rval;
|
||||
}
|
||||
|
||||
void Func::AddBody(const detail::FunctionIngredients& ingr, detail::StmtPtr new_body)
|
||||
{
|
||||
if ( ! new_body )
|
||||
new_body = ingr.Body();
|
||||
|
||||
AddBody(new_body, ingr.Inits(), ingr.FrameSize(), ingr.Priority(), ingr.Groups());
|
||||
}
|
||||
|
||||
void Func::AddBody(detail::StmtPtr new_body, const std::vector<detail::IDPtr>& new_inits,
|
||||
size_t new_frame_size, int priority)
|
||||
{
|
||||
|
|
13
src/Func.h
13
src/Func.h
|
@ -44,6 +44,7 @@ using IDPtr = IntrusivePtr<ID>;
|
|||
using StmtPtr = IntrusivePtr<Stmt>;
|
||||
|
||||
class ScriptFunc;
|
||||
class FunctionIngredients;
|
||||
|
||||
} // namespace detail
|
||||
|
||||
|
@ -114,14 +115,15 @@ public:
|
|||
return Invoke(&zargs);
|
||||
}
|
||||
|
||||
// Add a new event handler to an existing function (event).
|
||||
// Various ways to add a new event handler to an existing function
|
||||
// (event).
|
||||
void AddBody(const detail::FunctionIngredients& ingr, detail::StmtPtr new_body = nullptr);
|
||||
virtual void AddBody(detail::StmtPtr new_body, const std::vector<detail::IDPtr>& new_inits,
|
||||
size_t new_frame_size, int priority,
|
||||
const std::set<EventGroupPtr>& groups);
|
||||
|
||||
// Add a new event handler to an existing function (event).
|
||||
virtual void AddBody(detail::StmtPtr new_body, const std::vector<detail::IDPtr>& new_inits,
|
||||
void AddBody(detail::StmtPtr new_body, const std::vector<detail::IDPtr>& new_inits,
|
||||
size_t new_frame_size, int priority = 0);
|
||||
void AddBody(detail::StmtPtr new_body, size_t new_frame_size);
|
||||
|
||||
virtual void SetScope(detail::ScopePtr newscope);
|
||||
virtual detail::ScopePtr GetScope() const { return scope; }
|
||||
|
@ -333,8 +335,7 @@ struct CallInfo
|
|||
const zeek::Args& args;
|
||||
};
|
||||
|
||||
// Struct that collects all the specifics defining a Func. Used for ScriptFuncs
|
||||
// with closures.
|
||||
// Class that collects all the specifics defining a Func.
|
||||
class FunctionIngredients
|
||||
{
|
||||
public:
|
||||
|
|
|
@ -845,9 +845,7 @@ void end_func(StmtPtr body, const char* module_name, bool free_of_conditionals)
|
|||
id->SetConst();
|
||||
}
|
||||
|
||||
id->GetVal()->AsFunc()->AddBody(ingredients->Body(), ingredients->Inits(),
|
||||
ingredients->FrameSize(), ingredients->Priority(),
|
||||
ingredients->Groups());
|
||||
id->GetVal()->AsFunc()->AddBody(*ingredients);
|
||||
|
||||
script_coverage_mgr.AddFunction(id, ingredients->Body());
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue