Spicy
Public Member Functions | Protected Member Functions | Friends | List of all members
hilti::Declaration Class Referenceabstract

#include <declaration.h>

Inheritance diagram for hilti::Declaration:
hilti::Node hilti::node::WithDocString hilti::declaration::Constant hilti::declaration::Expression hilti::declaration::Field 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::type::bitfield::BitRange spicy::declaration::Hook spicy::declaration::UnitHook spicy::type::unit::Item

Public Member Functions

const auto & id () const
 
auto linkage () const
 
const auto & fullyQualifiedID () const
 
const auto & canonicalID () const
 
auto declarationIndex () const
 
void setID (const ID &id)
 
void setLinkage (declaration::Linkage linkage)
 
void setFullyQualifiedID (ID id)
 
void setCanonicalID (ID id)
 
virtual std::string_view displayName () const =0
 
node::Properties properties () const override
 
 Declaration (const Declaration &other)
 
 Declaration (Declaration &&other)=default
 
Declarationoperator= (const Declaration &other)=delete
 
Declarationoperator= (Declaration &&other)=delete
 
- 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 void dispatch (visitor::Dispatcher &v)=0
 
virtual std::string_view branchTag () const
 
Nodeoperator= (const Node &other)=delete
 
Nodeoperator= (Node &&other) noexcept=delete
 
- Public Member Functions inherited from hilti::node::WithDocString
const std::optional< DocString > & documentation () const
 
void clearDocumentation ()
 
void setDocumentation (DocString doc)
 

Protected Member Functions

 Declaration (ASTContext *ctx, node::Tags node_tags, Nodes children, ID id, declaration::Linkage linkage, Meta meta={})
 
void setDeclarationIndex (ast::DeclarationIndex index)
 
std::string _dump () const override
 
 HILTI_NODE_0 (Declaration, override)
 
- 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
 

Friends

class ASTContext
 

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

Base class for implementing declaration nodes.

Member Function Documentation

◆ _dump()

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

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

Reimplemented from hilti::Node.

Reimplemented in hilti::declaration::Parameter, hilti::declaration::Module, and hilti::declaration::Field.

◆ canonicalID()

const auto& hilti::Declaration::canonicalID ( ) const
inline

Returns the canonical ID associated with the declaration once it has been set during AST processing. Canonical IDs are guaranteed to be globally unique within one instance of an AST context. However, the ID is guaranteed to be unique and stable only once AST processing has finished. Returns an empty ID if not yet set.

◆ declarationIndex()

auto hilti::Declaration::declarationIndex ( ) const
inline

Returns the index the AST context associates with the declaration. This may become set during AST resolving. If not set yet, returns None.

◆ displayName()

virtual std::string_view hilti::Declaration::displayName ( ) const
pure virtual

◆ fullyQualifiedID()

const auto& hilti::Declaration::fullyQualifiedID ( ) const
inline

Returns the declaration's fully qualified ID once it has been set during AST processing. The ID is guaranteed to be stable only after AST processing has finished. Returns an empty ID if not yet set.

◆ id()

const auto& hilti::Declaration::id ( ) const
inline

Returns the declaration's ID.

◆ linkage()

auto hilti::Declaration::linkage ( ) const
inline

Returns the declaration's linkage.

◆ properties()

node::Properties hilti::Declaration::properties ( ) const
inlineoverridevirtual

◆ setCanonicalID()

void hilti::Declaration::setCanonicalID ( ID  id)
inline

Associates a canonical ID with the declaration. Should be used only by the ID assigner during AST processing.

Parameters
idcanonical ID, which must be globally unique for this declaration

◆ setFullyQualifiedID()

void hilti::Declaration::setFullyQualifiedID ( ID  id)
inline

Sets the declaration's fully qualified ID. Should be used only by the ID assigner during AST processing.

Parameters
idfully qualified ID

◆ setID()

void hilti::Declaration::setID ( const ID id)
inline

Sets the declaration's ID. This clears fully-qualified and canonical IDs as they likely need to be recomputed now.

◆ setLinkage()

void hilti::Declaration::setLinkage ( declaration::Linkage  linkage)
inline

Sets the declaration's linkage.


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