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 /ExpressionCompiler.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 'ExpressionCompiler.cpp')
-rw-r--r-- | ExpressionCompiler.cpp | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/ExpressionCompiler.cpp b/ExpressionCompiler.cpp index 33c10aa3..e882c198 100644 --- a/ExpressionCompiler.cpp +++ b/ExpressionCompiler.cpp @@ -345,6 +345,18 @@ void ExpressionCompiler::endVisit(MemberAccess const& _memberAccess) ASTString const& member = _memberAccess.getMemberName(); switch (_memberAccess.getExpression().getType()->getCategory()) { + case Type::Category::CONTRACT: + { + ContractType const& type = dynamic_cast<ContractType const&>(*_memberAccess.getExpression().getType()); + u256 identifier = type.getFunctionIdentifier(member); + if (identifier != Invalid256) + { + appendTypeConversion(type, IntegerType(0, IntegerType::Modifier::ADDRESS), true); + m_context << identifier; + break; + } + // fall-through to "integer" otherwise (address) + } case Type::Category::INTEGER: if (member == "balance") { @@ -358,14 +370,6 @@ void ExpressionCompiler::endVisit(MemberAccess const& _memberAccess) else BOOST_THROW_EXCEPTION(InternalCompilerError() << errinfo_comment("Invalid member access to integer.")); break; - case Type::Category::CONTRACT: - { - appendTypeConversion(*_memberAccess.getExpression().getType(), - IntegerType(0, IntegerType::Modifier::ADDRESS), true); - ContractType const& type = dynamic_cast<ContractType const&>(*_memberAccess.getExpression().getType()); - m_context << type.getFunctionIdentifier(member); - break; - } case Type::Category::MAGIC: // we can ignore the kind of magic and only look at the name of the member if (member == "coinbase") |