Browse Source

Fixed and simplified external type computation.

cl-refactor
chriseth 9 years ago
parent
commit
f94ff7b41c
  1. 4
      libsolidity/AST.cpp
  2. 17
      libsolidity/Types.cpp

4
libsolidity/AST.cpp

@ -340,8 +340,10 @@ vector<pair<FixedHash<4>, FunctionTypePointer>> const& ContractDefinition::getIn
{
for (ASTPointer<FunctionDefinition> 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);

17
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<ArrayType>(DataLocation::Memory, m_baseType->externalType());
return std::make_shared<ArrayType>(DataLocation::Memory, baseExt);
else
return std::make_shared<ArrayType>(DataLocation::Memory, m_baseType->externalType(), m_length);
return std::make_shared<ArrayType>(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<FunctionType>(paramTypes, retParamTypes, m_parameterNames, m_returnParameterNames, m_location, m_arbitraryParameters);
}

Loading…
Cancel
Save