diff options
author | Christian <c@ethdev.com> | 2015-01-27 21:32:59 +0800 |
---|---|---|
committer | Christian <c@ethdev.com> | 2015-01-29 07:29:43 +0800 |
commit | ae5a6a235c9d0996a712903e0cfd0560b326bbad (patch) | |
tree | 51e9e64e0a4f59172d4de9345e15100d3fd96268 /Types.cpp | |
parent | b5a786dda19e54fa587b1b693e7a139818d65b9e (diff) | |
download | dexon-solidity-ae5a6a235c9d0996a712903e0cfd0560b326bbad.tar.gz dexon-solidity-ae5a6a235c9d0996a712903e0cfd0560b326bbad.tar.zst dexon-solidity-ae5a6a235c9d0996a712903e0cfd0560b326bbad.zip |
Super keyword.
Diffstat (limited to 'Types.cpp')
-rw-r--r-- | Types.cpp | 20 |
1 files changed, 15 insertions, 5 deletions
@@ -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; |