Internals: Fix missing const. No functional change.

This commit is contained in:
Wilson Snyder 2022-12-01 18:47:09 -05:00
parent e465a30eee
commit 87135d0b2d
2 changed files with 23 additions and 23 deletions

View File

@ -82,7 +82,7 @@ public:
// Iff has second dtype, set as generic node function // Iff has second dtype, set as generic node function
virtual void virtRefDType2p(AstNodeDType* nodep) {} virtual void virtRefDType2p(AstNodeDType* nodep) {}
// Assignable equivalence. Call skipRefp() on this and samep before calling // Assignable equivalence. Call skipRefp() on this and samep before calling
virtual bool similarDType(AstNodeDType* samep) const = 0; virtual bool similarDType(const AstNodeDType* samep) const = 0;
// Iff has a non-null subDTypep(), as generic node function // Iff has a non-null subDTypep(), as generic node function
virtual AstNodeDType* subDTypep() const { return nullptr; } virtual AstNodeDType* subDTypep() const { return nullptr; }
virtual bool isFourstate() const; virtual bool isFourstate() const;
@ -161,7 +161,7 @@ public:
return (hi() == asamep->hi() && subDTypep() == asamep->subDTypep() return (hi() == asamep->hi() && subDTypep() == asamep->subDTypep()
&& rangenp()->sameTree(asamep->rangenp())); && rangenp()->sameTree(asamep->rangenp()));
} // HashedDT doesn't recurse, so need to check children } // HashedDT doesn't recurse, so need to check children
bool similarDType(AstNodeDType* samep) const override { bool similarDType(const AstNodeDType* samep) const override {
const AstNodeArrayDType* const asamep = static_cast<const AstNodeArrayDType*>(samep); const AstNodeArrayDType* const asamep = static_cast<const AstNodeArrayDType*>(samep);
return (asamep && type() == samep->type() && hi() == asamep->hi() return (asamep && type() == samep->type() && hi() == asamep->hi()
&& rangenp()->sameTree(asamep->rangenp()) && rangenp()->sameTree(asamep->rangenp())
@ -235,7 +235,7 @@ public:
int widthAlignBytes() const override; int widthAlignBytes() const override;
// (Slow) recurses - Width in bytes rounding up 1,2,4,8,12,... // (Slow) recurses - Width in bytes rounding up 1,2,4,8,12,...
int widthTotalBytes() const override; int widthTotalBytes() const override;
bool similarDType(AstNodeDType* samep) const override { bool similarDType(const AstNodeDType* samep) const override {
return this == samep; // We don't compare members, require exact equivalence return this == samep; // We don't compare members, require exact equivalence
} }
string name() const override { return m_name; } string name() const override { return m_name; }
@ -321,7 +321,7 @@ public:
if (!asamep->keyDTypep()) return false; if (!asamep->keyDTypep()) return false;
return (subDTypep() == asamep->subDTypep() && keyDTypep() == asamep->keyDTypep()); return (subDTypep() == asamep->subDTypep() && keyDTypep() == asamep->keyDTypep());
} }
bool similarDType(AstNodeDType* samep) const override { bool similarDType(const AstNodeDType* samep) const override {
const AstAssocArrayDType* const asamep = static_cast<const AstAssocArrayDType*>(samep); const AstAssocArrayDType* const asamep = static_cast<const AstAssocArrayDType*>(samep);
return type() == samep->type() && asamep->subDTypep() return type() == samep->type() && asamep->subDTypep()
&& subDTypep()->skipRefp()->similarDType(asamep->subDTypep()->skipRefp()); && subDTypep()->skipRefp()->similarDType(asamep->subDTypep()->skipRefp());
@ -399,7 +399,7 @@ public:
const AstBasicDType* const sp = static_cast<const AstBasicDType*>(samep); const AstBasicDType* const sp = static_cast<const AstBasicDType*>(samep);
return m == sp->m; return m == sp->m;
} }
bool similarDType(AstNodeDType* samep) const override { bool similarDType(const AstNodeDType* samep) const override {
return type() == samep->type() && same(samep); return type() == samep->type() && same(samep);
} }
string name() const override { return m.m_keyword.ascii(); } string name() const override { return m.m_keyword.ascii(); }
@ -483,7 +483,7 @@ public:
this->elementsp(elementsp); this->elementsp(elementsp);
} }
ASTGEN_MEMBERS_AstBracketArrayDType; ASTGEN_MEMBERS_AstBracketArrayDType;
bool similarDType(AstNodeDType* samep) const override { V3ERROR_NA_RETURN(false); } bool similarDType(const AstNodeDType* samep) const override { V3ERROR_NA_RETURN(false); }
AstNodeDType* subDTypep() const override { return childDTypep(); } AstNodeDType* subDTypep() const override { return childDTypep(); }
// METHODS // METHODS
// Will be removed in V3Width, which relies on this // Will be removed in V3Width, which relies on this
@ -518,7 +518,7 @@ public:
const AstClassRefDType* const asamep = static_cast<const AstClassRefDType*>(samep); const AstClassRefDType* const asamep = static_cast<const AstClassRefDType*>(samep);
return (m_classp == asamep->m_classp && m_classOrPackagep == asamep->m_classOrPackagep); return (m_classp == asamep->m_classp && m_classOrPackagep == asamep->m_classOrPackagep);
} }
bool similarDType(AstNodeDType* samep) const override { bool similarDType(const AstNodeDType* samep) const override {
return this == samep || (type() == samep->type() && same(samep)); return this == samep || (type() == samep->type() && same(samep));
} }
void dump(std::ostream& str = std::cout) const override; void dump(std::ostream& str = std::cout) const override;
@ -567,7 +567,7 @@ public:
const AstConstDType* const sp = static_cast<const AstConstDType*>(samep); const AstConstDType* const sp = static_cast<const AstConstDType*>(samep);
return (m_refDTypep == sp->m_refDTypep); return (m_refDTypep == sp->m_refDTypep);
} }
bool similarDType(AstNodeDType* samep) const override { bool similarDType(const AstNodeDType* samep) const override {
return skipRefp()->similarDType(samep->skipRefp()); return skipRefp()->similarDType(samep->skipRefp());
} }
AstNodeDType* getChildDTypep() const override { return childDTypep(); } AstNodeDType* getChildDTypep() const override { return childDTypep(); }
@ -614,7 +614,7 @@ public:
const AstDefImplicitDType* const sp = static_cast<const AstDefImplicitDType*>(samep); const AstDefImplicitDType* const sp = static_cast<const AstDefImplicitDType*>(samep);
return uniqueNum() == sp->uniqueNum(); return uniqueNum() == sp->uniqueNum();
} }
bool similarDType(AstNodeDType* samep) const override { bool similarDType(const AstNodeDType* samep) const override {
return type() == samep->type() && same(samep); return type() == samep->type() && same(samep);
} }
AstNodeDType* getChildDTypep() const override { return childDTypep(); } AstNodeDType* getChildDTypep() const override { return childDTypep(); }
@ -664,7 +664,7 @@ public:
if (!asamep->subDTypep()) return false; if (!asamep->subDTypep()) return false;
return subDTypep() == asamep->subDTypep(); return subDTypep() == asamep->subDTypep();
} }
bool similarDType(AstNodeDType* samep) const override { bool similarDType(const AstNodeDType* samep) const override {
const AstAssocArrayDType* const asamep = static_cast<const AstAssocArrayDType*>(samep); const AstAssocArrayDType* const asamep = static_cast<const AstAssocArrayDType*>(samep);
return type() == samep->type() && asamep->subDTypep() return type() == samep->type() && asamep->subDTypep()
&& subDTypep()->skipRefp()->similarDType(asamep->subDTypep()->skipRefp()); && subDTypep()->skipRefp()->similarDType(asamep->subDTypep()->skipRefp());
@ -702,7 +702,7 @@ public:
AstNodeDType* subDTypep() const override { return nullptr; } AstNodeDType* subDTypep() const override { return nullptr; }
AstNodeDType* virtRefDTypep() const override { return nullptr; } AstNodeDType* virtRefDTypep() const override { return nullptr; }
void virtRefDTypep(AstNodeDType* nodep) override {} void virtRefDTypep(AstNodeDType* nodep) override {}
bool similarDType(AstNodeDType* samep) const override { return this == samep; } bool similarDType(const AstNodeDType* samep) const override { return this == samep; }
AstBasicDType* basicp() const override VL_MT_SAFE { return nullptr; } AstBasicDType* basicp() const override VL_MT_SAFE { return nullptr; }
// cppcheck-suppress csyleCast // cppcheck-suppress csyleCast
AstNodeDType* skipRefp() const override VL_MT_SAFE { return (AstNodeDType*)this; } AstNodeDType* skipRefp() const override VL_MT_SAFE { return (AstNodeDType*)this; }
@ -747,7 +747,7 @@ public:
const AstEnumDType* const sp = static_cast<const AstEnumDType*>(samep); const AstEnumDType* const sp = static_cast<const AstEnumDType*>(samep);
return uniqueNum() == sp->uniqueNum(); return uniqueNum() == sp->uniqueNum();
} }
bool similarDType(AstNodeDType* samep) const override { return this == samep; } bool similarDType(const AstNodeDType* samep) const override { return this == samep; }
AstNodeDType* getChildDTypep() const override { return childDTypep(); } AstNodeDType* getChildDTypep() const override { return childDTypep(); }
AstNodeDType* subDTypep() const override { return m_refDTypep ? m_refDTypep : childDTypep(); } AstNodeDType* subDTypep() const override { return m_refDTypep ? m_refDTypep : childDTypep(); }
void refDTypep(AstNodeDType* nodep) { m_refDTypep = nodep; } void refDTypep(AstNodeDType* nodep) { m_refDTypep = nodep; }
@ -815,7 +815,7 @@ public:
AstNodeDType* skipRefp() const override VL_MT_SAFE { return (AstNodeDType*)this; } AstNodeDType* skipRefp() const override VL_MT_SAFE { return (AstNodeDType*)this; }
AstNodeDType* skipRefToConstp() const override { return (AstNodeDType*)this; } AstNodeDType* skipRefToConstp() const override { return (AstNodeDType*)this; }
AstNodeDType* skipRefToEnump() const override { return (AstNodeDType*)this; } AstNodeDType* skipRefToEnump() const override { return (AstNodeDType*)this; }
bool similarDType(AstNodeDType* samep) const override { return this == samep; } bool similarDType(const AstNodeDType* samep) const override { return this == samep; }
int widthAlignBytes() const override { return 1; } int widthAlignBytes() const override { return 1; }
int widthTotalBytes() const override { return 1; } int widthTotalBytes() const override { return 1; }
FileLine* modportFileline() const { return m_modportFileline; } FileLine* modportFileline() const { return m_modportFileline; }
@ -876,7 +876,7 @@ public:
void refDTypep(AstNodeDType* nodep) { m_refDTypep = nodep; } void refDTypep(AstNodeDType* nodep) { m_refDTypep = nodep; }
AstNodeDType* virtRefDTypep() const override { return m_refDTypep; } AstNodeDType* virtRefDTypep() const override { return m_refDTypep; }
void virtRefDTypep(AstNodeDType* nodep) override { refDTypep(nodep); } void virtRefDTypep(AstNodeDType* nodep) override { refDTypep(nodep); }
bool similarDType(AstNodeDType* samep) const override { return this == samep; } bool similarDType(const AstNodeDType* samep) const override { return this == samep; }
// //
// (Slow) recurse down to find basic data type (Note don't need virtual - // (Slow) recurse down to find basic data type (Note don't need virtual -
// AstVar isn't a NodeDType) // AstVar isn't a NodeDType)
@ -925,7 +925,7 @@ public:
AstNodeDType* skipRefp() const override VL_MT_SAFE { return subDTypep()->skipRefp(); } AstNodeDType* skipRefp() const override VL_MT_SAFE { return subDTypep()->skipRefp(); }
AstNodeDType* skipRefToConstp() const override { return subDTypep()->skipRefToConstp(); } AstNodeDType* skipRefToConstp() const override { return subDTypep()->skipRefToConstp(); }
AstNodeDType* skipRefToEnump() const override { return subDTypep()->skipRefToEnump(); } AstNodeDType* skipRefToEnump() const override { return subDTypep()->skipRefToEnump(); }
bool similarDType(AstNodeDType* samep) const override { bool similarDType(const AstNodeDType* samep) const override {
const AstParamTypeDType* const sp = static_cast<const AstParamTypeDType*>(samep); const AstParamTypeDType* const sp = static_cast<const AstParamTypeDType*>(samep);
return type() == samep->type() && sp return type() == samep->type() && sp
&& this->subDTypep()->skipRefp()->similarDType(sp->subDTypep()->skipRefp()); && this->subDTypep()->skipRefp()->similarDType(sp->subDTypep()->skipRefp());
@ -955,7 +955,7 @@ public:
ASTGEN_MEMBERS_AstParseTypeDType; ASTGEN_MEMBERS_AstParseTypeDType;
AstNodeDType* dtypep() const { return nullptr; } AstNodeDType* dtypep() const { return nullptr; }
// METHODS // METHODS
bool similarDType(AstNodeDType* samep) const override { return this == samep; } bool similarDType(const AstNodeDType* samep) const override { return this == samep; }
AstBasicDType* basicp() const override VL_MT_SAFE { return nullptr; } AstBasicDType* basicp() const override VL_MT_SAFE { return nullptr; }
AstNodeDType* skipRefp() const override VL_MT_SAFE { return nullptr; } AstNodeDType* skipRefp() const override VL_MT_SAFE { return nullptr; }
// cppcheck-suppress csyleCast // cppcheck-suppress csyleCast
@ -1003,7 +1003,7 @@ public:
if (!asamep->subDTypep()) return false; if (!asamep->subDTypep()) return false;
return (subDTypep() == asamep->subDTypep()); return (subDTypep() == asamep->subDTypep());
} }
bool similarDType(AstNodeDType* samep) const override { bool similarDType(const AstNodeDType* samep) const override {
const AstQueueDType* const asamep = static_cast<const AstQueueDType*>(samep); const AstQueueDType* const asamep = static_cast<const AstQueueDType*>(samep);
return type() == samep->type() && asamep->subDTypep() return type() == samep->type() && asamep->subDTypep()
&& subDTypep()->skipRefp()->similarDType(asamep->subDTypep()->skipRefp()); && subDTypep()->skipRefp()->similarDType(asamep->subDTypep()->skipRefp());
@ -1066,7 +1066,7 @@ public:
return (m_typedefp == asamep->m_typedefp && m_refDTypep == asamep->m_refDTypep return (m_typedefp == asamep->m_typedefp && m_refDTypep == asamep->m_refDTypep
&& m_name == asamep->m_name && m_classOrPackagep == asamep->m_classOrPackagep); && m_name == asamep->m_name && m_classOrPackagep == asamep->m_classOrPackagep);
} }
bool similarDType(AstNodeDType* samep) const override { bool similarDType(const AstNodeDType* samep) const override {
return skipRefp()->similarDType(samep->skipRefp()); return skipRefp()->similarDType(samep->skipRefp());
} }
void dump(std::ostream& str = std::cout) const override; void dump(std::ostream& str = std::cout) const override;
@ -1143,7 +1143,7 @@ public:
if (m_refDTypep && m_refDTypep->clonep()) m_refDTypep = m_refDTypep->clonep(); if (m_refDTypep && m_refDTypep->clonep()) m_refDTypep = m_refDTypep->clonep();
} }
bool same(const AstNode* samep) const override; bool same(const AstNode* samep) const override;
bool similarDType(AstNodeDType* samep) const override; bool similarDType(const AstNodeDType* samep) const override;
void dumpSmall(std::ostream& str) const override; void dumpSmall(std::ostream& str) const override;
AstNodeDType* getChildDTypep() const override { return childDTypep(); } AstNodeDType* getChildDTypep() const override { return childDTypep(); }
AstNodeDType* subDTypep() const override { return m_refDTypep ? m_refDTypep : childDTypep(); } AstNodeDType* subDTypep() const override { return m_refDTypep ? m_refDTypep : childDTypep(); }
@ -1174,7 +1174,7 @@ public:
AstNodeDType* subDTypep() const override { return nullptr; } AstNodeDType* subDTypep() const override { return nullptr; }
AstNodeDType* virtRefDTypep() const override { return nullptr; } AstNodeDType* virtRefDTypep() const override { return nullptr; }
void virtRefDTypep(AstNodeDType* nodep) override {} void virtRefDTypep(AstNodeDType* nodep) override {}
bool similarDType(AstNodeDType* samep) const override { return this == samep; } bool similarDType(const AstNodeDType* samep) const override { return this == samep; }
AstBasicDType* basicp() const override VL_MT_SAFE { return nullptr; } AstBasicDType* basicp() const override VL_MT_SAFE { return nullptr; }
// cppcheck-suppress csyleCast // cppcheck-suppress csyleCast
AstNodeDType* skipRefp() const override VL_MT_SAFE { return (AstNodeDType*)this; } AstNodeDType* skipRefp() const override VL_MT_SAFE { return (AstNodeDType*)this; }
@ -1208,7 +1208,7 @@ public:
if (m_refDTypep && m_refDTypep->clonep()) m_refDTypep = m_refDTypep->clonep(); if (m_refDTypep && m_refDTypep->clonep()) m_refDTypep = m_refDTypep->clonep();
} }
bool same(const AstNode* samep) const override; bool same(const AstNode* samep) const override;
bool similarDType(AstNodeDType* samep) const override; bool similarDType(const AstNodeDType* samep) const override;
void dumpSmall(std::ostream& str) const override; void dumpSmall(std::ostream& str) const override;
AstNodeDType* getChildDTypep() const override { return childDTypep(); } AstNodeDType* getChildDTypep() const override { return childDTypep(); }
AstNodeDType* subDTypep() const override VL_MT_SAFE { AstNodeDType* subDTypep() const override VL_MT_SAFE {

View File

@ -1994,7 +1994,7 @@ bool AstWildcardArrayDType::same(const AstNode* samep) const {
if (!asamep->subDTypep()) return false; if (!asamep->subDTypep()) return false;
return (subDTypep() == asamep->subDTypep()); return (subDTypep() == asamep->subDTypep());
} }
bool AstWildcardArrayDType::similarDType(AstNodeDType* samep) const { bool AstWildcardArrayDType::similarDType(const AstNodeDType* samep) const {
const AstNodeArrayDType* const asamep = static_cast<const AstNodeArrayDType*>(samep); const AstNodeArrayDType* const asamep = static_cast<const AstNodeArrayDType*>(samep);
return type() == samep->type() && asamep->subDTypep() return type() == samep->type() && asamep->subDTypep()
&& subDTypep()->skipRefp()->similarDType(asamep->subDTypep()->skipRefp()); && subDTypep()->skipRefp()->similarDType(asamep->subDTypep()->skipRefp());
@ -2008,7 +2008,7 @@ bool AstUnsizedArrayDType::same(const AstNode* samep) const {
if (!asamep->subDTypep()) return false; if (!asamep->subDTypep()) return false;
return (subDTypep() == asamep->subDTypep()); return (subDTypep() == asamep->subDTypep());
} }
bool AstUnsizedArrayDType::similarDType(AstNodeDType* samep) const { bool AstUnsizedArrayDType::similarDType(const AstNodeDType* samep) const {
const AstNodeArrayDType* const asamep = static_cast<const AstNodeArrayDType*>(samep); const AstNodeArrayDType* const asamep = static_cast<const AstNodeArrayDType*>(samep);
return type() == samep->type() && asamep->subDTypep() return type() == samep->type() && asamep->subDTypep()
&& subDTypep()->skipRefp()->similarDType(asamep->subDTypep()->skipRefp()); && subDTypep()->skipRefp()->similarDType(asamep->subDTypep()->skipRefp());