Internals: AstComment optional suppression of at. No functional change intended.

This commit is contained in:
Wilson Snyder 2019-09-23 18:44:45 -04:00
parent d6ac351dcb
commit 8490046028
7 changed files with 18 additions and 11 deletions

View File

@ -301,7 +301,7 @@ private:
m_namer.scopep()->addActivep(m_scopeFinalp);
}
nodep->unlinkFrBack();
m_scopeFinalp->addStmtsp(new AstComment(nodep->fileline(), nodep->typeName()));
m_scopeFinalp->addStmtsp(new AstComment(nodep->fileline(), nodep->typeName(), true));
m_scopeFinalp->addStmtsp(nodep->bodysp()->unlinkFrBackWithNext());
nodep->deleteTree(); VL_DANGLING(nodep);
}

View File

@ -2387,15 +2387,17 @@ class AstComment : public AstNodeStmt {
// Parents: {statement list}
// Children: none
private:
bool m_showAt; // Show "at <fileline>"
string m_name; // Text of comment
public:
AstComment(FileLine* fl, const string& name)
AstComment(FileLine* fl, const string& name, bool showAt=false)
: AstNodeStmt(fl)
, m_name(name) {}
, m_showAt(showAt), m_name(name) {}
ASTNODE_NODE_FUNCS(Comment)
virtual string name() const { return m_name; } // * = Text
virtual V3Hash sameHash() const { return V3Hash(); } // Ignore name in comments
virtual bool same(const AstNode* samep) const { return true; } // Ignore name in comments
virtual bool showAt() const { return m_showAt; }
};
class AstCond : public AstNodeCond {

View File

@ -271,7 +271,7 @@ private:
m_scopep = NULL;
}
virtual void visit(AstAlways* nodep) {
AstNode* cmtp = new AstComment(nodep->fileline(), nodep->typeName());
AstNode* cmtp = new AstComment(nodep->fileline(), nodep->typeName(), true);
nodep->replaceWith(cmtp);
if (AstNode* stmtsp = nodep->bodysp()) {
stmtsp->unlinkFrBackWithNext();
@ -280,7 +280,7 @@ private:
nodep->deleteTree(); VL_DANGLING(nodep);
}
virtual void visit(AstAlwaysPost* nodep) {
AstNode* cmtp = new AstComment(nodep->fileline(), nodep->typeName());
AstNode* cmtp = new AstComment(nodep->fileline(), nodep->typeName(), true);
nodep->replaceWith(cmtp);
if (AstNode* stmtsp = nodep->bodysp()) {
stmtsp->unlinkFrBackWithNext();
@ -309,7 +309,7 @@ private:
nodep->replaceWith(newp); nodep->deleteTree(); VL_DANGLING(nodep);
}
virtual void visit(AstInitial* nodep) {
AstNode* cmtp = new AstComment(nodep->fileline(), nodep->typeName());
AstNode* cmtp = new AstComment(nodep->fileline(), nodep->typeName(), true);
nodep->replaceWith(cmtp);
if (AstNode* stmtsp = nodep->bodysp()) {
stmtsp->unlinkFrBackWithNext();

View File

@ -236,7 +236,9 @@ public:
nodep->v3fatalSrc("Case statements should have been reduced out");
}
virtual void visit(AstComment* nodep) {
putsDecoration(string("// ")+nodep->name()+" at "+nodep->fileline()->ascii()+"\n");
string at;
if (nodep->showAt()) at = " at "+nodep->fileline()->ascii();
putsDecoration(string("// ")+nodep->name()+at+"\n");
iterateChildren(nodep);
}
virtual void visit(AstCoverDecl* nodep) {

View File

@ -364,7 +364,8 @@ private:
// outvscp is the variable for functions only, if NULL, it's a task
UASSERT_OBJ(refp->taskp(), refp, "Unlinked?");
AstNode* newbodysp = AstNode::cloneTreeNull(refp->taskp()->stmtsp(), true); // Maybe NULL
AstNode* beginp = new AstComment(refp->fileline(), string("Function: ")+refp->name());
AstNode* beginp = new AstComment(refp->fileline(),
string("Function: ")+refp->name(), true);
if (newbodysp) beginp->addNext(newbodysp);
if (debug()>=9) { beginp->dumpTreeAndNext(cout, "-newbegi:"); }
//
@ -483,7 +484,8 @@ private:
AstCFunc* cfuncp = m_statep->ftaskCFuncp(refp->taskp());
UASSERT_OBJ(cfuncp, refp, "No non-inline task associated with this task call?");
//
AstNode* beginp = new AstComment(refp->fileline(), string("Function: ")+refp->name());
AstNode* beginp = new AstComment(refp->fileline(),
string("Function: ")+refp->name(), true);
AstCCall* ccallp = new AstCCall(refp->fileline(), cfuncp, NULL);
beginp->addNext(ccallp);
// Convert complicated outputs to temp signals

View File

@ -684,7 +684,7 @@ private:
|| nodep == v3Global.rootp()->evalp()) {
// Need a non-null place to remember to later add a statement; make one
if (!nodep->stmtsp()) nodep->addStmtsp(
new AstComment(nodep->fileline(), "Tracing activity check"));
new AstComment(nodep->fileline(), "Tracing activity check", true));
V3GraphVertex* activityVtxp = getActivityVertexp(nodep->stmtsp(), nodep->slow());
new V3GraphEdge(&m_graph, activityVtxp, funcVtxp, 1);
}

View File

@ -130,7 +130,8 @@ private:
void addIgnore(const char* why) {
++m_statIgnSigs;
m_initSubFuncp->addStmtsp(
new AstComment(m_traVscp->fileline(), "Tracing: "+m_traShowname+" // Ignored: "+why));
new AstComment(m_traVscp->fileline(),
"Tracing: "+m_traShowname+" // Ignored: "+why, true));
}
// VISITORS