added error jump instead of STOP instraction in case of exception

This commit is contained in:
Liana Husikyan 2015-05-15 12:23:13 +02:00
parent f7e3568c62
commit 2f50eb0028
4 changed files with 10 additions and 10 deletions

View File

@ -455,12 +455,10 @@ void ArrayUtils::accessIndex(ArrayType const& _arrayType) const
m_context << eth::Instruction::DUP2 << load;
// stack: <base_ref> <index> <length>
// check out-of-bounds access
m_context << eth::Instruction::DUP2 << eth::Instruction::LT;
eth::AssemblyItem legalAccess = m_context.appendConditionalJump();
// out-of-bounds access throws exception (just STOP for now)
m_context << eth::Instruction::STOP;
m_context << eth::Instruction::DUP2 << eth::Instruction::LT << eth::Instruction::ISZERO;
// out-of-bounds access throws exception
m_context.appendConditionalJumpTo(m_context.errorTag());
m_context << legalAccess;
// stack: <base_ref> <index>
m_context << eth::Instruction::SWAP1;
if (_arrayType.isDynamicallySized())

View File

@ -193,8 +193,7 @@ void Compiler::appendFunctionSelector(ContractDefinition const& _contract)
appendReturnValuePacker(FunctionType(*fallback).getReturnParameterTypes());
}
else
m_context << eth::Instruction::STOP; // function not found
m_context.appendConditionalJumpTo(m_context.errorTag()); // function not found
for (auto const& it: interfaceFunctions)
{
FunctionTypePointer const& functionType = it.second;

View File

@ -98,6 +98,8 @@ public:
eth::AssemblyItem appendJumpToNew() { return m_asm.appendJump().tag(); }
/// Appends a JUMP to a tag already on the stack
CompilerContext& appendJump(eth::AssemblyItem::JumpType _jumpType = eth::AssemblyItem::JumpType::Ordinary);
/// Appends a JUMP to an "ErrorTag"
eth::AssemblyItem errorTag() { return m_asm.errorTag(); }
/// Appends a JUMP to a specific tag
CompilerContext& appendJumpTo(eth::AssemblyItem const& _tag) { m_asm.appendJump(_tag); return *this; }
/// Appends pushing of a new tag and @returns the new tag.

View File

@ -1102,9 +1102,10 @@ void ExpressionCompiler::appendExternalFunctionCall(
)
m_context << eth::Instruction::CALLCODE;
else
m_context << eth::Instruction::CALL;
auto tag = m_context.appendConditionalJump();
m_context << eth::Instruction::STOP << tag; // STOP if CALL leaves 0.
{
m_context << eth::Instruction::CALL << eth::Instruction::ISZERO;
auto tag = m_context.appendConditionalJumpTo(m_context.errorTag());// if CALL leaves 0.
}
if (_functionType.valueSet())
m_context << eth::Instruction::POP;
if (_functionType.gasSet())