Internals: Cleanup string casts. No functional change.

This commit is contained in:
Wilson Snyder 2018-10-13 22:02:39 -04:00
parent bccb9f794c
commit e4d638c73d
25 changed files with 45 additions and 45 deletions

View File

@ -1405,7 +1405,7 @@ public:
virtual string name() const { return m_name; } // * = Scope name
virtual void name(const string& name) { m_name = name; }
string nameDotless() const;
string nameVlSym() const { return (((string)"vlSymsp->") + nameDotless()); }
string nameVlSym() const { return ((string("vlSymsp->")) + nameDotless()); }
AstNodeModule* modp() const { return m_modp; }
void addVarp(AstNode* nodep) { addOp1p(nodep); }
AstNode* varsp() const { return op1p(); } // op1 = AstVarScope's
@ -2585,8 +2585,8 @@ public:
ASTNODE_NODE_FUNCS(Display)
virtual void dump(std::ostream& str);
virtual const char* broken() const { BROKEN_RTN(!fmtp()); return NULL; }
virtual string verilogKwd() const { return (filep() ? (string)"$f"+(string)displayType().ascii()
: (string)"$"+(string)displayType().ascii()); }
virtual string verilogKwd() const { return (filep() ? string("$f")+string(displayType().ascii())
: string("$")+string(displayType().ascii())); }
virtual bool isGateOptimizable() const { return false; }
virtual bool isPredictOptimizable() const { return false; }
virtual bool isPure() const { return false; } // SPECIAL: $display has 'visual' ordering

View File

@ -197,7 +197,7 @@ private:
// To keep correct visual order, must add before other Text's
AstNode* afterp = nodep->scopeAttrp();
if (afterp) afterp->unlinkFrBackWithNext();
nodep->scopeAttrp(new AstText(nodep->fileline(), (string)"__DOT__"+m_namedScope));
nodep->scopeAttrp(new AstText(nodep->fileline(), string("__DOT__")+m_namedScope));
if (afterp) nodep->scopeAttrp(afterp);
}
iterateChildren(nodep);

View File

@ -75,7 +75,7 @@ private:
if (vscp->user1p()) return ((AstVarScope*)vscp->user1p());
AstVar* varp = vscp->varp();
if (!varp->width1()) varp->v3error("Unsupported: Clock edge on non-single bit signal: "<<varp->prettyName());
string newvarname = ((string)"__Vclklast__"+vscp->scopep()->nameDotless()+"__"+varp->name());
string newvarname = (string("__Vclklast__")+vscp->scopep()->nameDotless()+"__"+varp->name());
AstVar* newvarp = new AstVar(vscp->fileline(), AstVarType::MODULETEMP, newvarname, VFlagLogicPacked(), 1);
newvarp->noReset(true); // Reset by below assign
m_modp->addStmtp(newvarp);

View File

@ -1075,8 +1075,8 @@ private:
if (!m_modp) nodep->v3fatalSrc("Not under module");
// We could create just one temp variable, but we'll get better optimization
// if we make one per term.
string name1 = ((string)"__Vconcswap"+cvtToStr(m_modp->varNumGetInc()));
string name2 = ((string)"__Vconcswap"+cvtToStr(m_modp->varNumGetInc()));
string name1 = (string("__Vconcswap")+cvtToStr(m_modp->varNumGetInc()));
string name2 = (string("__Vconcswap")+cvtToStr(m_modp->varNumGetInc()));
AstVar* temp1p = new AstVar(sel1p->fileline(), AstVarType::BLOCKTEMP, name1,
VFlagLogicPacked(), msb1-lsb1+1);
AstVar* temp2p = new AstVar(sel2p->fileline(), AstVarType::BLOCKTEMP, name2,

View File

@ -162,7 +162,7 @@ private:
// We'll do this, and make the if(...) coverinc later.
// Add signal to hold the old value
string newvarname = (string)"__Vtogcov__"+nodep->shortName();
string newvarname = string("__Vtogcov__")+nodep->shortName();
AstVar* chgVarp = new AstVar(nodep->fileline(), AstVarType::MODULETEMP, newvarname, nodep);
chgVarp->fileline()->modifyWarnOff(V3ErrorCode::UNUSED, true);
m_modp->addStmtp(chgVarp);

View File

@ -58,7 +58,7 @@ private:
UINFO(6," Deep "<<nodep<<endl);
//if (debug()>=9) nodep->dumpTree(cout,"deep:");
string newvarname = ((string)"__Vdeeptemp"+cvtToStr(m_modp->varNumGetInc()));
string newvarname = (string("__Vdeeptemp")+cvtToStr(m_modp->varNumGetInc()));
AstVar* varp = new AstVar(nodep->fileline(), AstVarType::STMTTEMP, newvarname,
// Width, not widthMin, as we may be in middle of BITSEL expression which
// though it's one bit wide, needs the mask in the upper bits.

View File

@ -233,7 +233,7 @@ public:
nodep->v3fatalSrc("Case statements should have been reduced out");
}
virtual void visit(AstComment* nodep) {
putsDecoration((string)"// "+nodep->name()+" at "+nodep->fileline()->ascii()+"\n");
putsDecoration(string("// ")+nodep->name()+" at "+nodep->fileline()->ascii()+"\n");
iterateChildren(nodep);
}
virtual void visit(AstCoverDecl* nodep) {
@ -776,7 +776,7 @@ public:
virtual void visit(AstCFile*) {} // Handled outside the Visit class
// Default
virtual void visit(AstNode* nodep) {
puts((string)"\n???? // "+nodep->prettyTypeName()+"\n");
puts(string("\n???? // ")+nodep->prettyTypeName()+"\n");
iterateChildren(nodep);
nodep->v3fatalSrc("Unknown node type reached emitter: "<<nodep->prettyTypeName());
}

View File

@ -299,7 +299,7 @@ void EmitCSyms::emitSymHdr() {
}
puts("\n// SYMS CLASS\n");
puts((string)"class "+symClassName()+" : public VerilatedSyms {\n");
puts(string("class ")+symClassName()+" : public VerilatedSyms {\n");
ofp()->putsPrivate(false); // public:
puts("\n// LOCAL STATE\n");
@ -340,7 +340,7 @@ void EmitCSyms::emitSymHdr() {
puts("\n// CREATORS\n");
puts(symClassName()+"("+topClassName()+"* topp, const char* namep);\n");
puts((string)"~"+symClassName()+"() {}\n");
puts(string("~")+symClassName()+"() {}\n");
puts("\n// METHODS\n");
puts("inline const char* name() { return __Vm_namep; }\n");

View File

@ -194,7 +194,7 @@ class EmitVBaseVisitor : public EmitCBaseVisitor {
putqs(nodep,"end\n");
}
virtual void visit(AstComment* nodep) {
puts((string)"// "+nodep->name()+"\n");
puts(string("// ")+nodep->name()+"\n");
iterateChildren(nodep);
}
virtual void visit(AstContinue* nodep) {
@ -595,7 +595,7 @@ class EmitVBaseVisitor : public EmitCBaseVisitor {
virtual void visit(AstCell*) {} // Handled outside the Visit class
// Default
virtual void visit(AstNode* nodep) {
puts((string)"\n???? // "+nodep->prettyTypeName()+"\n");
puts(string("\n???? // ")+nodep->prettyTypeName()+"\n");
iterateChildren(nodep);
// Not v3fatalSrc so we keep processing
nodep->v3error("Internal: Unknown node type reached emitter: "<<nodep->prettyTypeName());

View File

@ -130,8 +130,8 @@ string V3Error::msgPrefix() {
else if (code==V3ErrorCode::EC_FATAL) return "%Error: ";
else if (code==V3ErrorCode::EC_FATALSRC) return "%Error: Internal Error: ";
else if (code==V3ErrorCode::EC_ERROR) return "%Error: ";
else if (isError(code, supp)) return "%Error-"+(string)code.ascii()+": ";
else return "%Warning-"+(string)code.ascii()+": ";
else if (isError(code, supp)) return "%Error-"+string(code.ascii())+": ";
else return "%Warning-"+string(code.ascii())+": ";
}
//======================================================================

View File

@ -99,7 +99,7 @@ FileLine::FileLine(FileLine::EmptySecret) {
string FileLine::lineDirectiveStrg(int enterExit) const {
char numbuf[20]; sprintf(numbuf, "%d", lineno());
char levelbuf[20]; sprintf(levelbuf, "%d", enterExit);
return ((string)"`line "+numbuf+" \""+filename()+"\" "+levelbuf+"\n");
return (string("`line ")+numbuf+" \""+filename()+"\" "+levelbuf+"\n");
}
void FileLine::lineDirective(const char* textp, int& enterExitRef) {

View File

@ -438,11 +438,11 @@ private:
// To keep correct visual order, must add before other Text's
AstNode* afterp = nodep->scopeAttrp();
if (afterp) afterp->unlinkFrBackWithNext();
nodep->scopeAttrp(new AstText(nodep->fileline(), (string)"__DOT__"+m_cellp->name()));
nodep->scopeAttrp(new AstText(nodep->fileline(), string("__DOT__")+m_cellp->name()));
if (afterp) nodep->scopeAttrp(afterp);
afterp = nodep->scopeEntrp();
if (afterp) afterp->unlinkFrBackWithNext();
nodep->scopeEntrp(new AstText(nodep->fileline(), (string)"__DOT__"+m_cellp->name()));
nodep->scopeEntrp(new AstText(nodep->fileline(), string("__DOT__")+m_cellp->name()));
if (afterp) nodep->scopeEntrp(afterp);
iterateChildren(nodep);
}

View File

@ -513,7 +513,7 @@ public:
// Make a new temp wire
//if (1||debug()>=9) { pinp->dumpTree(cout,"-in_pin:"); }
AstNode* pinexprp = pinp->exprp()->unlinkFrBack();
string newvarname = ((string)(pinVarp->isOutput() ? "__Vcellout" : "__Vcellinp")
string newvarname = (string(pinVarp->isOutput() ? "__Vcellout" : "__Vcellinp")
+(forTristate?"t":"") // Prevent name conflict if both tri & non-tri add signals
+"__"+cellp->name()+"__"+pinp->name());
AstVar* newvarp = new AstVar(pinVarp->fileline(), AstVarType::MODULETEMP, newvarname, pinVarp);

View File

@ -91,7 +91,7 @@ void V3LinkLevel::wrapTop(AstNetlist* netlistp) {
// We do ONLY the top module
AstNodeModule* oldmodp = netlistp->modulesp();
if (!oldmodp) netlistp->v3fatalSrc("No module found to process");
AstNodeModule* newmodp = new AstModule(oldmodp->fileline(), (string)"TOP_"+oldmodp->name());
AstNodeModule* newmodp = new AstModule(oldmodp->fileline(), string("TOP_")+oldmodp->name());
// Make the new module first in the list
oldmodp->unlinkFrBackWithNext();
newmodp->addNext(oldmodp);

View File

@ -57,13 +57,13 @@ private:
void rename(AstNode* nodep, bool addPvt) {
if (!nodep->user1()) { // Not already done
if (addPvt) {
string newname = (string)"__PVT__"+nodep->name();
string newname = string("__PVT__")+nodep->name();
nodep->name(newname);
} else {
string rsvd = m_words.isKeyword(nodep->name());
if (rsvd != "") {
nodep->v3warn(SYMRSVDWORD,"Symbol matches "+rsvd+": '"<<nodep->prettyName()<<"'");
string newname = (string)"__SYM__"+nodep->name();
string newname = string("__SYM__")+nodep->name();
nodep->name(newname);
}
}

View File

@ -165,7 +165,7 @@ private:
int num = bucket + offset * BUCKETS;
m_valueMap.insert(make_pair(nodep, num));
// 'z' just to make sure we don't collide with a normal non-hashed number
return (string)"z"+cvtToStr(num);
return string("z")+cvtToStr(num);
}
}
void collectPins(CloneMap* clonemapp, AstNodeModule* modp) {

View File

@ -106,7 +106,7 @@ void V3ParseImp::parseFile(FileLine* fileline, const string& modfilename, bool i
// intervening +<lang>ext+ options since it was first ecountered.
FileLine *modfileline = new FileLine(modfilename, 0);
modfileline->language(v3Global.opt.fileLanguage(modfilename));
ppPushText((string)"`begin_keywords \""+modfileline->language().ascii()+"\"\n");
ppPushText(string("`begin_keywords \"")+modfileline->language().ascii()+"\"\n");
}
// Preprocess into m_ppBuffer

View File

@ -999,7 +999,7 @@ int V3PreProcImp::getStateToken() {
break;
}
else {
error((string)"Expecting define name. Found: "+tokenName(tok)+"\n");
error(string("Expecting define name. Found: ")+tokenName(tok)+"\n");
goto next_tok;
}
}
@ -1015,7 +1015,7 @@ int V3PreProcImp::getStateToken() {
if (!m_off) return tok;
else goto next_tok;
} else {
error((string)"Expecting define formal arguments. Found: "+tokenName(tok)+"\n");
error(string("Expecting define formal arguments. Found: ")+tokenName(tok)+"\n");
goto next_tok;
}
}
@ -1068,7 +1068,7 @@ int V3PreProcImp::getStateToken() {
} else {
if (m_defRefs.empty()) fatalSrc("Shouldn't be in DEFPAREN w/o active defref");
V3DefineRef* refp = &(m_defRefs.top());
error((string)"Expecting ( to begin argument list for define reference `"+refp->name()+"\n");
error(string("Expecting ( to begin argument list for define reference `")+refp->name()+"\n");
statePop();
goto next_tok;
}
@ -1132,7 +1132,7 @@ int V3PreProcImp::getStateToken() {
statePush(ps_STRIFY);
goto next_tok;
} else {
error((string)"Expecting ) or , to end argument list for define reference. Found: "+tokenName(tok));
error(string("Expecting ) or , to end argument list for define reference. Found: ")+tokenName(tok));
statePop();
goto next_tok;
}
@ -1161,7 +1161,7 @@ int V3PreProcImp::getStateToken() {
}
else {
statePop();
error((string)"Expecting include filename. Found: "+tokenName(tok)+"\n");
error(string("Expecting include filename. Found: ")+tokenName(tok)+"\n");
goto next_tok;
}
}
@ -1175,7 +1175,7 @@ int V3PreProcImp::getStateToken() {
goto next_tok;
}
else {
error((string)"Expecting `error string. Found: "+tokenName(tok)+"\n");
error(string("Expecting `error string. Found: ")+tokenName(tok)+"\n");
statePop();
goto next_tok;
}
@ -1217,7 +1217,7 @@ int V3PreProcImp::getStateToken() {
while ((pos=out.find("\n")) != string::npos) {
out.replace(pos, 1, " ");
}
unputString((string)"\""+out+"\"");
unputString(string("\"")+out+"\"");
statePop();
goto next_tok;
}
@ -1386,7 +1386,7 @@ int V3PreProcImp::getStateToken() {
case VP_DEFFORM: // Handled by state=ps_DEFFORM;
case VP_DEFVALUE: // Handled by state=ps_DEFVALUE;
default:
fatalSrc((string)"Internal error: Unexpected token "+tokenName(tok)+"\n");
fatalSrc(string("Internal error: Unexpected token ")+tokenName(tok)+"\n");
break;
}
return tok;

View File

@ -151,7 +151,7 @@ private:
}
AstVar* getBlockTemp(AstNode* nodep) {
string newvarname = ((string)"__Vtemp"+cvtToStr(m_modp->varNumGetInc()));
string newvarname = (string("__Vtemp")+cvtToStr(m_modp->varNumGetInc()));
AstVar* varp = new AstVar(nodep->fileline(), AstVarType::STMTTEMP, newvarname,
nodep->dtypep());
m_funcp->addInitsp(varp);

View File

@ -268,7 +268,7 @@ private:
}
virtual void visit(AstScopeName* nodep) {
// If there's a %m in the display text, we add a special node that will contain the name()
string prefix = (string)("__DOT__")+m_scopep->name();
string prefix = string("__DOT__")+m_scopep->name();
// TOP and above will be the user's name().
// Note 'TOP.' is stripped by scopePrettyName
// To keep correct visual order, must add before other Text's

View File

@ -152,7 +152,7 @@ public:
SplitVarPostVertex(V3Graph* graphp, AstNode* nodep)
: SplitNodeVertex(graphp,nodep) {}
virtual ~SplitVarPostVertex() {}
virtual string name() const { return (string)"POST "+SplitNodeVertex::name(); }
virtual string name() const { return string("POST ")+SplitNodeVertex::name(); }
virtual string dotColor() const { return "CadetBlue"; }
};
@ -526,10 +526,10 @@ protected:
// And a real ordering to get the statements into something reasonable
// We don't care if there's cutable violations here...
// Non-cutable violations should be impossible; as those edges are program-order
if (debug()>=9) m_graph.dumpDotFilePrefixed((string)"splitg_preo", false);
if (debug()>=9) m_graph.dumpDotFilePrefixed(string("splitg_preo"), false);
m_graph.acyclic(&SplitEdge::followCyclic);
m_graph.rank(&SplitEdge::followCyclic); // Or order(), but that's more expensive
if (debug()>=9) m_graph.dumpDotFilePrefixed((string)"splitg_opt", false);
if (debug()>=9) m_graph.dumpDotFilePrefixed(string("splitg_opt"), false);
}
void reorderBlock(AstNode* nodep) {

View File

@ -359,7 +359,7 @@ private:
// outvscp is the variable for functions only, if NULL, it's a task
if (!refp->taskp()) refp->v3fatalSrc("Unlinked?");
AstNode* newbodysp = AstNode::cloneTreeNull(refp->taskp()->stmtsp(), true); // Maybe NULL
AstNode* beginp = new AstComment(refp->fileline(), (string)("Function: ")+refp->name());
AstNode* beginp = new AstComment(refp->fileline(), string("Function: ")+refp->name());
if (newbodysp) beginp->addNext(newbodysp);
if (debug()>=9) { beginp->dumpTreeAndNext(cout,"-newbegi:"); }
//
@ -470,7 +470,7 @@ private:
AstCFunc* cfuncp = m_statep->ftaskCFuncp(refp->taskp());
if (!cfuncp) refp->v3fatalSrc("No non-inline task associated with this task call?");
//
AstNode* beginp = new AstComment(refp->fileline(), (string)("Function: ")+refp->name());
AstNode* beginp = new AstComment(refp->fileline(), string("Function: ")+refp->name());
AstCCall* ccallp = new AstCCall(refp->fileline(), cfuncp, NULL);
beginp->addNext(ccallp);
// Convert complicated outputs to temp signals

View File

@ -93,7 +93,7 @@ public:
}
virtual string name() const {
if (activityAlways()) return "*ALWAYS*";
else return ((string)(slow()?"*SLOW* ":""))+insertp()->name();
else return (string(slow()?"*SLOW* ":""))+insertp()->name();
}
virtual string dotColor() const { return slow()?"yellowGreen":"green"; }
bool activityCodeValid() const { return m_activityCodeValid; }

View File

@ -119,7 +119,7 @@ private:
replaceHandle.relink(newp);
}
else {
string name = ((string)"__Vlvbound"+cvtToStr(m_modp->varNumGetInc()));
string name = (string("__Vlvbound")+cvtToStr(m_modp->varNumGetInc()));
AstVar* varp = new AstVar(fl, AstVarType::MODULETEMP, name,
prep->dtypep());
m_modp->addStmtp(varp);
@ -287,7 +287,7 @@ private:
// Make a Vxrand variable
// We use the special XTEMP type so it doesn't break pure functions
if (!m_modp) nodep->v3fatalSrc("X number not under module");
string newvarname = ((string)"__Vxrand"
string newvarname = (string("__Vxrand")
+cvtToStr(m_modp->varNumGetInc()));
AstVar* newvarp
= new AstVar(nodep->fileline(), AstVarType::XTEMP, newvarname,

View File

@ -201,7 +201,7 @@ int V3ParseGrammar::s_modTypeImpNum = 0;
static void ERRSVKWD(FileLine* fileline, const string& tokname) {
static int toldonce = 0;
fileline->v3error((string)"Unexpected \""+tokname+"\": \""+tokname+"\" is a SystemVerilog keyword misused as an identifier.");
fileline->v3error(string("Unexpected \"")+tokname+"\": \""+tokname+"\" is a SystemVerilog keyword misused as an identifier.");
if (!toldonce++) fileline->v3error("Modify the Verilog-2001 code to avoid SV keywords, or use `begin_keywords or --language.");
}