Spicy
Public Member Functions | Static Public Member Functions | Friends | List of all members
hilti::statement::switch_::Case Class Reference

#include <switch.h>

Inheritance diagram for hilti::statement::switch_::Case:
hilti::NodeBase hilti::trait::isNode

Public Member Functions

 Case (hilti::Expression expr, Statement body, Meta m=Meta())
 
 Case (std::vector< hilti::Expression > exprs, Statement body, Meta m=Meta())
 
 Case (Default, Statement body, Meta m=Meta())
 
auto expressions () const
 
auto preprocessedExpressions () const
 
const auto & body () const
 
bool isDefault () const
 
auto & _bodyNode ()
 
auto properties () const
 
bool operator== (const Case &other) 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 Case setExpressions (Case c, std::vector< hilti::Expression > exprs)
 

Friends

class hilti::statement::Switch
 

Detailed Description

AST node for a switch case type.

Note that internally, we store the expressions in a preprocessed matter: E turns into <id> == E, where ID is selected to match the code generator's output. Doing this allows coercion for the comparision to proceed normally. The preprocessing happens at the time the Case gets added to a Switch statement, and the new versions are stored separately from the original expressions.

Member Function Documentation

◆ _bodyNode()

auto& hilti::statement::switch_::Case::_bodyNode ( )
inline

Internal method for use by builder API only.

◆ properties()

auto hilti::statement::switch_::Case::properties ( ) const
inline

Implements the Node interface.

◆ setExpressions()

static Case hilti::statement::switch_::Case::setExpressions ( Case  c,
std::vector< hilti::Expression >  exprs 
)
inlinestatic

Replaces a case's expresssions.

Parameters
ccase to replace expressions in
exprsnew expressions
Returns
new case that is a duplicate of c but has its expressions replaced with expr

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