Internals: Look at tree state instead of back for AstAttr. No functional change.

This commit is contained in:
Wilson Snyder
2012-07-28 10:52:29 -04:00
parent ecf508ec23
commit 33e6a17747
3 changed files with 25 additions and 2 deletions
+9 -1
View File
@@ -51,6 +51,7 @@ private:
AstVarScope* m_forVscp; // Iterator variable scope (NULL for generate pass)
AstConst* m_varValuep; // Current value of loop
AstNode* m_ignoreIncp; // Increment node to ignore
AstAttrOf* m_attrp; // Current attribute
bool m_varModeCheck; // Just checking RHS assignments
bool m_varModeReplace; // Replacing varrefs
bool m_varAssignHit; // Assign var hit
@@ -383,6 +384,12 @@ private:
nodep->v3error("V3Begin should have removed standard FORs");
}
}
virtual void visit(AstAttrOf* nodep, AstNUser*) {
AstAttrOf* oldAttr = m_attrp;
m_attrp = nodep;
nodep->iterateChildren(*this);
m_attrp = oldAttr;
}
virtual void visit(AstVarRef* nodep, AstNUser*) {
if (m_varModeCheck
@@ -396,7 +403,7 @@ private:
&& nodep->varp() == m_forVarp
&& nodep->varScopep() == m_forVscp
&& !nodep->lvalue()
&& !nodep->backp()->castAttrOf()) { // Most likely under a select
&& !m_attrp) { // Most likely under a select
AstNode* newconstp = m_varValuep->cloneTree(false);
nodep->replaceWith(newconstp);
pushDeletep(nodep);
@@ -423,6 +430,7 @@ public:
m_varModeReplace = false;
m_generate = generate;
m_beginName = beginName;
m_attrp = NULL;
//
nodep->accept(*this);
}