diff --git a/src/V3LinkDot.cpp b/src/V3LinkDot.cpp index cc1d664fb..2917ea472 100644 --- a/src/V3LinkDot.cpp +++ b/src/V3LinkDot.cpp @@ -98,8 +98,14 @@ public: if (VL_UNLIKELY(level < 0)) level = v3Global.opt.debugSrcLevel(__FILE__); return level; } - void dump() { - if (debug()>=6) m_syms.dumpFilePrefixed("linkdot"); + void dump(const string& nameComment="linkdot", bool force=false) { + if (debug()>=6 || force) { + string filename = v3Global.debugFilename(nameComment)+".txt"; + const auto_ptr logp (V3File::new_ofstream(filename)); + if (logp->fail()) v3fatalSrc("Can't write "<preErrorDump(); @@ -108,7 +114,7 @@ public: static bool diddump = false; if (!diddump && v3Global.opt.dumpTree()) { diddump = true; - m_syms.dumpFilePrefixed("linkdot-preerr"); + dump("linkdot-preerr",true); v3Global.rootp()->dumpTreeFile(v3Global.debugFilename("linkdot-preerr.tree")); } } @@ -256,7 +262,7 @@ public: UINFO(9," INSERTblk se"<<(void*)symp<<" above=se"<<(void*)abovep<<" node="<parentp(abovep); symp->packagep(packagep); - symp->fallbackp(abovep); // Needed so can find $unit stuff + symp->fallbackp(abovep); nodep->user1p(symp); if (name != "") { checkDuplicate(abovep, nodep, name); @@ -414,7 +420,6 @@ LinkDotState* LinkDotState::s_errorThisp = NULL; //====================================================================== class LinkDotFindVisitor : public AstNVisitor { -private: // STATE LinkDotState* m_statep; // State to pass between visitors, including symbol table AstPackage* m_packagep; // Current package @@ -772,7 +777,7 @@ private: nodep->v3error("Import object not found: "<packagep()->prettyName()<<"::"<prettyName()); } } - m_curSymp->import(m_statep->symsp(), srcp, nodep->name()); + m_curSymp->importFromPackage(m_statep->symsp(), srcp, nodep->name()); UINFO(9," Link Done: "<forScopeCreation()) { - if (debug()>=9) nodep->dumpTree(cout,"-\t\t\t\talias: "); - AstVarScope* fromVscp = nodep->lhsp()->castVarRef()->varScopep(); - AstVarScope* toVscp = nodep->rhsp()->castVarRef()->varScopep(); - if (!fromVscp || !toVscp) nodep->v3fatalSrc("Bad alias scopes"); - fromVscp->user2p(toVscp); - } + if (debug()>=9) nodep->dumpTree(cout,"-\t\t\t\talias: "); + AstVarScope* fromVscp = nodep->lhsp()->castVarRef()->varScopep(); + AstVarScope* toVscp = nodep->rhsp()->castVarRef()->varScopep(); + if (!fromVscp || !toVscp) nodep->v3fatalSrc("Bad alias scopes"); + fromVscp->user2p(toVscp); nodep->iterateChildren(*this); } // For speed, don't recurse things that can't have scope @@ -1096,7 +1099,7 @@ private: } inline void checkNoDot(AstNode* nodep) { if (VL_UNLIKELY(m_ds.m_dotPos != DP_NONE)) { - UINFO(1,"ds="<type()<<" under a "<backp()->type()<<" in dotted expression"); m_ds.m_dotErr = true; } @@ -1138,7 +1141,7 @@ private: } } virtual void visit(AstCell* nodep, AstNUser*) { - // Cell: Resolve its filename. If necessary, parse it. + // Cell: Recurse inside or cleanup not founds checkNoDot(nodep); m_cellp = nodep; AstNode::user5ClearTree(); @@ -1220,10 +1223,12 @@ private: } else { m_ds.m_dotPos = DP_SCOPE; nodep->lhsp()->iterateAndNext(*this); + //if (debug()>=9) nodep->dumpTree("-dot-lho: "); } if (!m_ds.m_dotErr) { // Once something wrong, give up if (start && m_ds.m_dotPos==DP_SCOPE) m_ds.m_dotPos = DP_FINAL; // Top 'final' dot RHS is final RHS, else it's a DOT(DOT(x,*here*),real-rhs) which we consider a RHS nodep->rhsp()->iterateAndNext(*this); + //if (debug()>=9) nodep->dumpTree("-dot-rho: "); } if (start) { AstNode* newp; @@ -1307,7 +1312,8 @@ private: } else { foundp = m_ds.m_dotSymp->findIdFallback(nodep->name()); } - if (foundp) UINFO(9," found=se"<<(void*)foundp<<" n="<nodep()<8) nodep->paramsp()->dumpTreeAndNext(cout,"-cellparams:\t"); for (AstPin* pinp = nodep->paramsp(); pinp; pinp=pinp->nextp()->castPin()) { - if (!pinp) nodep->v3fatalSrc("Non pin under cell params\n"); if (!pinp->exprp()) continue; // No-connect AstVar* modvarp = pinp->modVarp(); if (!modvarp) { diff --git a/src/V3ParseSym.h b/src/V3ParseSym.h index bcb62455a..12bcdb0ef 100644 --- a/src/V3ParseSym.h +++ b/src/V3ParseSym.h @@ -128,7 +128,7 @@ public: } // Walk old sym table and reinsert into current table // We let V3LinkDot report the error instead of us - symCurrentp()->import(&m_syms, symp, id_or_star); + symCurrentp()->importFromPackage(&m_syms, symp, id_or_star); } public: // CREATORS diff --git a/src/V3SymTable.h b/src/V3SymTable.h index 882611638..e8e7dd132 100644 --- a/src/V3SymTable.h +++ b/src/V3SymTable.h @@ -166,7 +166,7 @@ private: } } public: - bool import(VSymGraph* graphp, const VSymEnt* srcp, const string& id_or_star) { + bool importFromPackage(VSymGraph* graphp, const VSymEnt* srcp, const string& id_or_star) { // Import tokens from source symbol table into this symbol table // Returns true if successful bool any = false;