aboutsummaryrefslogtreecommitdiffstats
path: root/libsolidity/codegen
diff options
context:
space:
mode:
authorAlex Beregszaszi <alex@rtfs.hu>2016-06-18 18:11:55 +0800
committerchriseth <c@ethdev.com>2016-09-06 03:28:18 +0800
commita34f2f1a316d6093c14045ee8423d913ac01421d (patch)
tree79a97492be7e5a436498dc3a0a6ffe2174c36ab4 /libsolidity/codegen
parente2b787cdd0717bf074cc03634d580f7713568792 (diff)
downloaddexon-solidity-a34f2f1a316d6093c14045ee8423d913ac01421d.tar.gz
dexon-solidity-a34f2f1a316d6093c14045ee8423d913ac01421d.tar.zst
dexon-solidity-a34f2f1a316d6093c14045ee8423d913ac01421d.zip
Support payable keyword for functions
Diffstat (limited to 'libsolidity/codegen')
-rw-r--r--libsolidity/codegen/ContractCompiler.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/libsolidity/codegen/ContractCompiler.cpp b/libsolidity/codegen/ContractCompiler.cpp
index 9d77ccdc..eba85103 100644
--- a/libsolidity/codegen/ContractCompiler.cpp
+++ b/libsolidity/codegen/ContractCompiler.cpp
@@ -243,6 +243,14 @@ void ContractCompiler::appendFunctionSelector(ContractDefinition const& _contrac
if (fallback)
{
eth::AssemblyItem returnTag = m_context.pushNewTag();
+
+ // Reject transaction if value is not accepted, but was received
+ if (!fallback->isPayable())
+ {
+ m_context << Instruction::CALLVALUE;
+ m_context.appendConditionalJumpTo(m_context.errorTag());
+ }
+
fallback->accept(*this);
m_context << returnTag;
appendReturnValuePacker(FunctionType(*fallback).returnParameterTypes(), _contract.isLibrary());
@@ -255,8 +263,17 @@ 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);
eth::AssemblyItem returnTag = m_context.pushNewTag();
+
+ // Reject transaction if value is not accepted, but was received
+ if (!functionType->isPayable())
+ {
+ m_context << Instruction::CALLVALUE;
+ m_context.appendConditionalJumpTo(m_context.errorTag());
+ }
+
m_context << CompilerUtils::dataStartOffset;
appendCalldataUnpacker(functionType->parameterTypes());
m_context.appendJumpTo(m_context.functionEntryLabel(functionType->declaration()));