mirror of
https://github.com/verilator/verilator.git
synced 2024-12-29 10:47:34 +00:00
Internals: Refactor symIterate functions. No functional change intended
This commit is contained in:
parent
2d71d66cf5
commit
7a04a5b9a8
@ -2448,17 +2448,32 @@ class LinkDotResolveVisitor final : public VNVisitor {
|
||||
// A class reference might be to a class that is later in Ast due to
|
||||
// e.g. parmaeterization or referring to a "class (type T) extends T"
|
||||
// Resolve it so later Class:: references into its base classes work
|
||||
VL_RESTORER(m_ds);
|
||||
VSymEnt* const srcp = m_statep->getNodeSym(nodep);
|
||||
m_ds.init(srcp);
|
||||
iterate(nodep);
|
||||
symIterateNull(nodep, m_statep->getNodeSym(nodep));
|
||||
}
|
||||
|
||||
void updateVarUse(AstVar* nodep) {
|
||||
// Avoid dotted.PARAM false positive when in a parameter block
|
||||
// that is if ()'ed off by same dotted name as another block
|
||||
if (nodep && nodep->isParam()) nodep->usedParam(true);
|
||||
}
|
||||
|
||||
void symIterateChildren(AstNode* nodep, VSymEnt* symp) {
|
||||
// Iterate children, changing to given context, with restore to old context
|
||||
VL_RESTORER(m_ds);
|
||||
VL_RESTORER(m_curSymp);
|
||||
m_curSymp = symp;
|
||||
m_ds.init(m_curSymp);
|
||||
iterateChildren(nodep);
|
||||
}
|
||||
void symIterateNull(AstNode* nodep, VSymEnt* symp) {
|
||||
// Iterate node, changing to given context, with restore to old context
|
||||
VL_RESTORER(m_ds);
|
||||
VL_RESTORER(m_curSymp);
|
||||
m_curSymp = symp;
|
||||
m_ds.init(m_curSymp);
|
||||
iterateNull(nodep);
|
||||
}
|
||||
|
||||
#define LINKDOT_VISIT_START() \
|
||||
VL_RESTORER(m_indent); \
|
||||
++m_indent;
|
||||
@ -2494,14 +2509,12 @@ class LinkDotResolveVisitor final : public VNVisitor {
|
||||
void visit(AstScope* nodep) override {
|
||||
LINKDOT_VISIT_START();
|
||||
UINFO(8, indent() << "visit " << nodep << endl);
|
||||
checkNoDot(nodep);
|
||||
VL_RESTORER(m_modSymp);
|
||||
VL_RESTORER(m_curSymp);
|
||||
{
|
||||
checkNoDot(nodep);
|
||||
m_ds.m_dotSymp = m_curSymp = m_modSymp = m_statep->getScopeSym(nodep);
|
||||
iterateChildren(nodep);
|
||||
m_ds.m_dotSymp = m_curSymp = m_modSymp = nullptr;
|
||||
}
|
||||
m_ds.m_dotSymp = m_curSymp = m_modSymp = m_statep->getScopeSym(nodep);
|
||||
iterateChildren(nodep);
|
||||
m_ds.m_dotSymp = m_curSymp = m_modSymp = nullptr;
|
||||
}
|
||||
void visit(AstCellInline* nodep) override {
|
||||
LINKDOT_VISIT_START();
|
||||
@ -2670,6 +2683,8 @@ class LinkDotResolveVisitor final : public VNVisitor {
|
||||
} else {
|
||||
if (m_statep->forPrimary()
|
||||
&& m_extendsParam.find(classp) != m_extendsParam.end()) {
|
||||
UINFO(9, indent() << "deferring until post-V3Param: " << nodep->lhsp()
|
||||
<< endl);
|
||||
m_ds.m_unresolvedClass = true;
|
||||
} else {
|
||||
const auto baseClassp = cextp->classp();
|
||||
@ -2696,6 +2711,7 @@ class LinkDotResolveVisitor final : public VNVisitor {
|
||||
}
|
||||
if (m_statep->forPrimary() && isParamedClassRef(nodep->lhsp())) {
|
||||
// Dots of paramed classes will be linked after deparameterization
|
||||
UINFO(9, indent() << "deferring until post-V3Param: " << nodep->lhsp() << endl);
|
||||
m_ds.m_unresolvedClass = true;
|
||||
}
|
||||
if (m_ds.m_unresolvedCell
|
||||
@ -3024,6 +3040,8 @@ class LinkDotResolveVisitor final : public VNVisitor {
|
||||
refp->dotted(dotted.substr(0, pos));
|
||||
newp = refp;
|
||||
} else {
|
||||
UINFO(9, indent()
|
||||
<< "deferring until post-V3Param: " << refp << endl);
|
||||
newp = new AstUnlinkedRef{nodep->fileline(), refp, refp->name(),
|
||||
m_ds.m_unlinkedScopep->unlinkFrBack()};
|
||||
m_ds.m_unlinkedScopep = nullptr;
|
||||
@ -3475,9 +3493,7 @@ class LinkDotResolveVisitor final : public VNVisitor {
|
||||
if (m_ds.m_dotPos != DP_MEMBER || nodep->name() != "randomize") {
|
||||
// Visit arguments at the beginning.
|
||||
// They may be visitted even if the current node can't be linked now.
|
||||
VL_RESTORER(m_ds);
|
||||
m_ds.init(m_curSymp);
|
||||
iterateChildren(nodep);
|
||||
symIterateChildren(nodep, m_curSymp);
|
||||
}
|
||||
|
||||
if (m_ds.m_super) {
|
||||
@ -3732,16 +3748,10 @@ class LinkDotResolveVisitor final : public VNVisitor {
|
||||
m_ds.m_unresolvedCell = true;
|
||||
// And pass up m_ds.m_dotText
|
||||
}
|
||||
// Pass dot state down to fromp()
|
||||
// Pass dot state down to only fromp()
|
||||
iterateAndNextNull(nodep->fromp());
|
||||
{
|
||||
VL_RESTORER(m_ds);
|
||||
{
|
||||
m_ds.init(m_curSymp);
|
||||
iterateAndNextNull(nodep->bitp());
|
||||
iterateAndNextNull(nodep->attrp());
|
||||
}
|
||||
}
|
||||
symIterateNull(nodep->bitp(), m_curSymp);
|
||||
symIterateNull(nodep->attrp(), m_curSymp);
|
||||
if (m_ds.m_unresolvedCell && (m_ds.m_dotPos == DP_SCOPE || m_ds.m_dotPos == DP_FIRST)) {
|
||||
AstNodeExpr* const exprp = nodep->bitp()->unlinkFrBack();
|
||||
AstCellArrayRef* const newp
|
||||
@ -3763,12 +3773,8 @@ class LinkDotResolveVisitor final : public VNVisitor {
|
||||
return;
|
||||
}
|
||||
iterateAndNextNull(nodep->fromp());
|
||||
VL_RESTORER(m_ds);
|
||||
{
|
||||
m_ds.init(m_curSymp);
|
||||
iterateAndNextNull(nodep->rhsp());
|
||||
iterateAndNextNull(nodep->thsp());
|
||||
}
|
||||
symIterateNull(nodep->rhsp(), m_curSymp);
|
||||
symIterateNull(nodep->thsp(), m_curSymp);
|
||||
|
||||
if (nodep->attrp()) {
|
||||
AstNode* const attrp = nodep->attrp()->unlinkFrBack();
|
||||
@ -3792,15 +3798,15 @@ class LinkDotResolveVisitor final : public VNVisitor {
|
||||
LINKDOT_VISIT_START();
|
||||
UINFO(5, indent() << "visit " << nodep << endl);
|
||||
checkNoDot(nodep);
|
||||
VL_RESTORER(m_curSymp);
|
||||
{
|
||||
VL_RESTORER(m_curSymp);
|
||||
VL_RESTORER(m_ds);
|
||||
if (nodep->name() != "") {
|
||||
m_ds.m_dotSymp = m_curSymp = m_statep->getNodeSym(nodep);
|
||||
UINFO(5, indent() << "cur=se" << cvtToHex(m_curSymp) << endl);
|
||||
}
|
||||
iterateChildren(nodep);
|
||||
}
|
||||
m_ds.m_dotSymp = VL_RESTORER_PREV(m_curSymp);
|
||||
UINFO(5, indent() << "cur=se" << cvtToHex(m_curSymp) << endl);
|
||||
}
|
||||
void visit(AstNodeFTask* nodep) override {
|
||||
@ -3849,25 +3855,15 @@ class LinkDotResolveVisitor final : public VNVisitor {
|
||||
LINKDOT_VISIT_START();
|
||||
UINFO(5, indent() << "visit " << nodep << endl);
|
||||
checkNoDot(nodep);
|
||||
VL_RESTORER(m_curSymp);
|
||||
{
|
||||
m_ds.m_dotSymp = m_curSymp = m_statep->getNodeSym(nodep);
|
||||
iterateChildren(nodep);
|
||||
}
|
||||
m_ds.m_dotSymp = VL_RESTORER_PREV(m_curSymp);
|
||||
symIterateChildren(nodep, m_statep->getNodeSym(nodep));
|
||||
}
|
||||
void visit(AstWith* nodep) override {
|
||||
LINKDOT_VISIT_START();
|
||||
UINFO(5, indent() << "visit " << nodep << endl);
|
||||
checkNoDot(nodep);
|
||||
VL_RESTORER(m_curSymp);
|
||||
VL_RESTORER(m_inWith);
|
||||
{
|
||||
m_ds.m_dotSymp = m_curSymp = m_statep->getNodeSym(nodep);
|
||||
m_inWith = true;
|
||||
iterateChildren(nodep);
|
||||
}
|
||||
m_ds.m_dotSymp = VL_RESTORER_PREV(m_curSymp);
|
||||
m_inWith = true;
|
||||
symIterateChildren(nodep, m_statep->getNodeSym(nodep));
|
||||
}
|
||||
void visit(AstLambdaArgRef* nodep) override {
|
||||
LINKDOT_VISIT_START();
|
||||
|
Loading…
Reference in New Issue
Block a user