diff --git a/src/V3AstNodes.cpp b/src/V3AstNodes.cpp index ac382cd03..dd05e1be1 100644 --- a/src/V3AstNodes.cpp +++ b/src/V3AstNodes.cpp @@ -1681,6 +1681,8 @@ void AstVoidDType::dumpSmall(std::ostream& str) const { void AstVarScope::dump(std::ostream& str) const { this->AstNode::dump(str); if (isCircular()) str << " [CIRC]"; + if (isTrace()) str << " [T]"; + if (scopep()) str << " [scopep=" << reinterpret_cast(scopep()) << "]"; if (varp()) { str << " -> "; varp()->dump(str); diff --git a/src/V3Class.cpp b/src/V3Class.cpp index b50c147d8..c0e943d08 100644 --- a/src/V3Class.cpp +++ b/src/V3Class.cpp @@ -130,7 +130,6 @@ private: } } } - virtual void visit(AstCFunc* nodep) override { iterateChildren(nodep); // Don't move now, or wouldn't keep interating the class diff --git a/src/V3Descope.cpp b/src/V3Descope.cpp index 964716034..29bdd3abc 100644 --- a/src/V3Descope.cpp +++ b/src/V3Descope.cpp @@ -73,8 +73,6 @@ private: // module. string descopedSelfPointer(const AstScope* scopep) { UASSERT(scopep, "Var/Func not scoped"); - UASSERT(!VN_IS(scopep->modp(), Class), "References to classes handled elsewhere"); - // Static functions can't use relative references via 'this->' const bool relativeRefOk = !m_funcp->isStatic(); @@ -82,7 +80,11 @@ private: UINFO(8, " ref to " << scopep << endl); UINFO(8, " aboveScope " << scopep->aboveScopep() << endl); - if (relativeRefOk && scopep == m_scopep) { + if (VN_IS(scopep->modp(), Class)) { + // Direct reference to class members are from within the class itself, references from + // outside the class must go via AstMemberSel + return "this"; + } else if (relativeRefOk && scopep == m_scopep) { return "this"; } else if (relativeRefOk && !m_modSingleton && scopep->aboveScopep() == m_scopep && VN_IS(scopep->modp(), Module)) { @@ -224,15 +226,11 @@ private: } else if (scopep->modp() == v3Global.rootp()->constPoolp()->modp()) { // Reference to constant pool value need no self pointer nodep->selfPointer(""); - } else if (VN_IS(scopep->modp(), Class)) { - // Direct reference to class members are from within the class itself, references from - // outside the class must go via AstMemberSel - nodep->selfPointer("this"); } else { nodep->selfPointer(descopedSelfPointer(scopep)); } nodep->varScopep(nullptr); - UINFO(9, " refout " << nodep << endl); + UINFO(9, " refout " << nodep << " selfPtr=" << nodep->selfPointer() << endl); } virtual void visit(AstCCall* nodep) override { // UINFO(9, " " << nodep << endl); @@ -240,13 +238,7 @@ private: // Convert the hierch name UASSERT_OBJ(m_scopep, nodep, "Node not under scope"); const AstScope* const scopep = nodep->funcp()->scopep(); - if (VN_IS(scopep->modp(), Class)) { - // Direct call to class methods are from within the class itself, method calls from - // outside the class must go via AstCMethodCall - nodep->selfPointer("this"); - } else { - nodep->selfPointer(descopedSelfPointer(scopep)); - } + nodep->selfPointer(descopedSelfPointer(scopep)); // Can't do this, as we may have more calls later // nodep->funcp()->scopep(nullptr); } diff --git a/src/V3LinkDot.cpp b/src/V3LinkDot.cpp index 19784211c..8419a5a82 100644 --- a/src/V3LinkDot.cpp +++ b/src/V3LinkDot.cpp @@ -2113,8 +2113,9 @@ private: // Legal under a DOT: AstDot, AstParseRef, AstPackageRef, AstNodeSel // also a DOT can be part of an expression, but only above plus // AstFTaskRef are legal children - // DOT(PACKAGEREF, PARSEREF(text)) - // DOT(DOT(DOT(PARSEREF(text), ... + // Dot(PackageRef, ParseRef(text)) + // Dot(Dot(ClassOrPackageRef,ClassOrPackageRef), ParseRef(text)) + // Dot(Dot(Dot(ParseRef(text), ... if (nodep->user3SetOnce()) return; UINFO(8, " " << nodep << endl); const DotStates lastStates = m_ds;