use dynamic rather than static initialization of globals for scripts compiled to C++

This commit is contained in:
Vern Paxson 2022-09-29 15:11:05 -07:00
parent 6ad28b37e6
commit 0687959f1c
5 changed files with 59 additions and 14 deletions

View file

@ -5,6 +5,7 @@
#include <cerrno>
#include "zeek/script_opt/CPP/Compile.h"
#include "zeek/script_opt/IDOptInfo.h"
extern std::unordered_set<std::string> files_with_conditionals;
@ -310,6 +311,9 @@ void CPPCompile::RegisterCompiledBody(const string& f)
void CPPCompile::GenEpilog()
{
NL();
InitializeGlobals();
NL();
for ( const auto& ii : init_infos )
GenInitExpr(ii.second);
@ -468,6 +472,9 @@ void CPPCompile::GenFinishInit()
NL();
Emit("load_BiFs__CPP();");
NL();
Emit("init_globals__CPP();");
EndBlock();
}