mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 14:48:21 +00:00
fix to -O gen-C++ for dealing with "hidden" parameters
This commit is contained in:
parent
8025ee74ef
commit
2b64e3b05e
1 changed files with 23 additions and 16 deletions
|
@ -107,8 +107,8 @@ const string& CPPCompile::IDNameStr(const ID* id) {
|
||||||
return l->second;
|
return l->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
string CPPCompile::LocalName(const ID* l) const {
|
static string trim_name(const ID* id) {
|
||||||
auto n = l->Name();
|
auto n = id->Name();
|
||||||
auto without_module = strstr(n, "::");
|
auto without_module = strstr(n, "::");
|
||||||
|
|
||||||
while ( without_module ) {
|
while ( without_module ) {
|
||||||
|
@ -116,25 +116,32 @@ string CPPCompile::LocalName(const ID* l) const {
|
||||||
without_module = strstr(n, "::");
|
without_module = strstr(n, "::");
|
||||||
}
|
}
|
||||||
|
|
||||||
return Canonicalize(n);
|
string ns = n;
|
||||||
|
|
||||||
|
// Look for suffices added by check_params() (src/Var.cc).
|
||||||
|
static auto hidden_suffix = "-hidden";
|
||||||
|
static auto hidden_suffix_len = strlen(hidden_suffix);
|
||||||
|
auto hidden_loc = ns.find(hidden_suffix);
|
||||||
|
|
||||||
|
if ( hidden_loc != string::npos )
|
||||||
|
ns.erase(hidden_loc, hidden_loc + hidden_suffix_len);
|
||||||
|
|
||||||
|
return ns;
|
||||||
}
|
}
|
||||||
|
|
||||||
string CPPCompile::CaptureName(const ID* l) const {
|
string CPPCompile::LocalName(const ID* l) const { return Canonicalize(trim_name(l).c_str()); }
|
||||||
// We want to strip both the module and any inlining appendage.
|
|
||||||
auto n = l->Name();
|
|
||||||
auto without_module = strstr(n, "::");
|
|
||||||
|
|
||||||
while ( without_module ) {
|
string CPPCompile::CaptureName(const ID* c) const {
|
||||||
n = without_module + 2;
|
// We want to strip both the module and any inlining appendage.
|
||||||
without_module = strstr(n, "::");
|
auto n = Canonicalize(trim_name(c).c_str());
|
||||||
|
|
||||||
|
auto appendage = n.find(".");
|
||||||
|
if ( appendage != string::npos ) {
|
||||||
|
n.erase(n.begin() + appendage, n.end());
|
||||||
|
n.push_back('_');
|
||||||
}
|
}
|
||||||
|
|
||||||
auto appendage = strchr(n, '.');
|
return n;
|
||||||
|
|
||||||
if ( appendage )
|
|
||||||
return string(n, appendage - n) + "_";
|
|
||||||
|
|
||||||
return string(n) + "_";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
string CPPCompile::Canonicalize(const char* name) const {
|
string CPPCompile::Canonicalize(const char* name) const {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue