diff options
author | Christian <c@ethdev.com> | 2015-01-08 05:54:56 +0800 |
---|---|---|
committer | Christian <c@ethdev.com> | 2015-01-10 01:31:36 +0800 |
commit | c5c893319285993dd9a1c6a790537e7acc35e5d0 (patch) | |
tree | feee7124a0982ca8e44d142caf6774969305829b /Types.cpp | |
parent | 501ad14ed1a6b1c40e0b0437683bae6246a6eeeb (diff) | |
download | dexon-solidity-c5c893319285993dd9a1c6a790537e7acc35e5d0.tar.gz dexon-solidity-c5c893319285993dd9a1c6a790537e7acc35e5d0.tar.zst dexon-solidity-c5c893319285993dd9a1c6a790537e7acc35e5d0.zip |
Contracts are Addresses.
Diffstat (limited to 'Types.cpp')
-rw-r--r-- | Types.cpp | 15 |
1 files changed, 11 insertions, 4 deletions
@@ -424,15 +424,20 @@ TypePointer BoolType::binaryOperatorResult(Token::Value _operator, TypePointer c return TypePointer(); } -bool ContractType::isExplicitlyConvertibleTo(Type const& _convertTo) const +bool ContractType::isImplicitlyConvertibleTo(Type const& _convertTo) const { - if (isImplicitlyConvertibleTo(_convertTo)) + if (*this == _convertTo) return true; if (_convertTo.getCategory() == Category::INTEGER) return dynamic_cast<IntegerType const&>(_convertTo).isAddress(); return false; } +bool ContractType::isExplicitlyConvertibleTo(Type const& _convertTo) const +{ + return isImplicitlyConvertibleTo(_convertTo) || _convertTo.getCategory() == Category::INTEGER; +} + bool ContractType::operator==(Type const& _other) const { if (_other.getCategory() != getCategory()) @@ -459,7 +464,9 @@ MemberList const& ContractType::getMembers() const // We need to lazy-initialize it because of recursive references. if (!m_members) { - map<string, shared_ptr<Type const>> members; + // 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()] = make_shared<FunctionType>(*it.second, false); m_members.reset(new MemberList(members)); @@ -487,7 +494,7 @@ u256 ContractType::getFunctionIdentifier(string const& _functionName) const if (it->second->getName() == _functionName) return FixedHash<4>::Arith(it->first); - BOOST_THROW_EXCEPTION(InternalCompilerError() << errinfo_comment("Index of non-existing contract function requested.")); + return Invalid256; } bool StructType::operator==(Type const& _other) const |