Yume
Public Member Functions | Public Attributes | List of all members
yume::ast::GenericParam Struct Referencefinal

A generic, compile-time argument to a struct or function definition, comparable to C++ template parameters. Like C++ templates, these can be non-type parameters. If it's a generic type parameter, such as the following: More...

#include <ast.hpp>

Inheritance diagram for yume::ast::GenericParam:
Inheritance graph
[legend]
Collaboration diagram for yume::ast::GenericParam:
Collaboration graph
[legend]

Public Member Functions

 GenericParam (span< Token > tok, OptionalType type, string name)
 
void visit (Visitor &visitor) const override
 Recursively visit this ast node and all its constituents. More...
 
auto describe () const -> string override
 A short, string representation for debugging. More...
 
auto is_type_parameter () const -> bool
 
auto clone () const -> GenericParam *override
 Deep copy, except for the type and attachments. More...
 
- Public Member Functions inherited from yume::ast::AST
 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...
 

Public Attributes

OptionalType type
 
string name
 

Additional Inherited Members

- Protected Member Functions inherited from yume::ast::AST
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)
 

Detailed Description

A generic, compile-time argument to a struct or function definition, comparable to C++ template parameters. Like C++ templates, these can be non-type parameters. If it's a generic type parameter, such as the following:

struct Array{T type}

The type field will be absent, and the name will be uppercased. Otherwise, it's a non-type generic parameter:

struct StaticArray{n I32}

In this case, the type field be filled out with the specified type, and the name will be lowercase.

Definition at line 422 of file ast.hpp.

Constructor & Destructor Documentation

◆ GenericParam()

yume::ast::GenericParam::GenericParam ( span< Token tok,
OptionalType  type,
string  name 
)
inline

Definition at line 426 of file ast.hpp.

Referenced by clone().

Member Function Documentation

◆ clone()

auto yume::ast::GenericParam::clone ( ) const -> GenericParam *override
overridevirtual

Deep copy, except for the type and attachments.

Implements yume::ast::AST.

Definition at line 111 of file ast.cpp.

References GenericParam(), name, yume::ast::AST::tok(), and type.

◆ describe()

auto yume::ast::GenericParam::describe ( ) const -> string
inlineoverridevirtual

A short, string representation for debugging.

Reimplemented from yume::ast::AST.

Definition at line 429 of file ast.hpp.

◆ is_type_parameter()

auto yume::ast::GenericParam::is_type_parameter ( ) const -> bool
inline

Definition at line 431 of file ast.hpp.

References yume::ast::OptionalAnyBase< T >::has_value().

◆ visit()

void yume::ast::GenericParam::visit ( Visitor visitor) const
overridevirtual

Recursively visit this ast node and all its constituents.

See also
Visitor

Implements yume::ast::AST.

Definition at line 121 of file visit.cpp.

References name, type, and visitor.

Member Data Documentation

◆ name

string yume::ast::GenericParam::name

Definition at line 424 of file ast.hpp.

Referenced by clone(), and visit().

◆ type

OptionalType yume::ast::GenericParam::type

Definition at line 423 of file ast.hpp.

Referenced by clone(), and visit().


The documentation for this struct was generated from the following files: