![]() |
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 |
const auto & | declarations () const |
const auto & | preserved () const |
auto & | preserved () |
bool | isEmpty () const |
void | clear () |
Result< declaration::Property > | moduleProperty (const ID &id) const |
std::vector< declaration::Property > | moduleProperties (const ID &id) const |
void | add (Declaration n) |
void | add (Statement s) |
void | add (Expression e) |
NodeRef | preserve (Node n) |
auto | properties () const |
void | clearCache () |
![]() | |
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 NodeRef & | originalNode () const |
void | setOriginalNode (const NodeRef &n) |
void | clearCache () |
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.)
std::vector< declaration::Property > 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.
id | name of the property to return |
Result< 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 valid while not making the node itself part of the AST. That's especially useful when transforming nodes from one representation to another, but wanting to retain a link to the original one through Node::setOriginalNode()
.
|
inline |
Implements the Node
interface.