Pegmatite
|
Base class for AST nodes. More...
#include <ast.hh>
Public Member Functions | |
ASTNode () | |
Constructs the AST node, with a null parent. | |
ASTNode (const ASTNode &)=delete | |
Copying AST nodes is not supported. | |
virtual | ~ASTNode () |
Destructor does nothing, virtual for subclasses to use. More... | |
ASTNode * | parent () const |
Returns the parent of this AST node, or nullptr if there isn't one (either if this is the root, or if it is still in the stack waiting to be added to the tree). | |
virtual void | construct (const InputRange &r, ASTStack &st)=0 |
Interface for constructing the AST node. More... | |
virtual bool | isa (char *x) |
Root implementation of the RTTI-replacement for builds not wishing to use RTTI. More... | |
template<class T > | |
bool | isa () |
Returns true if this object is an instance of T . More... | |
template<class T > | |
T * | get_as () |
Returns a pointer to this object as a pointer to a child class, or nullptr if the cast would be unsafe. More... | |
Protected Member Functions | |
virtual char * | kind () |
Returns the kind of object class. More... | |
Static Protected Member Functions | |
static char * | classKind () |
Returns the unique identifier for this class. | |
Friends | |
template<class T , bool Optional> | |
class | ASTPtr |
template<class T > | |
class | ASTList |
template<class T > | |
class | BindAST |
Base class for AST nodes.
|
virtual |
Destructor does nothing, virtual for subclasses to use.
Defined out-of-line to avoid emitting vtables in every translation unit that includes this header.
|
pure virtual |
Interface for constructing the AST node.
The input range r
is the range within the source.
Implemented in pegmatite::ASTContainer.
|
inline |
Returns a pointer to this object as a pointer to a child class, or nullptr
if the cast would be unsafe.
Note that AST nodes are intended to be always used as unique pointers and so the returned object is only valid as long as the unique pointer is valid.
|
inlinevirtual |
Root implementation of the RTTI-replacement for builds not wishing to use RTTI.
This returns true if x
is the value returned from classKind()
, or false otherwise.
|
inline |
Returns true if this object is an instance of T
.
Note that this only works with single-inheritance hierarchies. If you wish to use multiple inheritance in your AST classes, then you must define USE_RTTI
and use the C++ RTTI mechanism.
|
inlineprotectedvirtual |
Returns the kind of object class.
This is a unique pointer that can be tested against pointers returned by classKind() to determine whether they can be safely compared.