Spicy
Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
hilti::AttributeSet Class Reference

#include <attribute.h>

Inheritance diagram for hilti::AttributeSet:
hilti::Node

Public Member Functions

auto attributes () const
 
Attributefind (const attribute::Kind &kind) const
 
hilti::node::Set< AttributefindAll (const attribute::Kind &kind) const
 
void add (ASTContext *ctx, Attribute *a)
 
void remove (const attribute::Kind &kind)
 
 operator bool () const
 
- Public Member Functions inherited from hilti::Node
node::Tag nodeTag () const
 
bool hasParent () const
 
Nodeparent (int i=1) const
 
template<typename T >
T * parent () const
 
auto pathLength () const
 
const auto & meta () const
 
const auto & location () const
 
void setMeta (Meta m)
 
auto scope () const
 
auto getOrCreateScope ()
 
void clearScope ()
 
Result< std::pair< Declaration *, ID > > lookupID (const ID &id, const std::string_view &what) const
 
virtual bool inheritScope () const
 
std::string typename_ () const
 
uint64_t identity () const
 
const auto & children () const
 
template<typename T >
T * child (unsigned int i) const
 
template<typename T >
T * childTryAs (unsigned int i) const
 
Nodechild (unsigned int i) const
 
template<typename T >
auto children (int begin, std::optional< int > end) const
 
template<typename T >
auto children (int begin, std::optional< int > end)
 
template<typename T >
node::Set< T > childrenOfType () const
 
bool hasChild (const Node *n, bool recurse=false) const
 
Nodesibling (Node *n) const
 
void addChild (ASTContext *ctx, Node *n)
 
void addChildren (ASTContext *ctx, const Nodes &children)
 
void removeChild (Node *n)
 
void removeChildren (int begin, std::optional< int > end)
 
void setChild (ASTContext *ctx, size_t idx, Node *n)
 
void replaceChildren (ASTContext *ctx, const Nodes &children)
 
void replaceChild (ASTContext *ctx, Node *old, Node *new_)
 
template<typename T >
bool isA () const
 
template<typename T >
bool isA_ () const
 
template<typename T >
T * as () const
 
template<typename T >
T * as ()
 
template<typename T >
const T * tryAs () const
 
template<typename T >
T * tryAs ()
 
template<typename T >
T * tryAs_ ()
 
void print (std::ostream &out, bool compact, bool user_visible) const
 
std::string print () const
 
std::string printRaw () const
 
 operator std::string () const
 
std::string dump () const
 
std::string renderSelf (bool include_location=true) const
 
void addError (std::string msg, std::vector< std::string > context={})
 
void addError (std::string msg, node::ErrorPriority priority, std::vector< std::string > context={})
 
void addError (std::string msg, const Location &l, std::vector< std::string > context={})
 
void addError (std::string msg, Location l, node::ErrorPriority priority, std::vector< std::string > context={})
 
bool hasErrors () const
 
const auto & errors () const
 
void clearErrors ()
 
void clearChildren ()
 
void retain ()
 
void release ()
 
bool isRetained () const
 
virtual node::Properties properties () const
 
virtual void dispatch (visitor::Dispatcher &v)=0
 
virtual std::string_view branchTag () const
 
Nodeoperator= (const Node &other)=delete
 
Nodeoperator= (Node &&other) noexcept=delete
 

Static Public Member Functions

static auto create (ASTContext *ctx, const Attributes &attrs={}, Meta m=Meta())
 

Protected Member Functions

 AttributeSet (ASTContext *ctx, Nodes children, Meta m=Meta())
 
 AttributeSet (ASTContext *ctx, Meta m=Meta())
 
std::string _dump () const override
 
 HILTI_NODE_0 (AttributeSet, final)
 
- Protected Member Functions inherited from hilti::Node
 Node (ASTContext *ctx, node::Tags node_tags, Nodes children, Meta meta)
 
 Node (ASTContext *ctx, node::Tags node_tags, Meta meta)
 
 Node (Node &&other)=default
 
 Node (const Node &other)
 
virtual std::string _typename () const
 
virtual Node_clone (ASTContext *ctx) const =0
 

Additional Inherited Members

- Static Public Attributes inherited from hilti::Node
static constexpr uint16_t NodeLevel = 0
 
static constexpr ::hilti::node::Tag NodeTag = ::hilti::node::tag::Node
 
static constexpr ::hilti::node::Tags NodeTags = {::hilti::node::tag::Node}
 

Detailed Description

AST node holding a set of Attribute nodes.

Constructor & Destructor Documentation

◆ AttributeSet() [1/2]

hilti::AttributeSet::AttributeSet ( ASTContext ctx,
Nodes  children,
Meta  m = Meta() 
)
inlineexplicitprotected

Constructs a set from from a vector of attributes.

Parameters
avector to initialize attribute set from
mmeta data to associate with the node

◆ AttributeSet() [2/2]

hilti::AttributeSet::AttributeSet ( ASTContext ctx,
Meta  m = Meta() 
)
inlineprotected

Constructs an empty set.

Parameters
mmeta data to associate with the node

Member Function Documentation

◆ _dump()

std::string AttributeSet::_dump ( ) const
overrideprotectedvirtual

Returns additional information to include into the node's dump() output, as provided by derived classes.

Reimplemented from hilti::Node.

◆ add()

void hilti::AttributeSet::add ( ASTContext ctx,
Attribute a 
)
inline

Adds an attribute to the set.

◆ attributes()

auto hilti::AttributeSet::attributes ( ) const
inline

Returns the set's attributes.

◆ find()

Attribute * AttributeSet::find ( const attribute::Kind kind) const

Retrieves an attribute with a given kind from the set. If multiple attributes with that kind exist, it's undefined which one is returned.

Returns
attribute if found, or null otherwise.

◆ findAll()

hilti::node::Set< Attribute > AttributeSet::findAll ( const attribute::Kind kind) const

Retrieves all attributes with a given kind from the set.

Returns
all attributes with matching kind

◆ operator bool()

hilti::AttributeSet::operator bool ( ) const
inline

Returns true if the set has at least one element.

◆ remove()

void AttributeSet::remove ( const attribute::Kind kind)

Removes all attributes of the given kind.


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