From acf943005aa2a6925e4da439cc81a7f030f85618 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20=C5=9Aliwak?= Date: Thu, 1 Dec 2022 00:28:45 +0100 Subject: [PATCH] Make ReferenceType::stringForReferencePart() public --- libsolidity/ast/Types.cpp | 10 ++++++---- libsolidity/ast/Types.h | 6 ++++-- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/libsolidity/ast/Types.cpp b/libsolidity/ast/Types.cpp index 22265b587..8f305669b 100644 --- a/libsolidity/ast/Types.cpp +++ b/libsolidity/ast/Types.cpp @@ -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 diff --git a/libsolidity/ast/Types.h b/libsolidity/ast/Types.h index 9574bb4ae..f240ee3c0 100644 --- a/libsolidity/ast/Types.h +++ b/libsolidity/ast/Types.h @@ -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;