Make ReferenceType::stringForReferencePart() public

This commit is contained in:
Kamil Śliwak 2022-12-01 00:28:45 +01:00
parent 56a6613c21
commit acf943005a
2 changed files with 10 additions and 6 deletions

View File

@ -1561,19 +1561,21 @@ Type const* ReferenceType::copyForLocationIfReference(Type const* _type) const
return TypeProvider::withLocationIfReference(m_location, _type);
}
string ReferenceType::stringForReferencePart() const
string ReferenceType::stringForReferencePart(bool _showIndirection) const
{
switch (m_location)
{
case DataLocation::Storage:
return string("storage ") + (isPointer() ? "pointer" : "ref");
if (_showIndirection)
return string("storage ") + (_showIndirection && isPointer() ? "pointer" : "ref");
else
return string("storage");
case DataLocation::CallData:
return "calldata";
case DataLocation::Memory:
return "memory";
}
solAssert(false, "");
return "";
solAssert(false);
}
string ReferenceType::identifierLocationSuffix() const

View File

@ -793,10 +793,12 @@ public:
Type const* withLocation(DataLocation _location, bool _isPointer) const;
/// @returns a human-readable description of the reference part of the type.
/// @param _showIndirection If true, the description indicates whether it's a pointer or not.
std::string stringForReferencePart(bool _showIndirection = true) const;
protected:
Type const* copyForLocationIfReference(Type const* _type) const;
/// @returns a human-readable description of the reference part of the type.
std::string stringForReferencePart() const;
/// @returns the suffix computed from the reference part to be used by identifier();
std::string identifierLocationSuffix() const;