Internals: Favor const for map keys. No functional change intended.

This commit is contained in:
Wilson Snyder
2020-10-30 18:00:40 -04:00
parent 0c949ceba2
commit 51b0963e61
30 changed files with 73 additions and 81 deletions
+21 -23
View File
@@ -71,13 +71,13 @@ class EmitCSyms : EmitCBaseVisitor {
, m_modp{modp}
, m_scopep{scopep} {}
};
typedef std::map<string, ScopeFuncData> ScopeFuncs;
typedef std::map<string, ScopeVarData> ScopeVars;
typedef std::map<string, ScopeData> ScopeNames;
typedef std::map<const string, ScopeFuncData> ScopeFuncs;
typedef std::map<const string, ScopeVarData> ScopeVars;
typedef std::map<const string, ScopeData> ScopeNames;
typedef std::pair<AstScope*, AstNodeModule*> ScopeModPair;
typedef std::pair<AstNodeModule*, AstVar*> ModVarPair;
typedef std::vector<string> ScopeNameList;
typedef std::map<string, ScopeNameList> ScopeNameHierarchy;
typedef std::map<const string, ScopeNameList> ScopeNameHierarchy;
struct CmpName {
inline bool operator()(const ScopeModPair& lhsp, const ScopeModPair& rhsp) const {
return lhsp.first->name() < rhsp.first->name();
@@ -395,7 +395,7 @@ void EmitCSyms::emitSymHdr() {
if (v3Global.dpi()) {
puts("\n// DPI TYPES for DPI Export callbacks (Internal use)\n");
std::map<string, int> types; // Remove duplicates and sort
std::map<const string, int> types; // Remove duplicates and sort
for (ScopeFuncs::iterator it = m_scopeFuncs.begin(); it != m_scopeFuncs.end(); ++it) {
AstCFunc* funcp = it->second.m_funcp;
if (funcp->dpiExport()) {
@@ -403,9 +403,7 @@ void EmitCSyms::emitSymHdr() {
types["typedef void (*" + cbtype + ") (" + cFuncArgs(funcp) + ");\n"] = 1;
}
}
for (std::map<string, int>::iterator it = types.begin(); it != types.end(); ++it) {
puts(it->first);
}
for (const auto& i : types) puts(i.first);
}
puts("\n// SYMS CLASS\n");
@@ -432,9 +430,9 @@ void EmitCSyms::emitSymHdr() {
puts("bool __Vm_didInit;\n");
puts("\n// SUBCELL STATE\n");
for (std::vector<ScopeModPair>::iterator it = m_scopes.begin(); it != m_scopes.end(); ++it) {
AstScope* scopep = it->first;
AstNodeModule* modp = it->second;
for (const auto& i : m_scopes) {
AstScope* scopep = i.first;
AstNodeModule* modp = i.second;
if (VN_IS(modp, Class)) continue;
if (modp->isTop()) {
ofp()->printf("%-30s ", (prefixNameProtect(modp) + "*").c_str());
@@ -469,9 +467,9 @@ void EmitCSyms::emitSymHdr() {
puts(symClassName() + "(" + topClassName() + "* topp, const char* namep);\n");
puts(string("~") + symClassName() + "() {}\n");
for (std::map<int, bool>::iterator it = m_usesVfinal.begin(); it != m_usesVfinal.end(); ++it) {
puts("void " + symClassName() + "_" + cvtToStr(it->first) + "(");
if (it->second) {
for (const auto& i : m_usesVfinal) {
puts("void " + symClassName() + "_" + cvtToStr(i.first) + "(");
if (i.second) {
puts("int __Vfinal");
} else {
puts(topClassName() + "* topp");
@@ -619,9 +617,9 @@ void EmitCSyms::emitSymImp() {
puts(" , __Vm_didInit(false)\n");
puts(" // Setup submodule names\n");
char comma = ',';
for (std::vector<ScopeModPair>::iterator it = m_scopes.begin(); it != m_scopes.end(); ++it) {
AstScope* scopep = it->first;
AstNodeModule* modp = it->second;
for (const auto& i : m_scopes) {
AstScope* scopep = i.first;
AstNodeModule* modp = i.second;
if (modp->isTop()) {
} else {
puts(string(" ") + comma + " " + protect(scopep->nameDotless()));
@@ -638,9 +636,9 @@ void EmitCSyms::emitSymImp() {
puts("// Pointer to top level\n");
puts("TOPp = topp;\n");
puts("// Setup each module's pointers to their submodules\n");
for (std::vector<ScopeModPair>::iterator it = m_scopes.begin(); it != m_scopes.end(); ++it) {
AstScope* scopep = it->first;
AstNodeModule* modp = it->second;
for (const auto& i : m_scopes) {
AstScope* scopep = i.first;
AstNodeModule* modp = i.second;
if (!modp->isTop()) {
checkSplit(false);
string arrow = scopep->name();
@@ -656,9 +654,9 @@ void EmitCSyms::emitSymImp() {
puts("// Setup each module's pointer back to symbol table (for public functions)\n");
puts("TOPp->" + protect("__Vconfigure") + "(this, true);\n");
for (std::vector<ScopeModPair>::iterator it = m_scopes.begin(); it != m_scopes.end(); ++it) {
AstScope* scopep = it->first;
AstNodeModule* modp = it->second;
for (const auto& i : m_scopes) {
AstScope* scopep = i.first;
AstNodeModule* modp = i.second;
if (!modp->isTop()) {
checkSplit(false);
// first is used by AstCoverDecl's call to __vlCoverInsert