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.
This commit is contained in:
Valentin Wüstholz
2017-01-26 16:39:07 +01:00
committed by chriseth
parent 102fd7ee5d
commit 9bcbd93ac5
10 changed files with 49 additions and 17 deletions
+5 -3
View File
@@ -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);