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

#include <module.h>

Inheritance diagram for hilti::declaration::Module:
hilti::Declaration hilti::Node hilti::node::WithDocString

Public Member Functions

const auto & uid () const
 
const auto & id () const
 
const auto & scopeID () const
 
const auto & scopePath () const
 
auto statements () const
 
auto declarations () const
 
const auto & dependencies () const
 
bool isEmpty () const
 
bool skipImplementation () const
 
void setSkipImplementation (bool skip_implementation)
 
auto cxxUnit () const
 
void setCxxUnit (std::shared_ptr<::hilti::detail::cxx::Unit > unit)
 
void clear ()
 
PropertymoduleProperty (const ID &id) const
 
hilti::node::Set< declaration::PropertymoduleProperties (const ID &id) const
 
void add (ASTContext *ctx, Declaration *d)
 
void add (ASTContext *ctx, Statement *s)
 
void addDependency (declaration::module::UID uid)
 
void clearDependencies ()
 
void setScopePath (const ID &scope)
 
void setUID (declaration::module::UID uid)
 
std::string_view displayName () const final
 
node::Properties properties () const override
 
std::string_view branchTag () const final
 
- Public Member Functions inherited from hilti::Declaration
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)
 
 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
 
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)
 

Static Public Member Functions

static auto create (ASTContext *ctx, const declaration::module::UID &uid, const ID &scope, const Declarations &decls, const Statements &stmts, Meta meta={})
 
static auto create (ASTContext *ctx, const declaration::module::UID &uid, const ID &scope={}, Meta meta={})
 
static auto create (ASTContext *ctx, const declaration::module::UID &uid, const ID &scope, const Declarations &decls, Meta meta={})
 

Protected Member Functions

 Module (ASTContext *ctx, Nodes children, declaration::module::UID uid, ID scope, Meta meta={})
 
std::string _dump () const override
 
 HILTI_NODE_1 (declaration::Module, Declaration, final)
 
- Protected Member Functions inherited from hilti::Declaration
 Declaration (ASTContext *ctx, node::Tags node_tags, Nodes children, ID id, declaration::Linkage linkage, Meta meta={})
 
void setDeclarationIndex (ast::DeclarationIndex index)
 
 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
 

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 for a module declaration.

Member Function Documentation

◆ _dump()

std::string declaration::Module::_dump ( ) const
overrideprotectedvirtual

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

Reimplemented from hilti::Declaration.

◆ add() [1/2]

void hilti::declaration::Module::add ( ASTContext ctx,
Declaration d 
)
inline

Adds a declaration to the module. It will be appended to the current list of declarations.

◆ add() [2/2]

void hilti::declaration::Module::add ( ASTContext ctx,
Statement s 
)
inline

Adds a top-level statement to the module. It will be appended to the end of the current list of statements and execute at module initialize time.

◆ branchTag()

std::string_view hilti::declaration::Module::branchTag ( ) const
inlinefinalvirtual

Optional tag associated with the AST subbranch that this node is the top of. If a tag is returned, this may be used to by visitors to skip the subbranch entirely based on that tag.

Returns
tag associated with the subbranch, or an empty string if none

Reimplemented from hilti::Node.

◆ clear()

void hilti::declaration::Module::clear ( )

Removes any content from the module. The result is an empty module just as if it had just been created. (The ID remains in place.)

◆ displayName()

std::string_view hilti::declaration::Module::displayName ( ) const
inlinefinalvirtual

Returns a user-friendly descriptive name for the type of object the declaration refers to (e.g., "local variable"). This can be used in messages to the user.

Implements hilti::Declaration.

◆ moduleProperties()

node::Set< declaration::Property > declaration::Module::moduleProperties ( const ID id) const

Returns all of module's property declarations of a given name. If there's no property declaration of that ID, return an empty container.

Parameters
idname of the property to return; leave unset for returning all

◆ moduleProperty()

declaration::Property * declaration::Module::moduleProperty ( const ID id) const

Returns a module's property declaration of a given name. If there's no property declaration of that name, return an error. If there's more than one of that name, it's undefined which one is returned.

Parameters
idname of the property to return

◆ properties()

node::Properties hilti::declaration::Module::properties ( ) const
inlineoverridevirtual

Implements the node interface.

Reimplemented from hilti::Declaration.

◆ setSkipImplementation()

void hilti::declaration::Module::setSkipImplementation ( bool  skip_implementation)
inline

Sets the module's skip-implementation flag.

◆ skipImplementation()

bool hilti::declaration::Module::skipImplementation ( ) const
inline

Retrieves the module's skip-implementation flag.


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