aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLiana Husikyan <liana@ethdev.com>2015-05-15 18:23:13 +0800
committerLiana Husikyan <liana@ethdev.com>2015-06-01 19:06:12 +0800
commit2f50eb0028c7f7525ff35a60db7a18e09eee42e6 (patch)
tree67722e7b7f2960db1a7e8716a0eb0ab6fe13b88f
parentf7e3568c6202b940394097f147e0c4e6ffe7fe9c (diff)
downloaddexon-solidity-2f50eb0028c7f7525ff35a60db7a18e09eee42e6.tar
dexon-solidity-2f50eb0028c7f7525ff35a60db7a18e09eee42e6.tar.gz
dexon-solidity-2f50eb0028c7f7525ff35a60db7a18e09eee42e6.tar.bz2
dexon-solidity-2f50eb0028c7f7525ff35a60db7a18e09eee42e6.tar.lz
dexon-solidity-2f50eb0028c7f7525ff35a60db7a18e09eee42e6.tar.xz
dexon-solidity-2f50eb0028c7f7525ff35a60db7a18e09eee42e6.tar.zst
dexon-solidity-2f50eb0028c7f7525ff35a60db7a18e09eee42e6.zip
added error jump instead of STOP instraction in case of exception
-rw-r--r--ArrayUtils.cpp8
-rw-r--r--Compiler.cpp3
-rw-r--r--CompilerContext.h2
-rw-r--r--ExpressionCompiler.cpp7
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())