diff options
Diffstat (limited to 'libsolidity')
-rw-r--r-- | libsolidity/analysis/GlobalContext.cpp | 4 | ||||
-rw-r--r-- | libsolidity/ast/Types.h | 7 | ||||
-rw-r--r-- | libsolidity/codegen/ExpressionCompiler.cpp | 8 |
3 files changed, 15 insertions, 4 deletions
diff --git a/libsolidity/analysis/GlobalContext.cpp b/libsolidity/analysis/GlobalContext.cpp index e46868be..cc418c5e 100644 --- a/libsolidity/analysis/GlobalContext.cpp +++ b/libsolidity/analysis/GlobalContext.cpp @@ -65,7 +65,9 @@ m_magicVariables(vector<shared_ptr<MagicVariableDeclaration const>>{make_shared< make_shared<MagicVariableDeclaration>("ecrecover", make_shared<FunctionType>(strings{"bytes32", "uint8", "bytes32", "bytes32"}, strings{"address"}, FunctionType::Location::ECRecover)), make_shared<MagicVariableDeclaration>("ripemd160", - make_shared<FunctionType>(strings(), strings{"bytes20"}, FunctionType::Location::RIPEMD160, true))}) + make_shared<FunctionType>(strings(), strings{"bytes20"}, FunctionType::Location::RIPEMD160, true)), + make_shared<MagicVariableDeclaration>("assert", + make_shared<FunctionType>(strings{"bool"}, strings{}, FunctionType::Location::Assert))}) { } diff --git a/libsolidity/ast/Types.h b/libsolidity/ast/Types.h index e280b32c..83d840e0 100644 --- a/libsolidity/ast/Types.h +++ b/libsolidity/ast/Types.h @@ -819,8 +819,8 @@ public: { Internal, ///< stack-call using plain JUMP External, ///< external call using CALL - CallCode, ///< extercnal call using CALLCODE, i.e. not exchanging the storage - DelegateCall, ///< extercnal call using DELEGATECALL, i.e. not exchanging the storage + CallCode, ///< external call using CALLCODE, i.e. not exchanging the storage + DelegateCall, ///< external call using DELEGATECALL, i.e. not exchanging the storage Bare, ///< CALL without function hash BareCallCode, ///< CALLCODE without function hash BareDelegateCall, ///< DELEGATECALL without function hash @@ -844,7 +844,8 @@ public: MulMod, ///< MULMOD ArrayPush, ///< .push() to a dynamically sized array in storage ByteArrayPush, ///< .push() to a dynamically sized byte array in storage - ObjectCreation ///< array creation using new + ObjectCreation, ///< array creation using new + Assert ///< assert() }; virtual Category category() const override { return Category::Function; } diff --git a/libsolidity/codegen/ExpressionCompiler.cpp b/libsolidity/codegen/ExpressionCompiler.cpp index d74d9dd3..a99e3d40 100644 --- a/libsolidity/codegen/ExpressionCompiler.cpp +++ b/libsolidity/codegen/ExpressionCompiler.cpp @@ -863,6 +863,14 @@ bool ExpressionCompiler::visit(FunctionCall const& _functionCall) m_context << Instruction::POP; break; } + case Location::Assert: + { + arguments.front()->accept(*this); + utils().convertType(*arguments.front()->annotation().type, *function.parameterTypes().front(), true); + m_context << Instruction::ISZERO; + m_context.appendConditionalJumpTo(m_context.errorTag()); + break; + } default: BOOST_THROW_EXCEPTION(InternalCompilerError() << errinfo_comment("Invalid function type.")); } |