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::List hilti::ctor::Map 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::Time hilti::ctor::Tuple hilti::ctor::Union hilti::ctor::ValueReference hilti::ctor::Vector hilti::ctor::WeakReference hilti::declaration::Constant hilti::declaration::Expression hilti::declaration::Forward hilti::declaration::Function hilti::declaration::GlobalVariable hilti::declaration::ImportedModule hilti::declaration::LocalVariable hilti::declaration::Module hilti::declaration::Parameter hilti::declaration::Property hilti::declaration::Type 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::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::struct_::Field hilti::type::union_::Field hilti::TypeBase hilti::ctor::detail::IntegerBase< int64_t, type::SignedInteger > hilti::ctor::detail::IntegerBase< uint64_t, type::UnsignedInteger > spicy::declaration::UnitHook spicy::statement::Print 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 > 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 ()
 

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 childs,
Meta  meta 
)
inline

Constructor registering child nodes.

Parameters
childschildren 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

◆ childs() [1/3]

template<typename T >
std::vector<T> hilti::NodeBase::childs ( 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
childs from start to end

◆ childs() [2/3]

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

Implements the Node interface.

◆ childs() [3/3]

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

Implements the Node interface.

◆ childsOfType()

template<typename T >
std::vector<T> hilti::NodeBase::childsOfType ( ) const
inline

Returns a subset of children by type.

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

◆ clearCache()

void hilti::NodeBase::clearCache ( )
inline

Implements the Node interface.

◆ meta()

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

Implements the Node interface.

◆ nodesOfType()

template<typename T >
auto hilti::NodeBase::nodesOfType ( ) const
inline

Returns a subset of children Node references, selected by type.

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

◆ originalNode()

const NodeRef& hilti::NodeBase::originalNode ( ) const
inline

Implements the Node interface.

◆ setMeta()

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

Implements the Node interface.

◆ setOriginalNode()

void hilti::NodeBase::setOriginalNode ( const NodeRef n)
inline

Implements the Node interface.


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