diff options
author | Valentin Wüstholz <wuestholz@gmail.com> | 2017-01-23 03:49:12 +0800 |
---|---|---|
committer | chriseth <c@ethdev.com> | 2017-01-26 23:39:07 +0800 |
commit | 9bcbd93ac59a19320fd56e27c58a6283f2450666 (patch) | |
tree | cf102bce6745c1e771dcacbd83a6e850a09c0054 /libsolidity/codegen/ContractCompiler.cpp | |
parent | 102fd7ee5daeb7d7a7bb1254cf0ce71a23ad1220 (diff) | |
download | dexon-solidity-9bcbd93ac59a19320fd56e27c58a6283f2450666.tar.gz dexon-solidity-9bcbd93ac59a19320fd56e27c58a6283f2450666.tar.zst dexon-solidity-9bcbd93ac59a19320fd56e27c58a6283f2450666.zip |
Change translation of implicit throws (issue #1589).
This adds a new invalid instruction that is used for encoding
implicit throws that are emitted by the compiler. This makes it
possible to distinguish such runtime errors from user-provided,
explicit throws.
Diffstat (limited to 'libsolidity/codegen/ContractCompiler.cpp')
-rw-r--r-- | libsolidity/codegen/ContractCompiler.cpp | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/libsolidity/codegen/ContractCompiler.cpp b/libsolidity/codegen/ContractCompiler.cpp index 9dc1fb37..56d03a05 100644 --- a/libsolidity/codegen/ContractCompiler.cpp +++ b/libsolidity/codegen/ContractCompiler.cpp @@ -106,7 +106,7 @@ void ContractCompiler::appendCallValueCheck() { // Throw if function is not payable but call contained ether. m_context << Instruction::CALLVALUE; - m_context.appendConditionalJumpTo(m_context.errorTag()); + m_context.appendConditionalInvalid(); } void ContractCompiler::appendInitAndConstructorCode(ContractDefinition const& _contract) @@ -271,7 +271,7 @@ void ContractCompiler::appendFunctionSelector(ContractDefinition const& _contrac appendReturnValuePacker(FunctionType(*fallback).returnParameterTypes(), _contract.isLibrary()); } else - m_context.appendJumpTo(m_context.errorTag()); + m_context.appendInvalid(); for (auto const& it: interfaceFunctions) { @@ -918,7 +918,9 @@ eth::AssemblyPointer ContractCompiler::cloneRuntime() a << Instruction::DELEGATECALL; //Propagate error condition (if DELEGATECALL pushes 0 on stack). a << Instruction::ISZERO; - a.appendJumpI(a.errorTag()); + eth::AssemblyItem falseTag = a.appendJumpI(); + eth::AssemblyItem endTag = a.appendJump().tag(); + a << falseTag << Instruction::INVALID << endTag; //@todo adjust for larger return values, make this dynamic. a << u256(0x20) << u256(0) << Instruction::RETURN; return make_shared<eth::Assembly>(a); |