Fix converting subclasses to string (#3552)

This commit is contained in:
Arkadiusz Kozdra 2022-08-18 00:08:43 +02:00 committed by GitHub
parent 93272c13fd
commit 0eeb40b975
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -87,10 +87,10 @@ static void makeToStringMiddle(AstClass* nodep) {
}
}
if (nodep->extendsp() && nodep->extendsp()->classp()->user1()) {
string stmt = "out += \"";
string stmt = "out += ";
if (!comma.empty()) stmt += "\", \"+ ";
// comma = ", "; // Nothing further so not needed
stmt += nodep->extendsp()->dtypep()->nameProtect();
stmt += EmitCBaseVisitor::prefixNameProtect(nodep->extendsp()->dtypep());
stmt += "::to_string_middle();\n";
nodep->user1(true); // So what we extend dumps this
funcp->addStmtsp(new AstCStmt{nodep->fileline(), stmt});
@ -104,13 +104,13 @@ static void makeToStringMiddle(AstClass* nodep) {
void V3Common::commonAll() {
UINFO(2, __FUNCTION__ << ": " << endl);
// NODE STATE
// Entire netlist:
// AstClass::user1() -> bool. True if class needs to_string dumper
const VNUser1InUse m_inuser1;
// Create common contents for each module
for (AstNode* nodep = v3Global.rootp()->modulesp(); nodep; nodep = nodep->nextp()) {
if (AstClass* const classp = VN_CAST(nodep, Class)) {
// NODE STATE
// Entire netlist:
// AstClass::user1() -> bool. True if class needs to_string dumper
const VNUser1InUse m_inuser1;
// Create ToString methods
makeVlToString(classp);
makeToString(classp);