mirror of
https://github.com/zeek/zeek.git
synced 2025-10-14 20:48: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;
|
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,
|
void Func::AddBody(detail::StmtPtr new_body, const std::vector<detail::IDPtr>& new_inits,
|
||||||
size_t new_frame_size, int priority)
|
size_t new_frame_size, int priority)
|
||||||
{
|
{
|
||||||
|
|
15
src/Func.h
15
src/Func.h
|
@ -44,6 +44,7 @@ using IDPtr = IntrusivePtr<ID>;
|
||||||
using StmtPtr = IntrusivePtr<Stmt>;
|
using StmtPtr = IntrusivePtr<Stmt>;
|
||||||
|
|
||||||
class ScriptFunc;
|
class ScriptFunc;
|
||||||
|
class FunctionIngredients;
|
||||||
|
|
||||||
} // namespace detail
|
} // namespace detail
|
||||||
|
|
||||||
|
@ -114,14 +115,15 @@ public:
|
||||||
return Invoke(&zargs);
|
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,
|
virtual void AddBody(detail::StmtPtr new_body, const std::vector<detail::IDPtr>& new_inits,
|
||||||
size_t new_frame_size, int priority,
|
size_t new_frame_size, int priority,
|
||||||
const std::set<EventGroupPtr>& groups);
|
const std::set<EventGroupPtr>& groups);
|
||||||
|
void AddBody(detail::StmtPtr new_body, const std::vector<detail::IDPtr>& new_inits,
|
||||||
// Add a new event handler to an existing function (event).
|
size_t new_frame_size, int priority = 0);
|
||||||
virtual void AddBody(detail::StmtPtr new_body, const std::vector<detail::IDPtr>& new_inits,
|
void AddBody(detail::StmtPtr new_body, size_t new_frame_size);
|
||||||
size_t new_frame_size, int priority = 0);
|
|
||||||
|
|
||||||
virtual void SetScope(detail::ScopePtr newscope);
|
virtual void SetScope(detail::ScopePtr newscope);
|
||||||
virtual detail::ScopePtr GetScope() const { return scope; }
|
virtual detail::ScopePtr GetScope() const { return scope; }
|
||||||
|
@ -333,8 +335,7 @@ struct CallInfo
|
||||||
const zeek::Args& args;
|
const zeek::Args& args;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Struct that collects all the specifics defining a Func. Used for ScriptFuncs
|
// Class that collects all the specifics defining a Func.
|
||||||
// with closures.
|
|
||||||
class FunctionIngredients
|
class FunctionIngredients
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -845,9 +845,7 @@ void end_func(StmtPtr body, const char* module_name, bool free_of_conditionals)
|
||||||
id->SetConst();
|
id->SetConst();
|
||||||
}
|
}
|
||||||
|
|
||||||
id->GetVal()->AsFunc()->AddBody(ingredients->Body(), ingredients->Inits(),
|
id->GetVal()->AsFunc()->AddBody(*ingredients);
|
||||||
ingredients->FrameSize(), ingredients->Priority(),
|
|
||||||
ingredients->Groups());
|
|
||||||
|
|
||||||
script_coverage_mgr.AddFunction(id, ingredients->Body());
|
script_coverage_mgr.AddFunction(id, ingredients->Body());
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue