Yume
Public Member Functions | List of all members
yume::Compiler Class Reference

The Compiler the the primary top-level type during compilation. A single instance is created during the compilation process. More...

#include <compiler.hpp>

Inheritance diagram for yume::Compiler:
Inheritance graph
[legend]
Collaboration diagram for yume::Compiler:
Collaboration graph
[legend]

Public Member Functions

auto module () const -> const auto &
 
auto context () const -> const auto &
 
auto builder () const -> const auto &
 
 Compiler (const optional< string > &target_triple, vector< SourceFile > source_files)
 
void run ()
 Begin compilation! More...
 
auto declare (Fn &) -> llvm::Function *
 Declare a function/constructor in bytecode, or get an existing declaration. More...
 
auto create_struct (Struct &) -> bool
 
void define (Fn &)
 Compile the body of a function or constructor. More...
 
void define (Const &)
 
void body_statement (ast::Stmt &)
 
auto decl_statement (ast::Stmt &, optional< ty::Type > parent=std::nullopt, ast::Program *member=nullptr, nullable< Substitutions * > parent_subs=nullptr) -> DeclLike
 
auto body_expression (ast::Expr &expr) -> Val
 
auto direct_call_operator (ast::CallExpr &expr) -> Val
 
void write_object (const char *filename, bool binary)
 
auto llvm_type (ty::Type type, bool erase_opaque=false) -> llvm::Type *
 Convert a type into its corresponding LLVM type. More...
 
auto ptr_bitsize () -> unsigned int
 
auto default_init (ty::Type type) -> Val
 Default-constructs an object of specified type type. More...
 
void destruct (Val val, ty::Type type)
 Destructs an object val of specified type type. More...
 
auto source_files () -> const auto &
 
template<>
void statement (ast::Compound &stat)
 
template<>
void statement (ast::WhileStmt &stat)
 
template<>
void statement (ast::IfStmt &stat)
 
template<>
void statement (ast::ReturnStmt &stat)
 
template<>
void statement (ast::VarDecl &stat)
 
template<>
auto expression (ast::NumberExpr &expr) -> Val
 
template<>
auto expression (ast::CharExpr &expr) -> Val
 
template<>
auto expression (ast::BoolExpr &expr) -> Val
 
template<>
auto expression (ast::StringExpr &expr) -> Val
 
template<>
auto expression (ast::VarExpr &expr) -> Val
 
template<>
auto expression (ast::ConstExpr &expr) -> Val
 
template<>
auto expression (ast::CallExpr &expr) -> Val
 
template<>
auto expression (ast::BinaryLogicExpr &expr) -> Val
 
template<>
auto expression (ast::AssignExpr &expr) -> Val
 
template<>
auto expression (ast::LambdaExpr &expr) -> Val
 
template<>
auto expression (ast::CtorExpr &expr) -> Val
 
template<>
auto expression (ast::SliceExpr &expr) -> Val
 
template<>
auto expression (ast::FieldAccessExpr &expr) -> Val
 
template<>
auto expression (ast::ImplicitCastExpr &expr) -> Val
 
template<>
auto expression (ast::TypeExpr &expr) -> Val
 
- Public Member Functions inherited from yume::CRTPWalker< Compiler >
auto body_statement (ast::Stmt &stat, auto &&... args)
 
auto body_expression (ast::Expr &expr, auto &&... args)
 

Detailed Description

The Compiler the the primary top-level type during compilation. A single instance is created during the compilation process.

Definition at line 45 of file compiler.hpp.

Constructor & Destructor Documentation

◆ Compiler()

yume::Compiler::Compiler ( const optional< string > &  target_triple,
vector< SourceFile source_files 
)

Definition at line 88 of file compiler.cpp.

References yume::TypeHolder::declare_size_type(), and yume::make_cdtor_fn().

Member Function Documentation

◆ body_expression()

auto yume::Compiler::body_expression ( ast::Expr expr) -> Val

Definition at line 1632 of file compiler.cpp.

References yume::CRTPWalker< Derived >::body_expression().

Referenced by define(), and statement().

◆ body_statement()

void yume::Compiler::body_statement ( ast::Stmt stat)

Definition at line 1626 of file compiler.cpp.

References yume::CRTPWalker< Derived >::body_statement(), and yume::ast::AST::kind_name().

Referenced by statement().

◆ builder()

auto yume::Compiler::builder ( ) const -> const auto&
inline

Definition at line 82 of file compiler.hpp.

Referenced by yume::destruct_indirect().

◆ context()

auto yume::Compiler::context ( ) const -> const auto&
inline

Definition at line 81 of file compiler.hpp.

◆ create_struct()

auto yume::Compiler::create_struct ( Struct st) -> bool

◆ decl_statement()

auto yume::Compiler::decl_statement ( ast::Stmt stmt,
optional< ty::Type parent = std::nullopt,
ast::Program member = nullptr,
nullable< Substitutions * >  parent_subs = nullptr 
) -> DeclLike

◆ declare()

auto yume::Compiler::declare ( Fn fn) -> llvm::Function*

◆ default_init()

auto yume::Compiler::default_init ( ty::Type  type) -> Val

Default-constructs an object of specified type type.

Definition at line 518 of file compiler.cpp.

References yume::Ptr.

◆ define() [1/2]

void yume::Compiler::define ( Const cn)

◆ define() [2/2]

void yume::Compiler::define ( Fn fn)

◆ destruct()

void yume::Compiler::destruct ( Val  val,
ty::Type  type 
)

◆ direct_call_operator()

auto yume::Compiler::direct_call_operator ( ast::CallExpr expr) -> Val

Definition at line 1259 of file compiler.cpp.

References YUME_ASSERT.

◆ expression() [1/15]

template<>
auto yume::Compiler::expression ( ast::AssignExpr expr) -> Val

Definition at line 1134 of file compiler.cpp.

References yume::destruct_indirect(), and YUME_ASSERT.

◆ expression() [2/15]

template<>
auto yume::Compiler::expression ( ast::BinaryLogicExpr expr) -> Val

Definition at line 1110 of file compiler.cpp.

◆ expression() [3/15]

template<>
auto yume::Compiler::expression ( ast::BoolExpr expr) -> Val

Definition at line 905 of file compiler.cpp.

◆ expression() [4/15]

template<>
auto yume::Compiler::expression ( ast::CallExpr expr) -> Val

Definition at line 1076 of file compiler.cpp.

References yume::vals_to_llvm().

◆ expression() [5/15]

template<>
auto yume::Compiler::expression ( ast::CharExpr expr) -> Val

Definition at line 903 of file compiler.cpp.

◆ expression() [6/15]

template<>
auto yume::Compiler::expression ( ast::ConstExpr expr) -> Val

Definition at line 974 of file compiler.cpp.

◆ expression() [7/15]

template<>
auto yume::Compiler::expression ( ast::CtorExpr expr) -> Val

Definition at line 1286 of file compiler.cpp.

References yume::ty::Int::is_signed(), and YUME_ASSERT.

◆ expression() [8/15]

template<>
auto yume::Compiler::expression ( ast::FieldAccessExpr expr) -> Val

Definition at line 1443 of file compiler.cpp.

References YUME_ASSERT.

◆ expression() [9/15]

template<>
auto yume::Compiler::expression ( ast::ImplicitCastExpr expr) -> Val

◆ expression() [10/15]

template<>
auto yume::Compiler::expression ( ast::LambdaExpr expr) -> Val

◆ expression() [11/15]

template<>
auto yume::Compiler::expression ( ast::NumberExpr expr) -> Val

Definition at line 896 of file compiler.cpp.

◆ expression() [12/15]

template<>
auto yume::Compiler::expression ( ast::SliceExpr expr) -> Val

Definition at line 1410 of file compiler.cpp.

References YUME_ASSERT.

◆ expression() [13/15]

template<>
auto yume::Compiler::expression ( ast::StringExpr expr) -> Val

Definition at line 933 of file compiler.cpp.

◆ expression() [14/15]

template<>
auto yume::Compiler::expression ( ast::TypeExpr expr) -> Val

Definition at line 1606 of file compiler.cpp.

References YUME_ASSERT.

◆ expression() [15/15]

template<>
auto yume::Compiler::expression ( ast::VarExpr expr) -> Val

Definition at line 963 of file compiler.cpp.

References yume::Val::llvm, and YUME_ASSERT.

◆ llvm_type()

auto yume::Compiler::llvm_type ( ty::Type  type,
bool  erase_opaque = false 
) -> llvm::Type*

Convert a type into its corresponding LLVM type.

Definition at line 429 of file compiler.cpp.

References yume::build_function_type(), yume::build_struct_type(), yume::Ptr, and YUME_ASSERT.

Referenced by define(), destruct(), yume::destruct_indirect(), run(), and statement().

◆ module()

auto yume::Compiler::module ( ) const -> const auto&
inline

Definition at line 80 of file compiler.hpp.

◆ ptr_bitsize()

auto yume::Compiler::ptr_bitsize ( ) -> unsigned int

Definition at line 1369 of file compiler.cpp.

Referenced by yume::TypeHolder::declare_size_type(), and destruct().

◆ run()

void yume::Compiler::run ( )

◆ source_files()

auto yume::Compiler::source_files ( ) -> const auto&
inline

Definition at line 115 of file compiler.hpp.

◆ statement() [1/5]

template<>
void yume::Compiler::statement ( ast::Compound stat)

Definition at line 593 of file compiler.cpp.

References body_statement().

◆ statement() [2/5]

template<>
void yume::Compiler::statement ( ast::IfStmt stat)

◆ statement() [3/5]

template<>
void yume::Compiler::statement ( ast::ReturnStmt stat)

◆ statement() [4/5]

template<>
void yume::Compiler::statement ( ast::VarDecl stat)

◆ statement() [5/5]

template<>
void yume::Compiler::statement ( ast::WhileStmt stat)

◆ write_object()

void yume::Compiler::write_object ( const char *  filename,
bool  binary 
)

Definition at line 1611 of file compiler.cpp.

References yume::open_file().


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