Internals: Move iterators to AstNVisitor to avoid null this.

This commit is contained in:
Wilson Snyder
2018-05-10 20:55:37 -04:00
parent 489f58011b
commit 05db8ce6c8
71 changed files with 1145 additions and 1099 deletions
+12 -12
View File
@@ -197,14 +197,14 @@ private:
// If this statement ends with 'else if', then nextIf will point to the
// nextIf statement. Otherwise it will be null.
AstNodeIf* nextifp = dynamic_cast<AstNodeIf*>(ifp->elsesp());
ifp->condp()->iterateAndNext(*this);
iterateAndNextNull(ifp->condp());
// Recurse into the true case.
ifp->ifsp()->iterateAndNext(*this);
iterateAndNextNull(ifp->ifsp());
// If the last else is not an else if, recurse into that too.
if (ifp->elsesp() && !nextifp) {
ifp->elsesp()->iterateAndNext(*this);
iterateAndNextNull(ifp->elsesp());
}
// Build a bitmask of the true predicates
@@ -242,13 +242,13 @@ private:
nodep->replaceWith(checkifp);
pushDeletep(nodep);
} else {
nodep->iterateChildren(*this);
iterateChildren(nodep);
}
}
// VISITORS //========== Case assertions
virtual void visit(AstCase* nodep) {
nodep->iterateChildren(*this);
iterateChildren(nodep);
if (!nodep->user1SetOnce()) {
bool has_default=false;
for (AstCaseItem* itemp = nodep->itemsp(); itemp; itemp=VN_CAST(itemp->nextp(), CaseItem)) {
@@ -306,7 +306,7 @@ private:
// VISITORS //========== Statements
virtual void visit(AstDisplay* nodep) {
nodep->iterateChildren(*this);
iterateChildren(nodep);
// Replace the special types with standard text
if (nodep->displayType()==AstDisplayType::DT_INFO) {
replaceDisplay(nodep, "-Info");
@@ -319,13 +319,13 @@ private:
}
virtual void visit(AstNodePslCoverOrAssert* nodep) {
nodep->iterateChildren(*this);
iterateChildren(nodep);
if (m_beginp && nodep->name() == "") nodep->name(m_beginp->name());
newPslAssertion(nodep, nodep->propp(), nodep->sentreep(),
nodep->stmtsp(), nodep->name()); VL_DANGLING(nodep);
}
virtual void visit(AstVAssert* nodep) {
nodep->iterateChildren(*this);
iterateChildren(nodep);
newVAssertion(nodep, nodep->propp()); VL_DANGLING(nodep);
++m_statAsSV;
}
@@ -333,7 +333,7 @@ private:
virtual void visit(AstNodeModule* nodep) {
m_modp = nodep;
//
nodep->iterateChildren(*this);
iterateChildren(nodep);
// Reset defaults
m_modp = NULL;
}
@@ -343,13 +343,13 @@ private:
AstBegin* lastp = m_beginp;
{
m_beginp = nodep;
nodep->iterateChildren(*this);
iterateChildren(nodep);
}
m_beginp = lastp;
}
virtual void visit(AstNode* nodep) {
nodep->iterateChildren(*this);
iterateChildren(nodep);
}
public:
// CONSTRUCTORS
@@ -357,7 +357,7 @@ public:
m_beginp = NULL;
m_modp = NULL;
// Process
nodep->accept(*this);
iterate(nodep);
}
virtual ~AssertVisitor() {
V3Stats::addStat("Assertions, PSL asserts", m_statAsPsl);