Spicy
Public Member Functions | List of all members
hilti::NodeBase Class Reference

#include <node.h>

Inheritance diagram for hilti::NodeBase:
hilti::trait::isNode hilti::Attribute hilti::AttributeSet hilti::ctor::Address hilti::ctor::Bool hilti::ctor::Bytes hilti::ctor::Coerced hilti::ctor::Default hilti::ctor::detail::IntegerBase< T, S > hilti::ctor::Enum hilti::ctor::Error hilti::ctor::Exception hilti::ctor::Interval hilti::ctor::Library hilti::ctor::List hilti::ctor::Map hilti::ctor::map::Element hilti::ctor::Network hilti::ctor::Null hilti::ctor::Optional hilti::ctor::Port hilti::ctor::Real hilti::ctor::RegExp hilti::ctor::Result hilti::ctor::Set hilti::ctor::Stream hilti::ctor::String hilti::ctor::StrongReference hilti::ctor::Struct hilti::ctor::struct_::Field hilti::ctor::Time hilti::ctor::Tuple hilti::ctor::Union hilti::ctor::ValueReference hilti::ctor::Vector hilti::ctor::WeakReference hilti::DeclarationBase hilti::expression::Assign hilti::expression::BuiltinFunction hilti::expression::Coerced hilti::expression::Ctor hilti::expression::Deferred hilti::expression::Grouping hilti::expression::Keyword hilti::expression::ListComprehension hilti::expression::LogicalAnd hilti::expression::LogicalNot hilti::expression::LogicalOr hilti::expression::Member hilti::expression::Move hilti::expression::PendingCoerced hilti::expression::ResolvedID hilti::expression::ResolvedOperatorBase hilti::expression::Ternary hilti::expression::Type_ hilti::expression::TypeInfo hilti::expression::TypeWrapped hilti::expression::UnresolvedID hilti::expression::UnresolvedOperator hilti::expression::Void hilti::Function hilti::ID hilti::Module hilti::node::None hilti::statement::Assert hilti::statement::Block hilti::statement::Break hilti::statement::Comment hilti::statement::Continue hilti::statement::Declaration hilti::statement::Expression hilti::statement::For hilti::statement::If hilti::statement::Return hilti::statement::SetLocation hilti::statement::Switch hilti::statement::switch_::Case hilti::statement::Throw hilti::statement::Try hilti::statement::try_::Catch hilti::statement::While hilti::statement::Yield hilti::type::enum_::Label hilti::type::function::Result hilti::type::tuple::Element hilti::TypeBase hilti::ctor::detail::IntegerBase< int64_t, type::SignedInteger > hilti::ctor::detail::IntegerBase< uint64_t, type::UnsignedInteger > spicy::ctor::Unit spicy::Hook spicy::statement::Confirm spicy::statement::Print spicy::statement::Reject spicy::statement::Stop spicy::type::bitfield::Bits spicy::type::unit::item::Field spicy::type::unit::item::Property spicy::type::unit::item::Sink spicy::type::unit::item::Switch spicy::type::unit::item::switch_::Case spicy::type::unit::item::UnitHook spicy::type::unit::item::UnresolvedField spicy::type::unit::item::Variable

Public Member Functions

 NodeBase (Meta meta)
 
 NodeBase (std::vector< Node > children, Meta meta)
 
template<typename T >
const T & child (int i) const
 
template<typename T >
void assertChildIsA (int i)
 
template<typename T >
auto children (int begin, int end) const
 
auto childRefs (int begin, int end)
 
template<typename T >
hilti::node::Set< T > childrenOfType () const
 
template<typename T >
std::vector< NodeRefchildRefsOfType () const
 
void addChild (Node n)
 
const auto & children () const
 
auto & children ()
 
auto & meta () const
 
void setMeta (Meta m)
 
bool pruneWalk () const
 

Detailed Description

Common base class for classes implementing the Node interface. The base implements a number of the interface methods with standard versions shared across all nodes.

Constructor & Destructor Documentation

◆ NodeBase() [1/2]

hilti::NodeBase::NodeBase ( Meta  meta)
inline

Constructor.

Parameters
metameta information to associate with the node

◆ NodeBase() [2/2]

hilti::NodeBase::NodeBase ( std::vector< Node children,
Meta  meta 
)
inline

Constructor registering child nodes.

Parameters
childrenchildren of this node
metameta information to associate with the node

Member Function Documentation

◆ addChild()

void hilti::NodeBase::addChild ( Node  n)
inline

Adds a child node. It will be appended to the end of the current list node of children.

◆ assertChildIsA()

template<typename T >
void hilti::NodeBase::assertChildIsA ( int  i)
inline

Aborts execution if a given child is not an expected type T.

Template Parameters
Ttype that the child node is assumed to have
Parameters
iindex of the child, in the order they were passed into the constructor and/or added

◆ child()

template<typename T >
const T& hilti::NodeBase::child ( int  i) const
inline

Returns a child.

Template Parameters
Ttype that the child nodes are assumed to (and must) have
Parameters
iindex of the child, in the order they were passed into the constructor and/or added
Returns
child casted to type T

◆ childRefs()

auto hilti::NodeBase::childRefs ( int  begin,
int  end 
)
inline

Returns a references to a subrange of children. The indices correspond to the order children were passed into the constructor and/or added.

Parameters
beginindex of first child to include; a negative index counts Python-style from end of list
endindex of one beyond last child to include; a negative index counts Python-style from end of list
Returns
vector containing child references from start to end

◆ childRefsOfType()

template<typename T >
std::vector< NodeRef > hilti::NodeBase::childRefsOfType ( ) const

Returns a vector of references to a subset of children selected by their type.

Template Parameters
Ttype of children to return
Returns
set of all children that have type T

◆ children() [1/3]

template<typename T >
auto hilti::NodeBase::children ( int  begin,
int  end 
) const
inline

Returns a subrange of children. The indices correspond to the order children were passed into the constructor and/or added.

Template Parameters
Ttype that the child nodes are assumed to (and must) have
Parameters
beginindex of first child to include; a negative index counts Python-style from end of list
endindex of one beyond last child to include; a negative index counts Python-style from end of list
Returns
range containing children from start to end

◆ children() [2/3]

const auto& hilti::NodeBase::children ( ) const
inline

Implements the Node interface.

◆ children() [3/3]

auto& hilti::NodeBase::children ( )
inline

Implements the Node interface.

◆ childrenOfType()

template<typename T >
hilti::node::Set< T > hilti::NodeBase::childrenOfType ( ) const

Returns a subset of children selected by their type.

Template Parameters
Ttype of children to return
Returns
set of all children that have type T

◆ meta()

auto& hilti::NodeBase::meta ( ) const
inline

Implements the Node interface.

◆ pruneWalk()

bool hilti::NodeBase::pruneWalk ( ) const
inline

Implements the Node interface.

◆ setMeta()

void hilti::NodeBase::setMeta ( Meta  m)
inline

Implements the Node interface.


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