aboutsummaryrefslogtreecommitdiffstats
path: root/libsolidity/ast
diff options
context:
space:
mode:
authorchriseth <chris@ethereum.org>2018-02-21 07:40:38 +0800
committerAlex Beregszaszi <alex@rtfs.hu>2018-03-21 22:53:29 +0800
commitcc2f71e4acede70f6c220d3d0ba407ab73c2024c (patch)
treeb280c6bbd441b395a3ed172bdb01d60f40ff15a7 /libsolidity/ast
parent32c94f505901201126000eb12087251f5695acbd (diff)
downloaddexon-solidity-cc2f71e4acede70f6c220d3d0ba407ab73c2024c.tar.gz
dexon-solidity-cc2f71e4acede70f6c220d3d0ba407ab73c2024c.tar.zst
dexon-solidity-cc2f71e4acede70f6c220d3d0ba407ab73c2024c.zip
Move dynamic type removal out of the type system.
Diffstat (limited to 'libsolidity/ast')
-rw-r--r--libsolidity/ast/Types.cpp23
-rw-r--r--libsolidity/ast/Types.h3
2 files changed, 16 insertions, 10 deletions
diff --git a/libsolidity/ast/Types.cpp b/libsolidity/ast/Types.cpp
index b2881bea..41700e28 100644
--- a/libsolidity/ast/Types.cpp
+++ b/libsolidity/ast/Types.cpp
@@ -2311,6 +2311,18 @@ vector<string> FunctionType::parameterNames() const
return vector<string>(m_parameterNames.cbegin() + 1, m_parameterNames.cend());
}
+TypePointers FunctionType::returnParameterTypesWithoutDynamicTypes() const
+{
+ TypePointers returnParameterTypes = m_returnParameterTypes;
+
+ if (m_kind == Kind::External || m_kind == Kind::CallCode || m_kind == Kind::DelegateCall)
+ for (auto& param: returnParameterTypes)
+ if (param->isDynamicallySized() && !param->dataStoredIn(DataLocation::Storage))
+ param = make_shared<InaccessibleDynamicType>();
+
+ return returnParameterTypes;
+}
+
TypePointers FunctionType::parameterTypes() const
{
if (!bound())
@@ -2772,18 +2784,9 @@ FunctionTypePointer FunctionType::asMemberFunction(bool _inLibrary, bool _bound)
kind = Kind::DelegateCall;
}
- TypePointers returnParameterTypes = m_returnParameterTypes;
- if (kind != Kind::Internal)
- {
- // Alter dynamic types to be non-accessible.
- for (auto& param: returnParameterTypes)
- if (param->isDynamicallySized())
- param = make_shared<InaccessibleDynamicType>();
- }
-
return make_shared<FunctionType>(
parameterTypes,
- returnParameterTypes,
+ m_returnParameterTypes,
m_parameterNames,
m_returnParameterNames,
kind,
diff --git a/libsolidity/ast/Types.h b/libsolidity/ast/Types.h
index c20a025f..c930dd24 100644
--- a/libsolidity/ast/Types.h
+++ b/libsolidity/ast/Types.h
@@ -973,6 +973,9 @@ public:
TypePointers parameterTypes() const;
std::vector<std::string> parameterNames() const;
TypePointers const& returnParameterTypes() const { return m_returnParameterTypes; }
+ /// @returns the list of return parameter types. All dynamically-sized types (this excludes
+ /// storage pointers) are replaced by InaccessibleDynamicType instances.
+ TypePointers returnParameterTypesWithoutDynamicTypes() const;
std::vector<std::string> const& returnParameterNames() const { return m_returnParameterNames; }
/// @returns the "self" parameter type for a bound function
TypePointer const& selfType() const;