mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 06:38:20 +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;
|
||||
}
|
||||
|
||||
string CPPCompile::LocalName(const ID* l) const {
|
||||
auto n = l->Name();
|
||||
static string trim_name(const ID* id) {
|
||||
auto n = id->Name();
|
||||
auto without_module = strstr(n, "::");
|
||||
|
||||
while ( without_module ) {
|
||||
|
@ -116,25 +116,32 @@ string CPPCompile::LocalName(const ID* l) const {
|
|||
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 {
|
||||
// We want to strip both the module and any inlining appendage.
|
||||
auto n = l->Name();
|
||||
auto without_module = strstr(n, "::");
|
||||
string CPPCompile::LocalName(const ID* l) const { return Canonicalize(trim_name(l).c_str()); }
|
||||
|
||||
while ( without_module ) {
|
||||
n = without_module + 2;
|
||||
without_module = strstr(n, "::");
|
||||
string CPPCompile::CaptureName(const ID* c) const {
|
||||
// We want to strip both the module and any inlining appendage.
|
||||
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, '.');
|
||||
|
||||
if ( appendage )
|
||||
return string(n, appendage - n) + "_";
|
||||
|
||||
return string(n) + "_";
|
||||
return n;
|
||||
}
|
||||
|
||||
string CPPCompile::Canonicalize(const char* name) const {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue