Spicy
Public Member Functions | Static Public Member Functions | List of all members
hilti::statement::Assert Class Reference

#include <assert.h>

Inheritance diagram for hilti::statement::Assert:
hilti::NodeBase hilti::trait::isStatement hilti::trait::isNode hilti::trait::isNode

Public Member Functions

 Assert (::hilti::Expression expr, std::optional<::hilti::Expression > msg, Meta m=Meta())
 
 Assert (assert::Exception, ::hilti::Expression expr, std::optional< Type > excpt, std::optional<::hilti::Expression > msg, Meta m=Meta())
 
bool expectsException () const
 
const auto & expression () const
 
auto exception () const
 
auto message () const
 
bool operator== (const Assert &other) const
 
auto isEqual (const Statement &other) const
 
auto properties () const
 
- Public Member Functions inherited from hilti::NodeBase
 NodeBase (Meta meta)
 
 NodeBase (std::vector< Node > childs, Meta meta)
 
template<typename T >
const T & child (int i) const
 
template<typename T >
void assertChildIsA (int i)
 
template<typename T >
std::vector< T > childs (int begin, int end) const
 
template<typename T >
std::vector< T > childsOfType () const
 
template<typename T >
auto nodesOfType () const
 
template<typename T >
auto nodesOfType ()
 
void addChild (Node n)
 
auto & childs () const
 
auto & childs ()
 
auto & meta () const
 
void setMeta (Meta m)
 
const NodeReforiginalNode () const
 
void setOriginalNode (const NodeRef &n)
 
void clearCache ()
 

Static Public Member Functions

static Statement setCondition (const Assert &e, const hilti::Expression &c)
 

Detailed Description

AST node for an assert statement.

Constructor & Destructor Documentation

◆ Assert() [1/2]

hilti::statement::Assert::Assert ( ::hilti::Expression  expr,
std::optional<::hilti::Expression >  msg,
Meta  m = Meta() 
)
inline

Creates an assert statement that expects an exception to evaluate to true at runtime.

Parameters
eexpression to evaluate at runtime
msgmessage to report an runtime if assertions fails
mmeta informatio for AST node

◆ Assert() [2/2]

hilti::statement::Assert::Assert ( assert::Exception  ,
::hilti::Expression  expr,
std::optional< Type >  excpt,
std::optional<::hilti::Expression >  msg,
Meta  m = Meta() 
)
inline

Creates an assert statement that expects an exception to occur when the expression is evaluated.

Parameters
assert::Exceptiontag to select this constructor
eexpression to evaluate at runtime
typeexception type that's expected to be thrown when e is evaluated; unset of any exception
msgmessage to report an runtime if assertions fails
mmeta informatio for AST node

Member Function Documentation

◆ isEqual()

auto hilti::statement::Assert::isEqual ( const Statement &  other) const
inline

Implements the Statement interface.

◆ properties()

auto hilti::statement::Assert::properties ( ) const
inline

Implements the Node interface.

◆ setCondition()

static Statement hilti::statement::Assert::setCondition ( const Assert e,
const hilti::Expression &  c 
)
inlinestatic

Returns a new assert statement with the expression replaced.

Parameters
eoriginal statement
cnew expresssion
Returns
new statement that's equal to original one but with the expression replaced

The documentation for this class was generated from the following file: