diff options
author | chriseth <chris@ethereum.org> | 2016-09-06 18:25:19 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-09-06 18:25:19 +0800 |
commit | f687635e4743a1e12d01fb082a4f8a76a759ab48 (patch) | |
tree | 7e3b917cfcc5ebf44c6770c6d742da0fa9277a12 /libsolidity/codegen/ContractCompiler.cpp | |
parent | 171c74843bb231c4663ec0fe7f4252ac03266f53 (diff) | |
parent | dff9633084ebc241d8268c5dbd35a0c5307fd6fc (diff) | |
download | dexon-solidity-f687635e4743a1e12d01fb082a4f8a76a759ab48.tar.gz dexon-solidity-f687635e4743a1e12d01fb082a4f8a76a759ab48.tar.zst dexon-solidity-f687635e4743a1e12d01fb082a4f8a76a759ab48.zip |
Merge pull request #665 from axic/feature/accept-ether
BREAKING: Add payable modifier
Diffstat (limited to 'libsolidity/codegen/ContractCompiler.cpp')
-rw-r--r-- | libsolidity/codegen/ContractCompiler.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/libsolidity/codegen/ContractCompiler.cpp b/libsolidity/codegen/ContractCompiler.cpp index 9d77ccdc..33571bc0 100644 --- a/libsolidity/codegen/ContractCompiler.cpp +++ b/libsolidity/codegen/ContractCompiler.cpp @@ -242,6 +242,12 @@ void ContractCompiler::appendFunctionSelector(ContractDefinition const& _contrac m_context << notFound; if (fallback) { + if (!fallback->isPayable()) + { + // Throw if function is not payable but call contained ether. + m_context << Instruction::CALLVALUE; + m_context.appendConditionalJumpTo(m_context.errorTag()); + } eth::AssemblyItem returnTag = m_context.pushNewTag(); fallback->accept(*this); m_context << returnTag; @@ -255,7 +261,15 @@ void ContractCompiler::appendFunctionSelector(ContractDefinition const& _contrac FunctionTypePointer const& functionType = it.second; solAssert(functionType->hasDeclaration(), ""); CompilerContext::LocationSetter locationSetter(m_context, functionType->declaration()); + m_context << callDataUnpackerEntryPoints.at(it.first); + if (!functionType->isPayable()) + { + // Throw if function is not payable but call contained ether. + m_context << Instruction::CALLVALUE; + m_context.appendConditionalJumpTo(m_context.errorTag()); + } + eth::AssemblyItem returnTag = m_context.pushNewTag(); m_context << CompilerUtils::dataStartOffset; appendCalldataUnpacker(functionType->parameterTypes()); |