Yume
Public Member Functions | Public Attributes | List of all members
yume::Struct Struct Reference

A struct declaration in the compiler. More...

#include <vals.hpp>

Collaboration diagram for yume::Struct:
Collaboration graph
[legend]

Public Member Functions

 Struct (ast::StructDecl &ast_decl, ast::Program *member, optional< ty::Type > type, Substitutions subs) noexcept
 
 Struct (ast::StructDecl &ast_decl, ast::Program *member, optional< ty::Type > type, nullable< Substitutions * > parent_subs, vector< GenericKey > generic={}, vector< unique_ptr< ty::Generic > > primary_generics={}) noexcept
 
auto ast () const noexcept -> const auto &
 
auto ast () noexcept -> auto &
 
auto body () const noexcept -> const auto &
 
auto body () noexcept -> auto &
 
auto get_self_ty () const noexcept -> optional< ty::Type >
 
auto get_subs () const -> const Substitutions &
 
auto get_subs () -> Substitutions &
 
auto has_annotation (const string &name) const -> bool
 
auto name () const noexcept -> string
 
auto get_or_create_instantiation (Substitutions &subs) noexcept -> std::pair< bool, Struct & >
 
auto create_instantiation (Substitutions &subs) noexcept -> Struct &
 

Public Attributes

ast::StructDeclst_ast
 
optional< ty::Typeself_ty {}
 The type of this struct. Used for the self type. More...
 
ast::Programmember {}
 The program this declaration is a member of. More...
 
vector< unique_ptr< ty::Generic > > primary_generics {}
 
Substitutions subs
 If this is an instantiation of a template, a mapping between type variables and their substitutions. More...
 
std::unordered_map< Substitutions, unique_ptr< Struct > > instantiations {}
 
std::vector< VTableEntryvtable_members {}
 
nullable< llvm::GlobalVariable * > vtable_memo {}
 

Detailed Description

A struct declaration in the compiler.

Very similar to Fn, the primary use of this structure is to bind together the AST declaration of a struct (ast::StructDecl) and the type this struct defines. A struct template may also be a Struct. All the instantiations of a template are stored in instantiations.

Definition at line 136 of file vals.hpp.

Constructor & Destructor Documentation

◆ Struct() [1/2]

yume::Struct::Struct ( ast::StructDecl ast_decl,
ast::Program member,
optional< ty::Type type,
Substitutions  subs 
)
inlinenoexcept

Definition at line 150 of file vals.hpp.

◆ Struct() [2/2]

yume::Struct::Struct ( ast::StructDecl ast_decl,
ast::Program member,
optional< ty::Type type,
nullable< Substitutions * >  parent_subs,
vector< GenericKey generic = {},
vector< unique_ptr< ty::Generic > >  primary_generics = {} 
)
inlinenoexcept

Definition at line 153 of file vals.hpp.

Member Function Documentation

◆ ast() [1/2]

auto yume::Struct::ast ( ) const -> const auto&
inlinenoexcept

Definition at line 158 of file vals.hpp.

References st_ast.

Referenced by yume::create_vtable_for(), and yume::Compiler::run().

◆ ast() [2/2]

auto yume::Struct::ast ( ) -> auto&
inlinenoexcept

Definition at line 159 of file vals.hpp.

References st_ast.

◆ body() [1/2]

auto yume::Struct::body ( ) const -> const auto&
inlinenoexcept

Definition at line 160 of file vals.hpp.

References yume::ast::StructDecl::body, and st_ast.

Referenced by create_instantiation(), and yume::create_vtable_for().

◆ body() [2/2]

auto yume::Struct::body ( ) -> auto&
inlinenoexcept

Definition at line 161 of file vals.hpp.

References yume::ast::StructDecl::body, and st_ast.

◆ create_instantiation()

auto yume::Struct::create_instantiation ( Substitutions subs) -> Struct&
noexcept

Definition at line 44 of file vals.cpp.

References body().

◆ get_or_create_instantiation()

auto yume::Struct::get_or_create_instantiation ( Substitutions subs) -> std::pair<bool, Struct&>
noexcept

Definition at line 56 of file vals.cpp.

◆ get_self_ty()

auto yume::Struct::get_self_ty ( ) const -> optional<ty::Type>
inlinenoexcept

Definition at line 162 of file vals.hpp.

References self_ty.

◆ get_subs() [1/2]

auto yume::Struct::get_subs ( ) -> Substitutions&
inline

Definition at line 164 of file vals.hpp.

References subs.

◆ get_subs() [2/2]

auto yume::Struct::get_subs ( ) const -> const Substitutions&
inline

Definition at line 163 of file vals.hpp.

References subs.

Referenced by yume::Compiler::create_struct(), and yume::Compiler::decl_statement().

◆ has_annotation()

auto yume::Struct::has_annotation ( const string &  name) const -> bool
inline

Definition at line 165 of file vals.hpp.

References yume::ast::StructDecl::annotations, name(), and st_ast.

Referenced by yume::Compiler::decl_statement().

◆ name()

auto yume::Struct::name ( ) const -> string
noexcept

Member Data Documentation

◆ instantiations

std::unordered_map<Substitutions, unique_ptr<Struct> > yume::Struct::instantiations {}

Definition at line 146 of file vals.hpp.

◆ member

ast::Program* yume::Struct::member {}

The program this declaration is a member of.

Definition at line 141 of file vals.hpp.

◆ primary_generics

vector<unique_ptr<ty::Generic> > yume::Struct::primary_generics {}

Definition at line 143 of file vals.hpp.

◆ self_ty

optional<ty::Type> yume::Struct::self_ty {}

The type of this struct. Used for the self type.

Definition at line 139 of file vals.hpp.

Referenced by yume::Compiler::create_struct(), yume::Compiler::decl_statement(), get_self_ty(), yume::Const::get_self_ty(), and yume::Const::referred_to_by().

◆ st_ast

ast::StructDecl& yume::Struct::st_ast

Definition at line 137 of file vals.hpp.

Referenced by ast(), body(), yume::Compiler::create_struct(), has_annotation(), and name().

◆ subs

Substitutions yume::Struct::subs

If this is an instantiation of a template, a mapping between type variables and their substitutions.

Definition at line 145 of file vals.hpp.

Referenced by yume::DeclLike::fully_substituted(), and get_subs().

◆ vtable_members

std::vector<VTableEntry> yume::Struct::vtable_members {}

Definition at line 147 of file vals.hpp.

Referenced by yume::create_vtable_for().

◆ vtable_memo

nullable<llvm::GlobalVariable*> yume::Struct::vtable_memo {}

Definition at line 148 of file vals.hpp.


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