mirror of
https://github.com/verilator/verilator.git
synced 2026-10-06 18:13:50 +02:00
Internals: Move iterators to AstNVisitor to avoid null this.
This commit is contained in:
+22
-22
@@ -99,7 +99,7 @@ private:
|
||||
// Operate starting at the top of the hierarchy
|
||||
m_aboveCellp = NULL;
|
||||
m_aboveScopep = NULL;
|
||||
modp->accept(*this);
|
||||
iterate(modp);
|
||||
cleanupVarRefs();
|
||||
}
|
||||
virtual void visit(AstNodeModule* nodep) {
|
||||
@@ -126,7 +126,7 @@ private:
|
||||
m_aboveScopep = m_scopep;
|
||||
AstNodeModule* modp = cellp->modp();
|
||||
if (!modp) cellp->v3fatalSrc("Unlinked mod");
|
||||
modp->accept(*this); // Recursive call to visit(AstNodeModule)
|
||||
iterate(modp); // Recursive call to visit(AstNodeModule)
|
||||
}
|
||||
// Done, restore vars
|
||||
m_scopep = oldScopep;
|
||||
@@ -148,7 +148,7 @@ private:
|
||||
|
||||
// Copy blocks into this scope
|
||||
// If this is the first usage of the block ever, we can simply move the reference
|
||||
nodep->iterateChildren(*this);
|
||||
iterateChildren(nodep);
|
||||
|
||||
// ***Note m_scopep is passed back to the caller of the routine (above)
|
||||
}
|
||||
@@ -161,7 +161,7 @@ private:
|
||||
AstInitial* clonep = nodep->cloneTree(false);
|
||||
nodep->user2p(clonep);
|
||||
m_scopep->addActivep(clonep);
|
||||
clonep->iterateChildren(*this); // We iterate under the *clone*
|
||||
iterateChildren(clonep); // We iterate under the *clone*
|
||||
}
|
||||
virtual void visit(AstFinal* nodep) {
|
||||
// Add to list of blocks under this scope
|
||||
@@ -169,7 +169,7 @@ private:
|
||||
AstFinal* clonep = nodep->cloneTree(false);
|
||||
nodep->user2p(clonep);
|
||||
m_scopep->addActivep(clonep);
|
||||
clonep->iterateChildren(*this); // We iterate under the *clone*
|
||||
iterateChildren(clonep); // We iterate under the *clone*
|
||||
}
|
||||
virtual void visit(AstAssignAlias* nodep) {
|
||||
// Add to list of blocks under this scope
|
||||
@@ -177,7 +177,7 @@ private:
|
||||
AstNode* clonep = nodep->cloneTree(false);
|
||||
nodep->user2p(clonep);
|
||||
m_scopep->addActivep(clonep);
|
||||
clonep->iterateChildren(*this); // We iterate under the *clone*
|
||||
iterateChildren(clonep); // We iterate under the *clone*
|
||||
}
|
||||
virtual void visit(AstAssignVarScope* nodep) {
|
||||
// Copy under the scope but don't recurse
|
||||
@@ -185,7 +185,7 @@ private:
|
||||
AstNode* clonep = nodep->cloneTree(false);
|
||||
nodep->user2p(clonep);
|
||||
m_scopep->addActivep(clonep);
|
||||
clonep->iterateChildren(*this); // We iterate under the *clone*
|
||||
iterateChildren(clonep); // We iterate under the *clone*
|
||||
}
|
||||
virtual void visit(AstAssignW* nodep) {
|
||||
// Add to list of blocks under this scope
|
||||
@@ -193,7 +193,7 @@ private:
|
||||
AstNode* clonep = nodep->cloneTree(false);
|
||||
nodep->user2p(clonep);
|
||||
m_scopep->addActivep(clonep);
|
||||
clonep->iterateChildren(*this); // We iterate under the *clone*
|
||||
iterateChildren(clonep); // We iterate under the *clone*
|
||||
}
|
||||
virtual void visit(AstAlways* nodep) {
|
||||
// Add to list of blocks under this scope
|
||||
@@ -201,7 +201,7 @@ private:
|
||||
AstNode* clonep = nodep->cloneTree(false);
|
||||
nodep->user2p(clonep);
|
||||
m_scopep->addActivep(clonep);
|
||||
clonep->iterateChildren(*this); // We iterate under the *clone*
|
||||
iterateChildren(clonep); // We iterate under the *clone*
|
||||
}
|
||||
virtual void visit(AstAlwaysPublic* nodep) {
|
||||
// Add to list of blocks under this scope
|
||||
@@ -209,7 +209,7 @@ private:
|
||||
AstNode* clonep = nodep->cloneTree(false);
|
||||
nodep->user2p(clonep);
|
||||
m_scopep->addActivep(clonep);
|
||||
clonep->iterateChildren(*this); // We iterate under the *clone*
|
||||
iterateChildren(clonep); // We iterate under the *clone*
|
||||
}
|
||||
virtual void visit(AstCoverToggle* nodep) {
|
||||
// Add to list of blocks under this scope
|
||||
@@ -217,7 +217,7 @@ private:
|
||||
AstNode* clonep = nodep->cloneTree(false);
|
||||
nodep->user2p(clonep);
|
||||
m_scopep->addActivep(clonep);
|
||||
clonep->iterateChildren(*this); // We iterate under the *clone*
|
||||
iterateChildren(clonep); // We iterate under the *clone*
|
||||
}
|
||||
virtual void visit(AstCFunc* nodep) {
|
||||
// Add to list of blocks under this scope
|
||||
@@ -227,7 +227,7 @@ private:
|
||||
m_scopep->addActivep(clonep);
|
||||
clonep->scopep(m_scopep);
|
||||
// We iterate under the *clone*
|
||||
clonep->iterateChildren(*this);
|
||||
iterateChildren(clonep);
|
||||
}
|
||||
virtual void visit(AstNodeFTask* nodep) {
|
||||
// Add to list of blocks under this scope
|
||||
@@ -236,7 +236,7 @@ private:
|
||||
nodep->user2p(clonep);
|
||||
m_scopep->addActivep(clonep);
|
||||
// We iterate under the *clone*
|
||||
clonep->iterateChildren(*this);
|
||||
iterateChildren(clonep);
|
||||
}
|
||||
virtual void visit(AstVar* nodep) {
|
||||
// Make new scope variable
|
||||
@@ -284,7 +284,7 @@ private:
|
||||
if (afterp) afterp->unlinkFrBackWithNext();
|
||||
nodep->scopeEntrp(new AstText(nodep->fileline(), prefix));
|
||||
if (afterp) nodep->scopeEntrp(afterp);
|
||||
nodep->iterateChildren(*this);
|
||||
iterateChildren(nodep);
|
||||
}
|
||||
virtual void visit(AstScope* nodep) {
|
||||
// Scope that was made by this module for different cell;
|
||||
@@ -293,7 +293,7 @@ private:
|
||||
//--------------------
|
||||
// Default
|
||||
virtual void visit(AstNode* nodep) {
|
||||
nodep->iterateChildren(*this);
|
||||
iterateChildren(nodep);
|
||||
}
|
||||
public:
|
||||
// CONSTUCTORS
|
||||
@@ -303,7 +303,7 @@ public:
|
||||
m_modp = NULL;
|
||||
m_scopep = NULL;
|
||||
//
|
||||
nodep->accept(*this);
|
||||
iterate(nodep);
|
||||
}
|
||||
virtual ~ScopeVisitor() {}
|
||||
};
|
||||
@@ -327,14 +327,14 @@ private:
|
||||
virtual void visit(AstScope* nodep) {
|
||||
// Want to ignore blocks under it
|
||||
m_scopep = nodep;
|
||||
nodep->iterateChildren(*this);
|
||||
iterateChildren(nodep);
|
||||
m_scopep = NULL;
|
||||
}
|
||||
|
||||
virtual void movedDeleteOrIterate(AstNode* nodep) {
|
||||
if (m_scopep) {
|
||||
// The new block; repair varrefs
|
||||
nodep->iterateChildren(*this);
|
||||
iterateChildren(nodep);
|
||||
} else {
|
||||
// A block that was just moved under a scope, Kill it.
|
||||
// Certain nodes can be referenced later in this pass, notably
|
||||
@@ -392,24 +392,24 @@ private:
|
||||
nodep->taskp(NULL);
|
||||
UINFO(9," New pkg-taskref "<<nodep<<endl);
|
||||
}
|
||||
nodep->iterateChildren(*this);
|
||||
iterateChildren(nodep);
|
||||
}
|
||||
virtual void visit(AstModportFTaskRef* nodep) {
|
||||
// The crossrefs are dealt with in V3LinkDot
|
||||
nodep->ftaskp(NULL);
|
||||
nodep->iterateChildren(*this);
|
||||
iterateChildren(nodep);
|
||||
}
|
||||
|
||||
//--------------------
|
||||
// Default
|
||||
virtual void visit(AstNode* nodep) {
|
||||
nodep->iterateChildren(*this);
|
||||
iterateChildren(nodep);
|
||||
}
|
||||
public:
|
||||
// CONSTUCTORS
|
||||
explicit ScopeCleanupVisitor(AstNetlist* nodep) {
|
||||
m_scopep = NULL;
|
||||
nodep->accept(*this);
|
||||
iterate(nodep);
|
||||
}
|
||||
virtual ~ScopeCleanupVisitor() {}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user