|
Yume
|
All nodes in the AST tree of the program inherit from this class.
More...
#include <ast.hpp>

Public Member Functions | |
| AST (const AST &)=delete | |
| AST (AST &&)=default | |
| auto | operator= (const AST &) -> AST &=delete |
| auto | operator= (AST &&) -> AST &=delete |
| virtual | ~AST ()=default |
| virtual void | visit (Visitor &visitor) const =0 |
| Recursively visit this ast node and all its constituents. More... | |
| auto | val_ty () const noexcept -> optional< ty::Type > |
| auto | ensure_ty () const -> ty::Type |
| void | val_ty (optional< ty::Type > type) |
| void | attach_to (nonnull< AST * > other) |
Make the type of this node depend on the type of other. More... | |
| auto | kind () const -> Kind |
| auto | kind_name () const -> string |
Human-readable string representation of the Kind of this node. More... | |
| auto | token_range () const -> const span< Token > & |
| auto | equals_by_hash (ast::AST &other) const -> bool |
| auto | location () const -> Loc |
The union of the locations of the Tokens making up this node. More... | |
| virtual auto | describe () const -> string |
| A short, string representation for debugging. More... | |
| virtual auto | clone () const -> AST *=0 |
| Deep copy, except for the type and attachments. More... | |
Protected Member Functions | |
| void | unify_val_ty () |
| Verify the type compatibility of the depends of this node, and merge the types if possible. This is called every time the node's type is updated. More... | |
| auto | tok () const noexcept -> span< Token > |
| AST (Kind kind, span< Token > tok) | |
All nodes in the AST tree of the program inherit from this class.
AST nodes cannot be copied or moved as all special member functions (aside from the destructor) are deleted. There will always be one instance for a specific node during the lifetype of the compiler. However note that AST nodes can be cloned with the clone() method, which will produce a deep copy. This is used when instantiating a template. The clone will have the exact same structure and locations but distinct types, depending on what the types the template is instantiated with.
|
delete |
|
default |
|
virtualdefault |
Make the type of this node depend on the type of other.
Definition at line 266 of file ast.hpp.
References unify_val_ty().
Referenced by yume::semantic::TypeWalker::expression(), and yume::semantic::TypeWalker::statement().
|
pure virtual |
Deep copy, except for the type and attachments.
Implemented in yume::ast::AssignExpr, yume::ast::BinaryLogicExpr, yume::ast::BoolExpr, yume::ast::CallExpr, yume::ast::CharExpr, yume::ast::Compound, yume::ast::ConstDecl, yume::ast::ConstExpr, yume::ast::CtorDecl, yume::ast::CtorExpr, yume::ast::Decl, yume::ast::DtorExpr, yume::ast::Expr, yume::ast::FieldAccessExpr, yume::ast::FnDecl, yume::ast::FunctionType, yume::ast::GenericParam, yume::ast::IfClause, yume::ast::IfStmt, yume::ast::ImplicitCastExpr, yume::ast::LambdaExpr, yume::ast::NumberExpr, yume::ast::Program, yume::ast::ProxyType, yume::ast::QualType, yume::ast::ReturnStmt, yume::ast::SelfType, yume::ast::SimpleType, yume::ast::SliceExpr, yume::ast::Stmt, yume::ast::StringExpr, yume::ast::StructDecl, yume::ast::TemplatedType, yume::ast::Type, yume::ast::TypeExpr, yume::ast::TypeName, yume::ast::VarDecl, yume::ast::VarExpr, and yume::ast::WhileStmt.
|
virtual |
A short, string representation for debugging.
Reimplemented in yume::ast::Decl, yume::ast::SimpleType, yume::ast::QualType, yume::ast::SelfType, yume::ast::ProxyType, yume::ast::FunctionType, yume::ast::TypeName, yume::ast::GenericParam, yume::ast::TemplatedType, yume::ast::NumberExpr, yume::ast::CharExpr, yume::ast::BoolExpr, yume::ast::StringExpr, yume::ast::VarExpr, yume::ast::ConstExpr, yume::ast::CallExpr, yume::ast::BinaryLogicExpr, yume::ast::CtorExpr, yume::ast::DtorExpr, and yume::ast::SliceExpr.
Definition at line 11 of file describe.cpp.
References kind_name().
|
inline |
Definition at line 254 of file ast.hpp.
References YUME_ASSERT.
Referenced by yume::destruct_indirect(), yume::Compiler::expression(), yume::ty::Type::is_trivially_destructible(), yume::semantic::OverloadSet::is_valid_overload(), and yume::Compiler::statement().
| auto yume::ast::AST::equals_by_hash | ( | ast::AST & | other | ) | const -> bool |
|
inline |
Definition at line 272 of file ast.hpp.
Referenced by yume::CRTPWalker< Derived >::body_expression(), yume::CRTPWalker< Derived >::body_statement(), and kind_name().
|
inline |
Human-readable string representation of the Kind of this node.
Definition at line 274 of file ast.hpp.
References kind(), and yume::ast::kind_name().
Referenced by yume::semantic::TypeWalker::body_expression(), yume::Compiler::body_statement(), yume::semantic::TypeWalker::body_statement(), and describe().
| auto yume::ast::AST::location | ( | ) | const -> Loc |
|
inlineprotectednoexcept |
Definition at line 239 of file ast.hpp.
Referenced by yume::ast::AssignExpr::clone(), yume::ast::BinaryLogicExpr::clone(), yume::ast::BoolExpr::clone(), yume::ast::CallExpr::clone(), yume::ast::CharExpr::clone(), yume::ast::Compound::clone(), yume::ast::ConstDecl::clone(), yume::ast::ConstExpr::clone(), yume::ast::CtorDecl::clone(), yume::ast::CtorExpr::clone(), yume::ast::DtorExpr::clone(), yume::ast::FieldAccessExpr::clone(), yume::ast::FnDecl::clone(), yume::ast::FunctionType::clone(), yume::ast::GenericParam::clone(), yume::ast::IfClause::clone(), yume::ast::IfStmt::clone(), yume::ast::ImplicitCastExpr::clone(), yume::ast::LambdaExpr::clone(), yume::ast::NumberExpr::clone(), yume::ast::Program::clone(), yume::ast::ProxyType::clone(), yume::ast::QualType::clone(), yume::ast::ReturnStmt::clone(), yume::ast::SelfType::clone(), yume::ast::SimpleType::clone(), yume::ast::SliceExpr::clone(), yume::ast::StringExpr::clone(), yume::ast::StructDecl::clone(), yume::ast::TemplatedType::clone(), yume::ast::TypeExpr::clone(), yume::ast::TypeName::clone(), yume::ast::VarDecl::clone(), yume::ast::VarExpr::clone(), and yume::ast::WhileStmt::clone().
|
inline |
|
protected |
Verify the type compatibility of the depends of this node, and merge the types if possible. This is called every time the node's type is updated.
Definition at line 10 of file ast.cpp.
Referenced by attach_to().
|
inlinenoexcept |
Definition at line 253 of file ast.hpp.
Referenced by yume::semantic::TypeWalker::expression(), and yume::semantic::TypeWalker::statement().
|
inline |
|
pure virtual |
Recursively visit this ast node and all its constituents.
Implemented in yume::ast::SimpleType, yume::ast::QualType, yume::ast::SelfType, yume::ast::ProxyType, yume::ast::FunctionType, yume::ast::TypeName, yume::ast::GenericParam, yume::ast::TemplatedType, yume::ast::NumberExpr, yume::ast::CharExpr, yume::ast::BoolExpr, yume::ast::StringExpr, yume::ast::VarExpr, yume::ast::ConstExpr, yume::ast::CallExpr, yume::ast::BinaryLogicExpr, yume::ast::CtorExpr, yume::ast::DtorExpr, yume::ast::SliceExpr, yume::ast::AssignExpr, yume::ast::FieldAccessExpr, yume::ast::ImplicitCastExpr, yume::ast::TypeExpr, yume::ast::Compound, yume::ast::LambdaExpr, yume::ast::FnDecl, yume::ast::CtorDecl, yume::ast::StructDecl, yume::ast::VarDecl, yume::ast::ConstDecl, yume::ast::WhileStmt, yume::ast::IfClause, yume::ast::IfStmt, yume::ast::ReturnStmt, and yume::ast::Program.
Referenced by yume::ast::AnyTypeOrExpr::ast(), and yume::Fn::ast().