diff options
-rw-r--r-- | ArrayUtils.cpp | 8 | ||||
-rw-r--r-- | Compiler.cpp | 3 | ||||
-rw-r--r-- | CompilerContext.h | 2 | ||||
-rw-r--r-- | ExpressionCompiler.cpp | 7 |
4 files changed, 10 insertions, 10 deletions
diff --git a/ArrayUtils.cpp b/ArrayUtils.cpp index 448e4da2..f59385d9 100644 --- a/ArrayUtils.cpp +++ b/ArrayUtils.cpp @@ -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()) diff --git a/Compiler.cpp b/Compiler.cpp index 5e24aaaa..26147340 100644 --- a/Compiler.cpp +++ b/Compiler.cpp @@ -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; diff --git a/CompilerContext.h b/CompilerContext.h index 7bc29de1..dbf3dcd4 100644 --- a/CompilerContext.h +++ b/CompilerContext.h @@ -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. diff --git a/ExpressionCompiler.cpp b/ExpressionCompiler.cpp index 2e513b7f..a9f0ba3e 100644 --- a/ExpressionCompiler.cpp +++ b/ExpressionCompiler.cpp @@ -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()) |