Require and Assert.

This commit is contained in:
chriseth committed 2017-03-14 14:21:33 +01:00
1 parent 9aab3b8639
commit 47cd8964b8
7 files changed
+50 -28

No files matched your search

+6 -2
View File
@@ -879,14 +879,18 @@ bool ExpressionCompiler::visit(FunctionCall const& _functionCall)
break;
}
case Location::Assert:
case Location::Require:
{
arguments.front()->accept(*this);
utils().convertType(*arguments.front()->annotation().type, *function.parameterTypes().front(), false);
// jump if condition was met
m_context << Instruction::ISZERO << Instruction::ISZERO;
auto success = m_context.appendConditionalJump();
// condition was not met, flag an error
m_context << Instruction::INVALID;
if (function.location() == Location::Assert)
// condition was not met, flag an error
m_context << Instruction::INVALID;
else
m_context << u256(0) << u256(0) << Instruction::REVERT;
// the success branch
m_context << success;
break;