mirror of
https://github.com/verilator/verilator.git
synced 2026-09-04 08:33:38 +02:00
Fix error on enums with x/z using .name(), and internal refactoring
This commit is contained in:
+22
-17
@@ -31,6 +31,24 @@ VL_DEFINE_DEBUG_FUNCTIONS;
|
||||
//######################################################################
|
||||
// Common component builders
|
||||
|
||||
string V3Common::makeToStringCall(AstNodeDType* nodep, const std::string& lhs) {
|
||||
std::string stmt;
|
||||
if (VN_IS(nodep->skipRefp(), BasicDType) && nodep->isWide()) {
|
||||
stmt += "VL_TO_STRING_W(";
|
||||
stmt += cvtToStr(nodep->widthWords());
|
||||
stmt += ", ";
|
||||
} else if (VN_IS(nodep->skipRefp(), BasicDType) && nodep->isWide()) {
|
||||
stmt += "VL_TO_STRING_W(";
|
||||
stmt += cvtToStr(nodep->widthWords());
|
||||
stmt += ", ";
|
||||
} else {
|
||||
stmt += "VL_TO_STRING(";
|
||||
}
|
||||
stmt += lhs;
|
||||
stmt += ")";
|
||||
return stmt;
|
||||
}
|
||||
|
||||
static void makeVlToString(AstClass* nodep) {
|
||||
AstCFunc* const funcp
|
||||
= new AstCFunc{nodep->fileline(), "VL_TO_STRING", nullptr, "std::string"};
|
||||
@@ -78,14 +96,8 @@ static void makeVlToString(AstNodeUOrStructDType* nodep) {
|
||||
stmt += ", ";
|
||||
}
|
||||
stmt += VIdProtect::protect(itemp->prettyName()) + ":\" + ";
|
||||
if (VN_IS(itemp->dtypep()->skipRefp(), BasicDType) && itemp->isWide()) {
|
||||
stmt += "VL_TO_STRING_W(";
|
||||
stmt += cvtToStr(itemp->widthWords());
|
||||
stmt += ", ";
|
||||
} else {
|
||||
stmt += "VL_TO_STRING(";
|
||||
}
|
||||
stmt += "obj." + itemp->nameProtect() + ");\n";
|
||||
stmt += V3Common::makeToStringCall(itemp->dtypep(), "obj."s + itemp->nameProtect());
|
||||
stmt += ";\n";
|
||||
funcp->addStmtsp(new AstCStmt{nodep->fileline(), stmt});
|
||||
}
|
||||
funcp->addStmtsp(new AstCStmt{nodep->fileline(), "out += \"}\";\n"});
|
||||
@@ -121,15 +133,8 @@ static void makeToStringMiddle(AstClass* nodep) {
|
||||
comma = ", ";
|
||||
stmt += itemp->origNameProtect();
|
||||
stmt += ":\" + ";
|
||||
if (VN_IS(itemp->dtypep()->skipRefp(), BasicDType) && itemp->isWide()) {
|
||||
stmt += "VL_TO_STRING_W(";
|
||||
stmt += cvtToStr(itemp->widthWords());
|
||||
stmt += ", ";
|
||||
} else {
|
||||
stmt += "VL_TO_STRING(";
|
||||
}
|
||||
stmt += itemp->nameProtect();
|
||||
stmt += ");\n";
|
||||
stmt += V3Common::makeToStringCall(itemp->dtypep(), itemp->nameProtect());
|
||||
stmt += ";\n";
|
||||
nodep->user1(true); // So what we extend dumps this
|
||||
funcp->addStmtsp(new AstCStmt{nodep->fileline(), stmt});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user