mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 06:38:20 +00:00
extensive rewrite of generation & execution of run-time initialization
This commit is contained in:
parent
bc3bf4ea6c
commit
e1a760e674
26 changed files with 3459 additions and 1580 deletions
|
@ -34,10 +34,8 @@ void CPPCompile::CompileLambda(const LambdaExpr* l, const ProfileFunc* pf)
|
|||
DefineBody(l_id->GetType<FuncType>(), pf, lname, body, &ids, FUNC_FLAVOR_FUNCTION);
|
||||
}
|
||||
|
||||
void CPPCompile::GenInvokeBody(const string& fname, const TypePtr& t, const string& args)
|
||||
void CPPCompile::GenInvokeBody(const string& call, const TypePtr& t)
|
||||
{
|
||||
auto call = fname + "(" + args + ")";
|
||||
|
||||
if ( ! t || t->Tag() == TYPE_VOID )
|
||||
{
|
||||
Emit("%s;", call);
|
||||
|
@ -144,7 +142,7 @@ void CPPCompile::InitializeEvents(const ProfileFunc* pf)
|
|||
// returns an EventHandlerPtr, sigh.
|
||||
Emit("if ( event_registry->Lookup(\"%s\") )", e);
|
||||
StartBlock();
|
||||
Emit("%s = event_registry->Register(\"%s\");", ev_name.c_str(), e);
|
||||
Emit("%s = event_registry->Register(\"%s\");", ev_name, e);
|
||||
EndBlock();
|
||||
Emit("did_init = true;");
|
||||
EndBlock();
|
||||
|
@ -233,6 +231,16 @@ string CPPCompile::BodyName(const FuncInfo& func)
|
|||
return fname + "__" + Fmt(static_cast<int>(i));
|
||||
}
|
||||
|
||||
p_hash_type CPPCompile::BodyHash(const Stmt* body)
|
||||
{
|
||||
ASSERT(body_names.count(body) > 0);
|
||||
|
||||
auto& body_name = body_names[body];
|
||||
ASSERT(body_hashes.count(body_name) > 0);
|
||||
|
||||
return body_hashes[body_name];
|
||||
}
|
||||
|
||||
string CPPCompile::GenArgs(const RecordTypePtr& params, const Expr* e)
|
||||
{
|
||||
const auto& exprs = e->AsListExpr()->Exprs();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue