![]() |
Spicy
|
#include <module.h>
Public Member Functions | |
Module (ID id, Meta m=Meta()) | |
Module (ID id, std::vector< Declaration > decls, Meta m=Meta()) | |
Module (ID id, std::vector< Declaration > decls, std::vector< Statement > stmts, const Meta &m=Meta()) | |
const auto & | id () const |
const auto & | statements () const |
auto | declarations () const |
auto | declarationRefs () const |
bool | isEmpty () const |
void | clear () |
hilti::optional_ref< const declaration::Property > | moduleProperty (const ID &id) const |
hilti::node::Set< declaration::Property > | moduleProperties (const std::optional< ID > &id) const |
void | add (Declaration n) |
void | add (Statement s) |
void | add (Expression e) |
NodeRef | preserve (const Node &n) |
void | destroyPreservedNodes () |
auto | properties () const |
![]() | |
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< NodeRef > | childRefsOfType () const |
void | addChild (Node n) |
const auto & | children () const |
auto & | children () |
auto & | meta () const |
void | setMeta (Meta m) |
bool | pruneWalk () const |
AST node representing a HILTI module.
|
inline |
Adds a declaration to the module. It will be appended to the current list of declarations.
Note this is a mutating function. Module
is an exception among AST classes in that we allow to modify existing instances. Changes will be reflected in all copies of this instance.
|
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.
Note this is a mutating function. Module
is an exception among AST classes in that we allow to modify existing instances. Changes will be reflected in all copies of this instance.
|
inline |
Adds a top-level expression to the module. It will be appended to the end of the current list of statements and be evaluated at module initialize time.
Note this is a mutating function. Module
is an exception among AST classes in that we allow to modify existing instances. Changes will be reflected in all copies of this instance.
void 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.)
void Module::destroyPreservedNodes | ( | ) |
Destroys any nodes retained previously through preserve()
.
node::Set< declaration::Property > Module::moduleProperties | ( | const std::optional< 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.
id | name of the property to return; leave unset for returning all |
hilti::optional_ref< const declaration::Property > 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.
id | name of the property to return |
Saves a node along with the module, but outside of the actual AST. This allows keeping references to the node's sub-AST valid while not making the node itself part of the AST. That's especially useful when transforming nodes from one representation to another while other parts of the AST are still referring to the original once.
n | node to retain with all of its children |
|
inline |
Implements the Node
interface.