#include <node.h>
|
template<typename T , typename std::enable_if_t< std::is_base_of< trait::isNode, T >::value > * = nullptr> |
| Node (T t) |
|
| Node (const Node &other) |
|
| Node (Node &&other) noexcept |
|
uint64_t | rid () const |
|
std::string | renderedRid () const |
|
IntrusivePtr< Scope > | scope () const |
|
void | setScope (IntrusivePtr< Scope > new_scope) |
|
void | clearScope () |
|
std::vector< node::Error > | errors () const |
|
bool | hasErrors () const |
|
void | clearErrors () |
|
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={}) |
|
void | destroyChildren () |
|
std::string | render (bool include_location=true) const |
|
void | print (std::ostream &out, bool compact=false) const |
|
std::string | print () const |
|
const Location & | location () const |
|
template<typename T > |
void | assertIsA () |
|
| operator std::string () const |
|
Node & | operator= (const Node &n) |
|
Node & | operator= (Node &&n) noexcept |
|
template<typename T > |
Node & | operator= (const T &t) |
|
AST node. This is a type-erased class that wraps all AST nodes.
- Note
- Do not derive from this class. Derive from
NodeBase
instead and then implement the Node
interface.
◆ Node()
template<typename T , typename std::enable_if_t< std::is_base_of< trait::isNode, T >::value > * = nullptr>
Constructs a node from an instance of a class implementing the Node
interface.
◆ addError() [1/4]
void hilti::Node::addError |
( |
std::string |
msg, |
|
|
std::vector< std::string > |
context = {} |
|
) |
| |
|
inline |
Associate an error message with the node. The error's location will be that of the current node, and it will have normal priority.
- Parameters
-
msg | error message to report |
context | further lines of context to show along with error |
◆ addError() [2/4]
void hilti::Node::addError |
( |
std::string |
msg, |
|
|
node::ErrorPriority |
priority, |
|
|
std::vector< std::string > |
context = {} |
|
) |
| |
|
inline |
Associate an error message with the node. The error's location will be that of the current node.
- Parameters
-
msg | error message to report |
priority | importance of showing the error |
context | further lines of context to show along with error |
◆ addError() [3/4]
void hilti::Node::addError |
( |
std::string |
msg, |
|
|
const Location & |
l, |
|
|
std::vector< std::string > |
context = {} |
|
) |
| |
|
inline |
Associate an error message with the node. The error will have normal priority.
- Parameters
-
msg | error message to report |
l | custom location to associate with the error |
context | further lines of context to show along with error |
◆ addError() [4/4]
Associate an error message with the node.
- Parameters
-
msg | error message to report |
l | custom location to associate with the error |
priority | importance of showing the error |
context | further lines of context to show along with error |
◆ assertIsA()
template<typename T >
void hilti::Node::assertIsA |
( |
| ) |
|
|
inline |
Aborts execution if node is not of a given type T
.
◆ clearErrors()
void hilti::Node::clearErrors |
( |
| ) |
|
|
inline |
Clears any error message associated with the node.
◆ clearScope()
void hilti::Node::clearScope |
( |
| ) |
|
|
inline |
Clears out the current scope.
◆ destroyChildren()
void Node::destroyChildren |
( |
| ) |
|
Recursively clears all child nodes and then deletes them from this node. This helps to break reference cycles.
◆ errors()
Returns any error messages associated with the node.
◆ hasErrors()
bool hilti::Node::hasErrors |
( |
| ) |
const |
|
inline |
Returns true if there are any errors associated with the node.
◆ location()
const Location& hilti::Node::location |
( |
| ) |
const |
|
inline |
Convenience method to return the meta data's location information.
◆ operator std::string()
hilti::Node::operator std::string |
( |
| ) |
const |
|
inline |
Renders the node as HILTI source code.
◆ operator=() [1/3]
Node& hilti::Node::operator= |
( |
const Node & |
n | ) |
|
|
inline |
Replaces the node with another one. Existing NodeRef
pointing to this node will remain valid and reflect the new value.
◆ operator=() [2/3]
Node& hilti::Node::operator= |
( |
Node && |
n | ) |
|
|
inlinenoexcept |
Replaces the node with another one. Existing NodeRef
pointing to this node will remain valid and reflect the new value.
◆ operator=() [3/3]
template<typename T >
Node& hilti::Node::operator= |
( |
const T & |
t | ) |
|
|
inline |
Replaces the node with an instance of a class implementing the Node
interface. Existing NodeRef
pointing to this node will remain valid and reflect the new value.
◆ print() [1/2]
void Node::print |
( |
std::ostream & |
out, |
|
|
bool |
compact = false |
|
) |
| const |
Print out a HILTI source code representation of the node and all its children. If the node is not the root of an AST, it's not guaranteed that the result will form valid HILTI source code (but it can still be used, e.g., in error messages).
- Parameters
-
out | output stream |
compact | create a one-line representation |
◆ print() [2/2]
std::string Node::print |
( |
| ) |
const |
Returns a HILTI source code representation of the node and all its children. This can be called from inside a debugger.
◆ render()
std::string Node::render |
( |
bool |
include_location = true | ) |
const |
Returns an internal string representation of the node and all its children.
- Parameters
-
include_location | if true, include source code locations into the output |
◆ renderedRid()
std::string hilti::Node::renderedRid |
( |
| ) |
const |
|
inline |
Returns a string representation of rid()
.
- Note
- This is primarily for internal usage.
◆ rid()
uint64_t hilti::Node::rid |
( |
| ) |
const |
|
inline |
Returns the node's unique control ID if there's at least NodeRef
has been created that refers to it. If there's no such NodeRef, returns zero.
- Note
- This is primarily for internal usage.
◆ scope()
Returns the scope associated with the node. All nodes have a scope used for ID resolution. Initially, a new node receive its own, empty scope. However, scopes can be shared across nodes through setScope()
.
◆ setScope()
Resets the node's scope to point to another one.
The documentation for this class was generated from the following files:
- /home/docs/checkouts/readthedocs.org/user_builds/spicy-docs/checkouts/v1.6.1/hilti/toolchain/include/ast/node.h
- /home/docs/checkouts/readthedocs.org/user_builds/spicy-docs/checkouts/v1.6.1/hilti/toolchain/src/ast/node.cc