Internals: Cleanups towards static class members. No functional change intended.

This commit is contained in:
Wilson Snyder 2022-01-02 15:03:57 -05:00
parent 3b1371124e
commit f1bb0544be
4 changed files with 12 additions and 18 deletions

View File

@ -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<const void*>(scopep()) << "]";
if (varp()) {
str << " -> ";
varp()->dump(str);

View File

@ -130,7 +130,6 @@ private:
}
}
}
virtual void visit(AstCFunc* nodep) override {
iterateChildren(nodep);
// Don't move now, or wouldn't keep interating the class

View File

@ -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);
}

View File

@ -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;