aboutsummaryrefslogtreecommitdiffstats
path: root/Types.cpp
diff options
context:
space:
mode:
authorChristian <c@ethdev.com>2015-01-27 21:32:59 +0800
committerChristian <c@ethdev.com>2015-01-29 07:29:43 +0800
commitae5a6a235c9d0996a712903e0cfd0560b326bbad (patch)
tree51e9e64e0a4f59172d4de9345e15100d3fd96268 /Types.cpp
parentb5a786dda19e54fa587b1b693e7a139818d65b9e (diff)
downloaddexon-solidity-ae5a6a235c9d0996a712903e0cfd0560b326bbad.tar.gz
dexon-solidity-ae5a6a235c9d0996a712903e0cfd0560b326bbad.tar.zst
dexon-solidity-ae5a6a235c9d0996a712903e0cfd0560b326bbad.zip
Super keyword.
Diffstat (limited to 'Types.cpp')
-rw-r--r--Types.cpp20
1 files changed, 15 insertions, 5 deletions
diff --git a/Types.cpp b/Types.cpp
index fcb10d4b..3d6c4e96 100644
--- a/Types.cpp
+++ b/Types.cpp
@@ -450,7 +450,9 @@ bool ContractType::isImplicitlyConvertibleTo(Type const& _convertTo) const
if (_convertTo.getCategory() == Category::CONTRACT)
{
auto const& bases = getContractDefinition().getLinearizedBaseContracts();
- return find(bases.begin(), bases.end(),
+ if (m_super && bases.size() <= 1)
+ return false;
+ return find(m_super ? ++bases.begin() : bases.begin(), bases.end(),
&dynamic_cast<ContractType const&>(_convertTo).getContractDefinition()) != bases.end();
}
return false;
@@ -472,12 +474,12 @@ bool ContractType::operator==(Type const& _other) const
if (_other.getCategory() != getCategory())
return false;
ContractType const& other = dynamic_cast<ContractType const&>(_other);
- return other.m_contract == m_contract;
+ return other.m_contract == m_contract && other.m_super == m_super;
}
string ContractType::toString() const
{
- return "contract " + m_contract.getName();
+ return "contract " + string(m_super ? "super " : "") + m_contract.getName();
}
MemberList const& ContractType::getMembers() const
@@ -488,8 +490,16 @@ MemberList const& ContractType::getMembers() const
// All address members and all interface functions
map<string, shared_ptr<Type const>> members(IntegerType::AddressMemberList.begin(),
IntegerType::AddressMemberList.end());
- for (auto const& it: m_contract.getInterfaceFunctions())
- members[it.second.getName()] = it.second.getFunctionTypeShared();
+ if (m_super)
+ {
+ for (ContractDefinition const* base: m_contract.getLinearizedBaseContracts())
+ for (ASTPointer<FunctionDefinition> const& function: base->getDefinedFunctions())
+ if (!function->isConstructor())
+ members.insert(make_pair(function->getName(), make_shared<FunctionType>(*function, true)));
+ }
+ else
+ for (auto const& it: m_contract.getInterfaceFunctions())
+ members[it.second.getName()] = it.second.getFunctionTypeShared();
m_members.reset(new MemberList(members));
}
return *m_members;