From f94ff7b41c68807a51650b18a3e3e031136b542e Mon Sep 17 00:00:00 2001 From: chriseth Date: Fri, 26 Jun 2015 16:52:30 +0200 Subject: [PATCH] Fixed and simplified external type computation. --- libsolidity/AST.cpp | 4 +++- libsolidity/Types.cpp | 17 ++++++++++------- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/libsolidity/AST.cpp b/libsolidity/AST.cpp index 7333c024a..09af49c67 100644 --- a/libsolidity/AST.cpp +++ b/libsolidity/AST.cpp @@ -340,8 +340,10 @@ vector, FunctionTypePointer>> const& ContractDefinition::getIn { for (ASTPointer const& f: contract->getDefinedFunctions()) { + if (!f->isPartOfExternalInterface()) + continue; string functionSignature = f->externalSignature(); - if (f->isPartOfExternalInterface() && signaturesSeen.count(functionSignature) == 0) + if (signaturesSeen.count(functionSignature) == 0) { functionsSeen.insert(f->getName()); signaturesSeen.insert(functionSignature); diff --git a/libsolidity/Types.cpp b/libsolidity/Types.cpp index 01876b5a7..15c367421 100644 --- a/libsolidity/Types.cpp +++ b/libsolidity/Types.cpp @@ -827,15 +827,16 @@ TypePointer ArrayType::externalType() const { if (m_arrayKind != ArrayKind::Ordinary) return this->copyForLocation(DataLocation::Memory, true); - if (!m_baseType->externalType()) + TypePointer baseExt = m_baseType->externalType(); + if (!baseExt) return TypePointer(); if (m_baseType->getCategory() == Category::Array && m_baseType->isDynamicallySized()) return TypePointer(); if (isDynamicallySized()) - return std::make_shared(DataLocation::Memory, m_baseType->externalType()); + return std::make_shared(DataLocation::Memory, baseExt); else - return std::make_shared(DataLocation::Memory, m_baseType->externalType(), m_length); + return std::make_shared(DataLocation::Memory, baseExt, m_length); } TypePointer ArrayType::copyForLocation(DataLocation _location, bool _isPointer) const @@ -1268,15 +1269,17 @@ FunctionTypePointer FunctionType::externalFunctionType() const for (auto type: m_parameterTypes) { - if (!type->externalType()) + if (auto ext = type->externalType()) + paramTypes.push_back(ext); + else return FunctionTypePointer(); - paramTypes.push_back(type->externalType()); } for (auto type: m_returnParameterTypes) { - if (!type->externalType()) + if (auto ext = type->externalType()) + retParamTypes.push_back(ext); + else return FunctionTypePointer(); - retParamTypes.push_back(type->externalType()); } return make_shared(paramTypes, retParamTypes, m_parameterNames, m_returnParameterNames, m_location, m_arbitraryParameters); }