|
Yume
|
The Compiler the the primary top-level type during compilation. A single instance is created during the compilation process.
More...
#include <compiler.hpp>


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) |
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.
| 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().
Definition at line 1632 of file compiler.cpp.
References yume::CRTPWalker< Derived >::body_expression().
Referenced by define(), and 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().
|
inline |
Definition at line 82 of file compiler.hpp.
Referenced by yume::destruct_indirect().
|
inline |
Definition at line 81 of file compiler.hpp.
| auto yume::Compiler::create_struct | ( | Struct & | st | ) | -> bool |
Definition at line 277 of file compiler.cpp.
References yume::Struct::get_subs(), yume::Struct::self_ty, yume::Struct::st_ast, and YUME_ASSERT.
| auto yume::Compiler::decl_statement | ( | ast::Stmt & | stmt, |
| optional< ty::Type > | parent = std::nullopt, |
||
| ast::Program * | member = nullptr, |
||
| nullable< Substitutions * > | parent_subs = nullptr |
||
| ) | -> DeclLike |
Definition at line 305 of file compiler.cpp.
References yume::ast::StructDecl::BUILTIN_TYPE_SLICE, yume::Struct::get_subs(), yume::Struct::has_annotation(), yume::Struct::self_ty, and YUME_ASSERT.
Referenced by run().
| auto yume::Compiler::declare | ( | Fn & | fn | ) | -> llvm::Function* |
Declare a function/constructor in bytecode, or get an existing declaration.
Definition at line 544 of file compiler.cpp.
References yume::Fn::arg_names(), yume::Fn::ast(), yume::ty::Function::closure_memo(), yume::Fn::extern_decl(), yume::Fn::extern_linkage(), yume::ty::Function::fn_memo(), yume::Fn::fn_ty, yume::Fn::has_annotation(), yume::Fn::llvm, yume::Fn::local(), yume::mangle::mangle_name(), yume::Fn::member, yume::Fn::name(), yume::Fn::primitive(), and YUME_ASSERT.
Referenced by yume::semantic::TypeWalker::resolve_queue(), and run().
Default-constructs an object of specified type type.
Definition at line 518 of file compiler.cpp.
References yume::Ptr.
| void yume::Compiler::define | ( | Const & | cn | ) |
Definition at line 654 of file compiler.cpp.
References yume::Const::ast(), body_expression(), destruct(), yume::Const::llvm, and llvm_type().
| void yume::Compiler::define | ( | Fn & | fn | ) |
Compile the body of a function or constructor.
Definition at line 683 of file compiler.cpp.
References yume::Fn::abstract(), yume::Fn::ast(), yume::Fn::compound_body(), end, yume::Fn::fn_body(), yume::Fn::llvm, yume::Val::llvm, llvm_type(), yume::Fn::self_ty, yume::InScope::value, yume::vtable_entry_for(), and YUME_ASSERT.
Referenced by run().
Destructs an object val of specified type type.
Definition at line 472 of file compiler.cpp.
References yume::ty::Type::base_cast(), yume::ty::Type::base_dyn_cast(), destruct(), yume::ty::Type::is_mut(), yume::ty::Type::is_slice(), yume::ty::Type::is_trivially_destructible(), llvm_type(), yume::ty::Type::mut_base(), and ptr_bitsize().
Referenced by define(), destruct(), and yume::destruct_indirect().
| auto yume::Compiler::direct_call_operator | ( | ast::CallExpr & | expr | ) | -> Val |
Definition at line 1259 of file compiler.cpp.
References YUME_ASSERT.
| auto yume::Compiler::expression | ( | ast::AssignExpr & | expr | ) | -> Val |
Definition at line 1134 of file compiler.cpp.
References yume::destruct_indirect(), and YUME_ASSERT.
| auto yume::Compiler::expression | ( | ast::BinaryLogicExpr & | expr | ) | -> Val |
Definition at line 1110 of file compiler.cpp.
| auto yume::Compiler::expression | ( | ast::BoolExpr & | expr | ) | -> Val |
Definition at line 905 of file compiler.cpp.
| auto yume::Compiler::expression | ( | ast::CallExpr & | expr | ) | -> Val |
Definition at line 1076 of file compiler.cpp.
References yume::vals_to_llvm().
| auto yume::Compiler::expression | ( | ast::CharExpr & | expr | ) | -> Val |
Definition at line 903 of file compiler.cpp.
| auto yume::Compiler::expression | ( | ast::ConstExpr & | expr | ) | -> Val |
Definition at line 974 of file compiler.cpp.
| 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.
| auto yume::Compiler::expression | ( | ast::FieldAccessExpr & | expr | ) | -> Val |
Definition at line 1443 of file compiler.cpp.
References YUME_ASSERT.
| auto yume::Compiler::expression | ( | ast::ImplicitCastExpr & | expr | ) | -> Val |
Definition at line 1522 of file compiler.cpp.
References yume::ty::Struct::decl(), yume::Fn::fn_ty, yume::ty::Struct::is_interface(), yume::ty::Int::is_signed(), yume::Val::llvm, yume::InScope::owning, yume::Val::scope, and YUME_ASSERT.
| auto yume::Compiler::expression | ( | ast::LambdaExpr & | expr | ) | -> Val |
Definition at line 1198 of file compiler.cpp.
References yume::ast::AST::ensure_ty(), yume::Val::llvm, yume::Fn::member, and YUME_ASSERT.
| auto yume::Compiler::expression | ( | ast::NumberExpr & | expr | ) | -> Val |
Definition at line 896 of file compiler.cpp.
| auto yume::Compiler::expression | ( | ast::SliceExpr & | expr | ) | -> Val |
Definition at line 1410 of file compiler.cpp.
References YUME_ASSERT.
| auto yume::Compiler::expression | ( | ast::StringExpr & | expr | ) | -> Val |
Definition at line 933 of file compiler.cpp.
| auto yume::Compiler::expression | ( | ast::TypeExpr & | expr | ) | -> Val |
Definition at line 1606 of file compiler.cpp.
References YUME_ASSERT.
| auto yume::Compiler::expression | ( | ast::VarExpr & | expr | ) | -> Val |
Definition at line 963 of file compiler.cpp.
References yume::Val::llvm, and YUME_ASSERT.
| 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().
|
inline |
Definition at line 80 of file compiler.hpp.
| auto yume::Compiler::ptr_bitsize | ( | ) | -> unsigned int |
Definition at line 1369 of file compiler.cpp.
Referenced by yume::TypeHolder::declare_size_type(), and destruct().
| void yume::Compiler::run | ( | ) |
Begin compilation!
Definition at line 180 of file compiler.cpp.
References yume::Struct::ast(), yume::create_vtable_for(), decl_statement(), declare(), define(), yume::Fn::extern_decl(), yume::Fn::extern_linkage(), llvm_type(), yume::Fn::make_extern_linkage(), yume::Fn::name(), and YUME_ASSERT.
Referenced by compile().
|
inline |
Definition at line 115 of file compiler.hpp.
| void yume::Compiler::statement | ( | ast::Compound & | stat | ) |
Definition at line 593 of file compiler.cpp.
References body_statement().
| void yume::Compiler::statement | ( | ast::IfStmt & | stat | ) |
Definition at line 778 of file compiler.cpp.
References body_expression(), yume::ast::IfStmt::clauses, yume::ast::IfStmt::else_clause, and yume::Fn::llvm.
| void yume::Compiler::statement | ( | ast::ReturnStmt & | stat | ) |
Definition at line 823 of file compiler.cpp.
References body_expression(), yume::ast::ReturnStmt::expr, yume::ast::ReturnStmt::extends_lifetime, yume::ast::OptionalAnyBase< T >::has_value(), yume::Fn::llvm, yume::InScope::owning, and yume::ast::OptionalAnyBase< T >::raw_ptr().
| void yume::Compiler::statement | ( | ast::VarDecl & | stat | ) |
Definition at line 874 of file compiler.cpp.
References body_expression(), yume::ast::AST::ensure_ty(), yume::ast::VarDecl::init, llvm_type(), and yume::ast::VarDecl::name.
| void yume::Compiler::statement | ( | ast::WhileStmt & | stat | ) |
Definition at line 764 of file compiler.cpp.
References yume::ast::WhileStmt::body, body_expression(), body_statement(), yume::ast::WhileStmt::cond, and yume::Fn::llvm.
| void yume::Compiler::write_object | ( | const char * | filename, |
| bool | binary | ||
| ) |
Definition at line 1611 of file compiler.cpp.
References yume::open_file().