Internals: Refactor generate construct Ast handling (#6280) (#6470)

Internals: Refactor generate construct Ast handling (#6280)

We introduce AstNodeGen, the common base class of AstGenBlock,
AstGenCase, AstGenFor, and AstGenIf, which together represent all SV
generate constructs. Subsequently remove AstNodeFor, AstNodeCase
(AstCase is now directly derived from AstNodeStmt) and adjust internals
to work on the new representation.

Output is identical modulo hashes do to changed AstNode type ids, no
functional change intended.

Step towards #6280.
This commit is contained in:
Geza Lore
2025-09-23 19:49:01 +01:00
committed by GitHub
parent df187c4406
commit 800af37975
42 changed files with 687 additions and 517 deletions
+27
View File
@@ -259,6 +259,17 @@ public:
}
}
void applyBlock(AstGenBlock* nodep) {
const VPragmaType pragma = VPragmaType::COVERAGE_BLOCK_OFF;
if (!nodep->unnamed()) {
for (const string& i : m_coverageOffBlocks) {
if (VString::wildmatch(nodep->prettyOrigOrName(), i)) {
nodep->addItemsp(new AstPragma{nodep->fileline(), pragma});
}
}
}
}
void applyBlock(AstNodeBlock* nodep) {
const VPragmaType pragma = VPragmaType::COVERAGE_BLOCK_OFF;
if (!nodep->unnamed()) {
@@ -375,6 +386,13 @@ public:
m_waivers.emplace_back(WaiverSetting{code, contents, newMatch});
}
void applyBlock(AstGenBlock* nodep) {
// Apply to block at this line
const VPragmaType pragma = VPragmaType::COVERAGE_BLOCK_OFF;
if (lineMatch(nodep->fileline()->lineno(), pragma)) {
nodep->addItemsp(new AstPragma{nodep->fileline(), pragma});
}
}
void applyBlock(AstNodeBlock* nodep) {
// Apply to block at this line
const VPragmaType pragma = VPragmaType::COVERAGE_BLOCK_OFF;
@@ -741,6 +759,15 @@ void V3Control::applyCoverageBlock(AstNodeModule* modulep, AstBegin* nodep) {
if (modp) modp->applyBlock(nodep);
}
void V3Control::applyCoverageBlock(AstNodeModule* modulep, AstGenBlock* nodep) {
const string& filename = nodep->fileline()->filename();
V3ControlFile* const filep = V3ControlResolver::s().files().resolve(filename);
if (filep) filep->applyBlock(nodep);
const string& modname = modulep->prettyOrigOrName();
V3ControlModule* const modp = V3ControlResolver::s().modules().resolve(modname);
if (modp) modp->applyBlock(nodep);
}
void V3Control::applyIgnores(FileLine* filelinep) {
const string& filename = filelinep->filename();
V3ControlFile* const filep = V3ControlResolver::s().files().resolve(filename);