mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
added error jump instead of STOP instraction in case of exception
This commit is contained in:
parent
f7e3568c62
commit
2f50eb0028
@ -455,12 +455,10 @@ void ArrayUtils::accessIndex(ArrayType const& _arrayType) const
|
|||||||
m_context << eth::Instruction::DUP2 << load;
|
m_context << eth::Instruction::DUP2 << load;
|
||||||
// stack: <base_ref> <index> <length>
|
// stack: <base_ref> <index> <length>
|
||||||
// check out-of-bounds access
|
// check out-of-bounds access
|
||||||
m_context << eth::Instruction::DUP2 << eth::Instruction::LT;
|
m_context << eth::Instruction::DUP2 << eth::Instruction::LT << eth::Instruction::ISZERO;
|
||||||
eth::AssemblyItem legalAccess = m_context.appendConditionalJump();
|
// out-of-bounds access throws exception
|
||||||
// out-of-bounds access throws exception (just STOP for now)
|
m_context.appendConditionalJumpTo(m_context.errorTag());
|
||||||
m_context << eth::Instruction::STOP;
|
|
||||||
|
|
||||||
m_context << legalAccess;
|
|
||||||
// stack: <base_ref> <index>
|
// stack: <base_ref> <index>
|
||||||
m_context << eth::Instruction::SWAP1;
|
m_context << eth::Instruction::SWAP1;
|
||||||
if (_arrayType.isDynamicallySized())
|
if (_arrayType.isDynamicallySized())
|
||||||
|
@ -193,8 +193,7 @@ void Compiler::appendFunctionSelector(ContractDefinition const& _contract)
|
|||||||
appendReturnValuePacker(FunctionType(*fallback).getReturnParameterTypes());
|
appendReturnValuePacker(FunctionType(*fallback).getReturnParameterTypes());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
m_context << eth::Instruction::STOP; // function not found
|
m_context.appendConditionalJumpTo(m_context.errorTag()); // function not found
|
||||||
|
|
||||||
for (auto const& it: interfaceFunctions)
|
for (auto const& it: interfaceFunctions)
|
||||||
{
|
{
|
||||||
FunctionTypePointer const& functionType = it.second;
|
FunctionTypePointer const& functionType = it.second;
|
||||||
|
@ -98,6 +98,8 @@ public:
|
|||||||
eth::AssemblyItem appendJumpToNew() { return m_asm.appendJump().tag(); }
|
eth::AssemblyItem appendJumpToNew() { return m_asm.appendJump().tag(); }
|
||||||
/// Appends a JUMP to a tag already on the stack
|
/// Appends a JUMP to a tag already on the stack
|
||||||
CompilerContext& appendJump(eth::AssemblyItem::JumpType _jumpType = eth::AssemblyItem::JumpType::Ordinary);
|
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
|
/// Appends a JUMP to a specific tag
|
||||||
CompilerContext& appendJumpTo(eth::AssemblyItem const& _tag) { m_asm.appendJump(_tag); return *this; }
|
CompilerContext& appendJumpTo(eth::AssemblyItem const& _tag) { m_asm.appendJump(_tag); return *this; }
|
||||||
/// Appends pushing of a new tag and @returns the new tag.
|
/// Appends pushing of a new tag and @returns the new tag.
|
||||||
|
@ -1102,9 +1102,10 @@ void ExpressionCompiler::appendExternalFunctionCall(
|
|||||||
)
|
)
|
||||||
m_context << eth::Instruction::CALLCODE;
|
m_context << eth::Instruction::CALLCODE;
|
||||||
else
|
else
|
||||||
m_context << eth::Instruction::CALL;
|
{
|
||||||
auto tag = m_context.appendConditionalJump();
|
m_context << eth::Instruction::CALL << eth::Instruction::ISZERO;
|
||||||
m_context << eth::Instruction::STOP << tag; // STOP if CALL leaves 0.
|
auto tag = m_context.appendConditionalJumpTo(m_context.errorTag());// if CALL leaves 0.
|
||||||
|
}
|
||||||
if (_functionType.valueSet())
|
if (_functionType.valueSet())
|
||||||
m_context << eth::Instruction::POP;
|
m_context << eth::Instruction::POP;
|
||||||
if (_functionType.gasSet())
|
if (_functionType.gasSet())
|
||||||
|
Loading…
Reference in New Issue
Block a user