From a39c81c63f97df4d1979b985a3236253331ea244 Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Mon, 20 Feb 2012 16:48:52 -0500 Subject: [PATCH] Internals: Remove width() on AstCaseItem. No functional change. --- internals.pod | 6 ++++++ src/V3Ast.cpp | 4 ++++ src/V3Ast.h | 3 +++ src/V3Width.cpp | 47 +++++++++++++++++------------------------------ 4 files changed, 30 insertions(+), 30 deletions(-) diff --git a/internals.pod b/internals.pod index 47509d32d..7e02d2571 100644 --- a/internals.pod +++ b/internals.pod @@ -247,6 +247,12 @@ what made a line in the tree dumps): watch AstNode::s_editCntGbl==#### +To print a node: + + p nodep->dumpCout() + p nodep->dumpTreeCout() + p nodep->dumpPtrsCout() + =head1 DISTRIBUTION The latest version is available from L. diff --git a/src/V3Ast.cpp b/src/V3Ast.cpp index b824b3996..291b7b1fd 100644 --- a/src/V3Ast.cpp +++ b/src/V3Ast.cpp @@ -947,6 +947,10 @@ void AstNode::checkTree() { } } +void AstNode::dumpCout() { dump(cout); } // For GDB only +void AstNode::dumpPtrsCout() const { dumpPtrs(cout); } // For GDB only +void AstNode::dumpTreeCout() { dumpTree(cout); } // For GDB only + void AstNode::dumpPtrs(ostream& os) const { os<<"This="<exprp()->iterateAndNext(*this,WidthVP(ANYSIZE,0,PRELIM).p()); - for (AstCaseItem* nextp, *itemp = nodep->itemsp(); itemp; itemp=nextp) { - nextp = itemp->nextp()->castCaseItem(); // Prelim may cause the node to get replaced - itemp->iterate(*this,WidthVP(ANYSIZE,0,PRELIM).p()); itemp=NULL; + for (AstCaseItem* nextip, *itemp = nodep->itemsp(); itemp; itemp=nextip) { + nextip = itemp->nextp()->castCaseItem(); // Prelim may cause the node to get replaced + if (!m_casep->castGenCase()) itemp->bodysp()->iterateAndNext(*this); + for (AstNode* nextcp, *condp = itemp->condsp(); condp; condp=nextcp) { + nextcp = condp->nextp(); // Prelim may cause the node to get replaced + condp->iterate(*this,WidthVP(ANYSIZE,0,PRELIM).p()); condp=NULL; + } } + // Take width as maximum across all items int width = nodep->exprp()->width(); int mwidth = nodep->exprp()->widthMin(); for (AstCaseItem* itemp = nodep->itemsp(); itemp; itemp=itemp->nextp()->castCaseItem()) { - width = max(width,itemp->width()); - mwidth = max(mwidth,itemp->widthMin()); + for (AstNode* condp = itemp->condsp(); condp; condp=condp->nextp()) { + width = max(width,condp->width()); + mwidth = max(mwidth,condp->widthMin()); + } } + // Apply width nodep->exprp()->iterateAndNext(*this,WidthVP(width,mwidth,FINAL).p()); for (AstCaseItem* itemp = nodep->itemsp(); itemp; itemp=itemp->nextp()->castCaseItem()) { - itemp->iterate(*this,WidthVP(width,mwidth,FINAL).p()); + for (AstNode* condp = itemp->condsp(); condp; condp=condp->nextp()) { + condp->iterate(*this,WidthVP(width,mwidth,FINAL).p()); + widthCheck(nodep,"Case Item",condp,width,mwidth); + } } widthCheck(nodep,"Case expression",nodep->exprp(),width,mwidth); m_casep = lastCasep; } - virtual void visit(AstCaseItem* nodep, AstNUser* vup) { - // Same for both prelim() and final() - if (!m_casep->castGenCase()) nodep->bodysp()->iterateAndNext(*this); - if (!nodep->condsp()) { - // Else "default:" of the case, just return benign value - nodep->width(vup->c()->width(),vup->c()->widthMin()); - } else { - // Need to look across multiple case values for one set of statements - int width = nodep->condsp()->width(); - int mwidth = nodep->condsp()->widthMin(); - for (AstNode* nextp, *condp = nodep->condsp(); condp; condp=nextp) { - nextp = condp->nextp(); // Prelim may cause the node to get replaced - condp->iterate(*this,vup); condp=NULL; - } - for (AstNode* condp = nodep->condsp(); condp; condp=condp->nextp()) { - width = max(width,condp->width()); - mwidth = max(mwidth,condp->widthMin()); - if (vup->c()->final()) { - widthCheck(nodep,"Case Item",condp,vup->c()->width(),vup->c()->widthMin()); - } - } - nodep->width(width,mwidth); - } - } virtual void visit(AstNodeFor* nodep, AstNUser*) { // TOP LEVEL NODE nodep->initsp()->iterateAndNext(*this);