Internals: Remove m_classPrefix from AstNodeVarRef/AstNodeCCall

This is now redundant and can be reconstituted in V3EmitC without being
explicitly stored.
This commit is contained in:
Geza Lore 2021-06-19 15:50:29 +01:00
parent 2ee52222e2
commit fcb8bc22bd
5 changed files with 8 additions and 39 deletions

View File

@ -2285,7 +2285,6 @@ private:
AstNodeModule* m_classOrPackagep = nullptr; // Package hierarchy
string m_name; // Name of variable
string m_selfPointer; // Output code object pointer (e.g.: 'this')
string m_classPrefix; // Output class prefix (i.e.: the part before ::)
protected:
AstNodeVarRef(AstType t, FileLine* fl, const string& name, const VAccess& access)
@ -2320,9 +2319,6 @@ public:
string selfPointer() const { return m_selfPointer; }
void selfPointer(const string& value) { m_selfPointer = value; }
string selfPointerProtect(bool useSelfForThis) const;
string classPrefix() const { return m_classPrefix; }
void classPrefix(const string& value) { m_classPrefix = value; }
string classPrefixProtect() const;
AstNodeModule* classOrPackagep() const { return m_classOrPackagep; }
void classOrPackagep(AstNodeModule* nodep) { m_classOrPackagep = nodep; }
// Know no children, and hot function, so skip iterator for speed
@ -2626,7 +2622,6 @@ class AstNodeCCall VL_NOT_FINAL : public AstNodeStmt {
// Functions are not statements, while tasks are. AstNodeStmt needs isStatement() to deal.
AstCFunc* m_funcp;
string m_selfPointer; // Output code object pointer (e.g.: 'this')
string m_classPrefix; // Output class prefix (i.e.: the part before ::)
string m_argTypes;
protected:
@ -2655,9 +2650,6 @@ public:
string selfPointer() const { return m_selfPointer; }
void selfPointer(const string& value) { m_selfPointer = value; }
string selfPointerProtect(bool useSelfForThis) const;
string classPrefix() const { return m_classPrefix; }
void classPrefix(const string& value) { m_classPrefix = value; }
string classPrefixProtect() const;
void argTypes(const string& str) { m_argTypes = str; }
string argTypes() const { return m_argTypes; }
// op1p reserved for AstCMethodCall

View File

@ -63,10 +63,6 @@ string AstNodeVarRef::selfPointerProtect(bool useSelfForThis) const {
return VIdProtect::protectWordsIf(sp, protect());
}
string AstNodeVarRef::classPrefixProtect() const {
return v3Global.opt.modPrefix() + "_" + VIdProtect::protectWordsIf(classPrefix(), protect());
}
void AstAddrOfCFunc::cloneRelink() {
if (m_funcp && m_funcp->clonep()) m_funcp = m_funcp->clonep();
}
@ -130,9 +126,6 @@ string AstNodeCCall::selfPointerProtect(bool useSelfForThis) const {
= useSelfForThis ? VString::replaceWord(selfPointer(), "this", "vlSelf") : selfPointer();
return VIdProtect::protectWordsIf(sp, protect());
}
string AstNodeCCall::classPrefixProtect() const {
return v3Global.opt.modPrefix() + "_" + VIdProtect::protectWordsIf(classPrefix(), protect());
}
void AstNodeCond::numberOperate(V3Number& out, const V3Number& lhs, const V3Number& rhs,
const V3Number& ths) {

View File

@ -73,7 +73,6 @@ public:
= oldp->argsp() ? oldp->argsp()->unlinkFrBackWithNext() : nullptr;
AstCCall* const newp = new AstCCall(oldp->fileline(), newfuncp, argsp);
newp->selfPointer(oldp->selfPointer());
newp->classPrefix(oldp->classPrefix());
newp->argTypes(oldp->argTypes());
addCall(newp); // Fix the table, in case the newfuncp itself gets replaced
oldp->replaceWith(newp);

View File

@ -106,17 +106,6 @@ private:
}
}
// Construct the class prefix (as in, the part before the :: scope resolution operator) when
// referencing an object in 'scopep' from a CFunc in 'm_scopep'.
string descopedClassPrefix(const AstScope* scopep) {
UASSERT(scopep, "Var/Func not scoped");
if (VN_IS(scopep->modp(), Class) && scopep != m_scopep) {
return scopep->modp()->name();
} else {
return "";
}
}
void makePublicFuncWrappers() {
// We recorded all public functions in m_modFuncs.
// If for any given name only one function exists, we can use that function directly.
@ -229,10 +218,7 @@ private:
UASSERT_OBJ(m_scopep, nodep, "Node not under scope");
const AstVar* const varp = nodep->varScopep()->varp();
const AstScope* const scopep = nodep->varScopep()->scopep();
if (!varp->isFuncLocal()) {
nodep->selfPointer(descopedSelfPointer(scopep));
nodep->classPrefix(descopedClassPrefix(scopep));
}
if (!varp->isFuncLocal()) { nodep->selfPointer(descopedSelfPointer(scopep)); }
nodep->varScopep(nullptr);
UINFO(9, " refout " << nodep << endl);
}
@ -243,7 +229,6 @@ private:
UASSERT_OBJ(m_scopep, nodep, "Node not under scope");
const AstScope* const scopep = nodep->funcp()->scopep();
nodep->selfPointer(descopedSelfPointer(scopep));
nodep->classPrefix(descopedClassPrefix(scopep));
// Can't do this, as we may have more calls later
// nodep->funcp()->scopep(nullptr);
}

View File

@ -386,12 +386,11 @@ public:
puts(funcp->name());
} else if (funcp->isProperMethod() && funcp->isStatic()) {
// Call static method via the containing class
AstNodeModule* modp = VN_CAST(funcp->user4p(), NodeModule);
puts(prefixNameProtect(modp) + "::");
puts(prefixNameProtect(funcp->user4p()) + "::");
puts(funcp->nameProtect());
} else if (!nodep->classPrefix().empty()) {
// Prefix explicitly given
puts(nodep->classPrefixProtect() + "::");
} else if (VN_IS(funcp->user4p(), Class) && funcp->user4p() != m_modp) {
// Calling superclass method
puts(prefixNameProtect(funcp->user4p()) + "::");
puts(funcp->nameProtect());
} else if (funcp->isLoose()) {
// Calling loose method
@ -1133,8 +1132,9 @@ public:
} else if (varp->isStatic()) {
// Access static variable via the containing class
puts(prefixNameProtect(varp->user4p()) + "::");
} else if (!nodep->classPrefix().empty()) {
puts(nodep->classPrefixProtect() + "::");
} else if (VN_IS(varp->user4p(), Class) && varp->user4p() != m_modp) {
// Superclass member reference
puts(prefixNameProtect(varp->user4p()) + "::");
} else if (!nodep->selfPointer().empty()) {
emitDereference(nodep->selfPointerProtect(m_useSelfForThis));
}