Yume
type_holder.hpp
Go to the documentation of this file.
1#pragma once
2
3#include "ty/type.hpp"
4#include <array>
5#include <llvm/ADT/StringMap.h>
6#include <memory>
7#include <vector>
8
9namespace yume {
10class Compiler;
11struct TypeHolder {
12 struct IntTypePair {
15 };
16
17 array<IntTypePair, 4> int_types{};
21 llvm::StringMap<unique_ptr<ty::BaseType>> known{};
22 std::vector<unique_ptr<ty::Function>> fn_types{};
23
24 TypeHolder();
25
27
28 constexpr auto int8() -> IntTypePair { return int_types[0]; }
29 constexpr auto int16() -> IntTypePair { return int_types[1]; }
30 constexpr auto int32() -> IntTypePair { return int_types[2]; }
31 constexpr auto int64() -> IntTypePair { return int_types[3]; }
32
33 auto find_or_create_fn_type(const vector<ty::Type>& args, optional<ty::Type> ret, const vector<ty::Type>& closure)
34 -> ty::Function*;
35 auto find_or_create_fn_ptr_type(const vector<ty::Type>& args, optional<ty::Type> ret, bool c_varargs = false)
36 -> ty::Function*;
37};
38} // namespace yume
The Compiler the the primary top-level type during compilation. A single instance is created during t...
Definition: compiler.hpp:45
A function pointer type.
Definition: type.hpp:129
A built-in integral type, such as I32 or Bool.
Definition: type.hpp:35
The null type, Nil.
Definition: type.hpp:49
Definition: ast.cpp:8
constexpr auto int8() -> IntTypePair
Definition: type_holder.hpp:28
constexpr auto int64() -> IntTypePair
Definition: type_holder.hpp:31
void declare_size_type(Compiler &)
Definition: type_holder.cpp:33
ty::Int * bool_type
Definition: type_holder.hpp:18
auto find_or_create_fn_ptr_type(const vector< ty::Type > &args, optional< ty::Type > ret, bool c_varargs=false) -> ty::Function *
Definition: type_holder.cpp:53
llvm::StringMap< unique_ptr< ty::BaseType > > known
Definition: type_holder.hpp:21
constexpr auto int16() -> IntTypePair
Definition: type_holder.hpp:29
auto find_or_create_fn_type(const vector< ty::Type > &args, optional< ty::Type > ret, const vector< ty::Type > &closure) -> ty::Function *
Definition: type_holder.cpp:43
IntTypePair size_type
Definition: type_holder.hpp:19
array< IntTypePair, 4 > int_types
Definition: type_holder.hpp:17
ty::Nil * nil_type
Definition: type_holder.hpp:20
constexpr auto int32() -> IntTypePair
Definition: type_holder.hpp:30
std::vector< unique_ptr< ty::Function > > fn_types
Definition: type_holder.hpp:22