Yume
Classes | Public Types | Public Member Functions | Public Attributes | Static Public Attributes | List of all members
yume::ast::FnDecl Struct Referencefinal

A declaration of a function (def). More...

#include <ast.hpp>

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

Classes

struct  Body
 

Public Types

using extern_decl_t = { string name
 
using abstract_decl_t = {}
 
using body_base_t = visitable_variant< Compound, string, extern_decl_t, abstract_decl_t >
 

Public Member Functions

 FnDecl (span< Token > tok, string name, vector< TypeName > args, vector< GenericParam > type_args, OptionalType ret, Body body, std::unordered_set< string > annotations)
 
void visit (Visitor &visitor) const override
 Recursively visit this ast node and all its constituents. More...
 
auto decl_name () const -> string override
 
auto varargs () const -> bool
 
auto primitive () const -> bool
 
auto extern_decl () const -> bool
 
auto abstract () const -> bool
 
auto extern_linkage () const -> bool
 
auto override () const -> bool
 
void make_extern_linkage (bool value=true)
 
auto clone () const -> FnDecl *override
 Deep copy, except for the type and attachments. More...
 
- Public Member Functions inherited from yume::ast::Decl
auto clone () const -> Decl *override=0
 Deep copy, except for the type and attachments. More...
 
virtual auto decl_name () const -> string=0
 
auto describe () const -> string final
 A short, string representation for debugging. More...
 
auto clone () const -> Stmt *override=0
 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

bool varargs
 
string name
 
std::unordered_set< string > annotations
 
vector< TypeNameargs
 
vector< GenericParamtype_args
 
OptionalType ret
 
Body body
 If this function declaration refers to a primitive, this field is a string representing the name of the primitive. If it's an external method, this field is a pair of the extern name and whether the method is varargs. Otherise, this function declaration refers to a regular function and this field holds the body of that function. More...
 
Fnsema_decl {}
 During semantic analysis, AST nodes are converted to a format better suited for semantic analysis. This field will be set once said conversion is performed. More...
 

Static Public Attributes

static constexpr auto ANN_EXTERN = "extern"
 
static constexpr auto ANN_OVERRIDE = "override"
 

Additional Inherited Members

- Protected Member Functions inherited from yume::ast::Stmt
 AST (Kind kind, span< Token > tok)
 
 AST (const AST &)=delete
 
 AST (AST &&)=default
 
- 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 declaration of a function (def).

Definition at line 762 of file ast.hpp.

Member Typedef Documentation

◆ abstract_decl_t

Definition at line 768 of file ast.hpp.

◆ body_base_t

Definition at line 770 of file ast.hpp.

◆ extern_decl_t

Definition at line 764 of file ast.hpp.

Constructor & Destructor Documentation

◆ FnDecl()

yume::ast::FnDecl::FnDecl ( span< Token tok,
string  name,
vector< TypeName args,
vector< GenericParam type_args,
OptionalType  ret,
Body  body,
std::unordered_set< string >  annotations 
)
inline

Definition at line 791 of file ast.hpp.

Referenced by clone().

Member Function Documentation

◆ abstract()

auto yume::ast::FnDecl::abstract ( ) const -> bool
inline

Definition at line 802 of file ast.hpp.

Referenced by yume::Fn::abstract().

◆ clone()

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

Deep copy, except for the type and attachments.

Implements yume::ast::Decl.

Definition at line 96 of file ast.cpp.

References annotations, args, body, FnDecl(), name, ret, yume::ast::AST::tok(), and type_args.

◆ decl_name()

auto yume::ast::FnDecl::decl_name ( ) const -> string
inlineoverridevirtual

Implements yume::ast::Decl.

Definition at line 797 of file ast.hpp.

◆ extern_decl()

auto yume::ast::FnDecl::extern_decl ( ) const -> bool
inline

Definition at line 801 of file ast.hpp.

Referenced by yume::Fn::extern_decl().

◆ extern_linkage()

auto yume::ast::FnDecl::extern_linkage ( ) const -> bool
inline

Definition at line 803 of file ast.hpp.

Referenced by yume::Fn::extern_linkage().

◆ make_extern_linkage()

void yume::ast::FnDecl::make_extern_linkage ( bool  value = true)
inline

Definition at line 805 of file ast.hpp.

Referenced by yume::Fn::make_extern_linkage().

◆ override()

auto yume::ast::FnDecl::override ( ) const -> bool
inline

Definition at line 804 of file ast.hpp.

◆ primitive()

auto yume::ast::FnDecl::primitive ( ) const -> bool
inline

Definition at line 800 of file ast.hpp.

Referenced by yume::Fn::primitive().

◆ varargs()

auto yume::ast::FnDecl::varargs ( ) const -> bool
inline

Definition at line 799 of file ast.hpp.

◆ visit()

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

Recursively visit this ast node and all its constituents.

See also
Visitor

Implements yume::ast::AST.

Definition at line 89 of file visit.cpp.

References annotations, args, body, name, ret, type_args, yume::visitable_variant< Ts >::visit(), and visitor.

Member Data Documentation

◆ ANN_EXTERN

constexpr auto yume::ast::FnDecl::ANN_EXTERN = "extern"
staticconstexpr

Definition at line 775 of file ast.hpp.

◆ ANN_OVERRIDE

constexpr auto yume::ast::FnDecl::ANN_OVERRIDE = "override"
staticconstexpr

Definition at line 776 of file ast.hpp.

Referenced by yume::DeclLike::opaque_self().

◆ annotations

std::unordered_set<string> yume::ast::FnDecl::annotations

Definition at line 779 of file ast.hpp.

Referenced by clone(), and visit().

◆ args

vector<TypeName> yume::ast::FnDecl::args

Definition at line 780 of file ast.hpp.

Referenced by clone(), yume::semantic::TypeWalker::statement(), and visit().

◆ body

Body yume::ast::FnDecl::body

If this function declaration refers to a primitive, this field is a string representing the name of the primitive. If it's an external method, this field is a pair of the extern name and whether the method is varargs. Otherise, this function declaration refers to a regular function and this field holds the body of that function.

Definition at line 786 of file ast.hpp.

Referenced by clone(), yume::Fn::compound_body(), yume::Fn::fn_body(), yume::semantic::TypeWalker::statement(), and visit().

◆ name

string yume::ast::FnDecl::name

Definition at line 778 of file ast.hpp.

Referenced by clone(), and visit().

◆ ret

OptionalType yume::ast::FnDecl::ret

Definition at line 782 of file ast.hpp.

Referenced by clone(), yume::semantic::TypeWalker::statement(), and visit().

◆ sema_decl

Fn* yume::ast::FnDecl::sema_decl {}

During semantic analysis, AST nodes are converted to a format better suited for semantic analysis. This field will be set once said conversion is performed.

Definition at line 789 of file ast.hpp.

◆ type_args

vector<GenericParam> yume::ast::FnDecl::type_args

Definition at line 781 of file ast.hpp.

Referenced by clone(), and visit().

◆ varargs

bool yume::ast::FnDecl::varargs

Definition at line 766 of file ast.hpp.

Referenced by yume::semantic::TypeWalker::statement(), and yume::Fn::varargs().


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