mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 14:48:21 +00:00
Merge remote-tracking branch 'origin/topic/vern/canonicalize-std-string'
* origin/topic/vern/canonicalize-std-string: switched CPPCompile::Canonicalize() to take std::string instead of const char*
This commit is contained in:
commit
c171d9e8c2
8 changed files with 16 additions and 14 deletions
4
CHANGES
4
CHANGES
|
@ -1,3 +1,7 @@
|
||||||
|
7.1.0-dev.459 | 2024-11-04 18:47:02 +0100
|
||||||
|
|
||||||
|
* switched CPPCompile::Canonicalize() to take std::string instead of const char* (Vern Paxson, Corelight)
|
||||||
|
|
||||||
7.1.0-dev.457 | 2024-11-04 16:33:14 +0100
|
7.1.0-dev.457 | 2024-11-04 16:33:14 +0100
|
||||||
|
|
||||||
* minor ZAM BTest updates for recently added fnv1a64 BiF (Vern Paxson, Corelight)
|
* minor ZAM BTest updates for recently added fnv1a64 BiF (Vern Paxson, Corelight)
|
||||||
|
|
2
VERSION
2
VERSION
|
@ -1 +1 @@
|
||||||
7.1.0-dev.457
|
7.1.0-dev.459
|
||||||
|
|
|
@ -10,7 +10,7 @@ void CPPCompile::DeclareFunc(const FuncInfo& func) {
|
||||||
if ( ! IsCompilable(func) )
|
if ( ! IsCompilable(func) )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
auto fname = Canonicalize(BodyName(func).c_str()) + "_zf";
|
auto fname = Canonicalize(BodyName(func)) + "_zf";
|
||||||
auto pf = func.Profile();
|
auto pf = func.Profile();
|
||||||
auto f = func.Func();
|
auto f = func.Func();
|
||||||
const auto& body = func.Body();
|
const auto& body = func.Body();
|
||||||
|
@ -25,7 +25,7 @@ void CPPCompile::DeclareFunc(const FuncInfo& func) {
|
||||||
void CPPCompile::DeclareLambda(const LambdaExpr* l, const ProfileFunc* pf) {
|
void CPPCompile::DeclareLambda(const LambdaExpr* l, const ProfileFunc* pf) {
|
||||||
ASSERT(is_CPP_compilable(pf));
|
ASSERT(is_CPP_compilable(pf));
|
||||||
|
|
||||||
auto lname = Canonicalize(l->Name().c_str()) + "_lb";
|
auto lname = Canonicalize(l->Name()) + "_lb";
|
||||||
auto body = l->Ingredients()->Body();
|
auto body = l->Ingredients()->Body();
|
||||||
auto l_id = l->Ingredients()->GetID();
|
auto l_id = l->Ingredients()->GetID();
|
||||||
auto& ids = l->OuterIDs();
|
auto& ids = l->OuterIDs();
|
||||||
|
|
|
@ -646,7 +646,7 @@ string CPPCompile::GenLambdaExpr(const Expr* e) {
|
||||||
|
|
||||||
string CPPCompile::GenLambdaExpr(const Expr* e, string capture_args) {
|
string CPPCompile::GenLambdaExpr(const Expr* e, string capture_args) {
|
||||||
auto l = static_cast<const LambdaExpr*>(e);
|
auto l = static_cast<const LambdaExpr*>(e);
|
||||||
auto name = Canonicalize(l->Name().c_str()) + "_lb_cl";
|
auto name = Canonicalize(l->Name()) + "_lb_cl";
|
||||||
auto cl_args = string("\"") + name + "\"" + std::move(capture_args);
|
auto cl_args = string("\"") + name + "\"" + std::move(capture_args);
|
||||||
auto body = string("make_intrusive<") + name + ">(" + cl_args + ")";
|
auto body = string("make_intrusive<") + name + ">(" + cl_args + ")";
|
||||||
auto func = string("make_intrusive<CPPLambdaFunc>(\"") + l->Name() + "\", cast_intrusive<FuncType>(" +
|
auto func = string("make_intrusive<CPPLambdaFunc>(\"") + l->Name() + "\", cast_intrusive<FuncType>(" +
|
||||||
|
|
|
@ -10,7 +10,7 @@ void CPPCompile::CompileFunc(const FuncInfo& func) {
|
||||||
if ( ! IsCompilable(func) )
|
if ( ! IsCompilable(func) )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
auto fname = Canonicalize(BodyName(func).c_str()) + "_zf";
|
auto fname = Canonicalize(BodyName(func)) + "_zf";
|
||||||
auto pf = func.Profile();
|
auto pf = func.Profile();
|
||||||
auto f = func.Func();
|
auto f = func.Func();
|
||||||
const auto& body = func.Body();
|
const auto& body = func.Body();
|
||||||
|
@ -19,7 +19,7 @@ void CPPCompile::CompileFunc(const FuncInfo& func) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void CPPCompile::CompileLambda(const LambdaExpr* l, const ProfileFunc* pf) {
|
void CPPCompile::CompileLambda(const LambdaExpr* l, const ProfileFunc* pf) {
|
||||||
auto lname = Canonicalize(l->Name().c_str()) + "_lb";
|
auto lname = Canonicalize(l->Name()) + "_lb";
|
||||||
auto body = l->Ingredients()->Body();
|
auto body = l->Ingredients()->Body();
|
||||||
auto l_id = l->Ingredients()->GetID();
|
auto l_id = l->Ingredients()->GetID();
|
||||||
auto& ids = l->OuterIDs();
|
auto& ids = l->OuterIDs();
|
||||||
|
|
|
@ -259,7 +259,7 @@ void CPPCompile::GenStandaloneActivation() {
|
||||||
|
|
||||||
auto f = func.Func();
|
auto f = func.Func();
|
||||||
auto fname = BodyName(func);
|
auto fname = BodyName(func);
|
||||||
auto bname = Canonicalize(fname.c_str()) + "_zf";
|
auto bname = Canonicalize(fname) + "_zf";
|
||||||
|
|
||||||
if ( compiled_funcs.count(bname) == 0 )
|
if ( compiled_funcs.count(bname) == 0 )
|
||||||
// We didn't wind up compiling it.
|
// We didn't wind up compiling it.
|
||||||
|
|
|
@ -129,7 +129,7 @@ static string trim_name(const ID* id) {
|
||||||
return ns;
|
return ns;
|
||||||
}
|
}
|
||||||
|
|
||||||
string CPPCompile::LocalName(const ID* l) const { return Canonicalize(trim_name(l).c_str()); }
|
string CPPCompile::LocalName(const ID* l) const { return Canonicalize(trim_name(l)); }
|
||||||
|
|
||||||
string CPPCompile::CaptureName(const ID* c) const {
|
string CPPCompile::CaptureName(const ID* c) const {
|
||||||
// We want to strip both the module and any inlining appendage.
|
// We want to strip both the module and any inlining appendage.
|
||||||
|
@ -139,15 +139,13 @@ string CPPCompile::CaptureName(const ID* c) const {
|
||||||
if ( appendage != string::npos )
|
if ( appendage != string::npos )
|
||||||
tn.erase(tn.begin() + appendage, tn.end());
|
tn.erase(tn.begin() + appendage, tn.end());
|
||||||
|
|
||||||
return Canonicalize(tn.c_str());
|
return Canonicalize(tn);
|
||||||
}
|
}
|
||||||
|
|
||||||
string CPPCompile::Canonicalize(const char* name) const {
|
string CPPCompile::Canonicalize(const std::string& name) const {
|
||||||
string cname;
|
string cname;
|
||||||
|
|
||||||
for ( int i = 0; name[i]; ++i ) {
|
for ( auto c : name ) {
|
||||||
auto c = name[i];
|
|
||||||
|
|
||||||
// Strip <>'s - these get introduced for lambdas.
|
// Strip <>'s - these get introduced for lambdas.
|
||||||
if ( c == '<' || c == '>' )
|
if ( c == '<' || c == '>' )
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -47,7 +47,7 @@ std::string CaptureName(const IDPtr& l) const { return CaptureName(l.get()); }
|
||||||
|
|
||||||
// Returns a canonicalized name, with various non-alphanumeric characters
|
// Returns a canonicalized name, with various non-alphanumeric characters
|
||||||
// stripped or transformed, and guaranteed not to conflict with C++ keywords.
|
// stripped or transformed, and guaranteed not to conflict with C++ keywords.
|
||||||
std::string Canonicalize(const char* name) const;
|
std::string Canonicalize(const std::string& name) const;
|
||||||
|
|
||||||
// Returns the name of the global corresponding to an expression (which must
|
// Returns the name of the global corresponding to an expression (which must
|
||||||
// be a EXPR_NAME).
|
// be a EXPR_NAME).
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue