Fix VPI TOP level variable iteration (#3919) (#4618)

This commit is contained in:
Marlon James
2023-11-07 07:47:55 -05:00
committed by GitHub
parent dc10118d3b
commit 5ba7084815
10 changed files with 899 additions and 32 deletions
+13 -15
View File
@@ -152,25 +152,23 @@ class EmitCSyms final : EmitCBaseVisitorConst {
static string scopeDecodeIdentifier(const string& scpname) {
string out = scpname;
// Remove hierarchy
string::size_type pos = out.rfind('.');
string::size_type pos = string::npos;
// If there's more than one ident and an escape, find the true last ident
if (pos != string::npos && scpname.find('\\') != string::npos) {
size_t i = 0;
// always makes progress
while (i < scpname.length()) {
if (scpname[i] == '\\') {
while (i < scpname.length() && scpname[i] != ' ') ++i;
++i; // Proc ' ', it should always be there. Then grab '.' on next cycle
} else {
while (i < scpname.length() && scpname[i] != '.') ++i;
if (i < scpname.length()) { pos = i++; }
}
// Remove hierarchy
size_t i = 0;
// always makes progress
while (i < scpname.length()) {
if (scpname[i] == '\\') {
while (i < scpname.length() && scpname[i] != ' ') ++i;
++i; // Proc ' ', it should always be there. Then grab '.' on next cycle
} else {
while (i < scpname.length() && scpname[i] != '.') ++i;
if (i < scpname.length()) pos = i++;
}
}
if (pos != std::string::npos) out.erase(0, pos + 1);
// Decode all escaped characters
while ((pos = out.find("__0")) != string::npos) {
unsigned int x;
@@ -230,7 +228,7 @@ class EmitCSyms final : EmitCBaseVisitorConst {
}
// UINFO(9, "For " << scopep->name() << " - " << varp->name() << " Scp "
// << scpName << "Var " << varBase << endl);
const string varBasePretty = AstNode::prettyName(VName::dehash(varBase));
const string varBasePretty = AstNode::vpiName(VName::dehash(varBase));
const string scpPretty = AstNode::prettyName(VName::dehash(scpName));
const string scpSym = scopeSymString(VName::dehash(scpName));
// UINFO(9, " scnameins sp " << scpName << " sp " << scpPretty << " ss "