mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Merge pull request #1975 from LianaHus/sol_EVMExceptions
"error jump" instead of STOP instraction in case of exception
This commit is contained in:
commit
408fd7ab59
@ -465,12 +465,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())
|
||||
|
@ -194,7 +194,6 @@ void Compiler::appendFunctionSelector(ContractDefinition const& _contract)
|
||||
}
|
||||
else
|
||||
m_context << eth::Instruction::STOP; // function not found
|
||||
|
||||
for (auto const& it: interfaceFunctions)
|
||||
{
|
||||
FunctionTypePointer const& functionType = it.second;
|
||||
|
@ -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);
|
||||
/// Returns 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.
|
||||
|
@ -1106,8 +1106,11 @@ 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.
|
||||
|
||||
//Propagate error condition (if CALL pushes 0 on stack).
|
||||
m_context << eth::Instruction::ISZERO;
|
||||
m_context.appendConditionalJumpTo(m_context.errorTag());
|
||||
|
||||
if (_functionType.valueSet())
|
||||
m_context << eth::Instruction::POP;
|
||||
if (_functionType.gasSet())
|
||||
|
@ -98,10 +98,7 @@ private:
|
||||
void appendHighBitsCleanup(IntegerType const& _typeOnStack);
|
||||
|
||||
/// Appends code to call a function of the given type with the given arguments.
|
||||
void appendExternalFunctionCall(
|
||||
FunctionType const& _functionType,
|
||||
std::vector<ASTPointer<Expression const>> const& _arguments
|
||||
);
|
||||
void appendExternalFunctionCall(FunctionType const& _functionType, std::vector<ASTPointer<Expression const>> const& _arguments);
|
||||
/// Appends code that evaluates the given arguments and moves the result to memory encoded as
|
||||
/// specified by the ABI. The memory offset is expected to be on the stack and is updated by
|
||||
/// this call. If @a _padToWordBoundaries is set to false, all values are concatenated without
|
||||
|
Loading…
Reference in New Issue
Block a user