diff options
author | John Hodge <tpg@mutabah.net> | 2016-05-14 15:06:25 +0800 |
---|---|---|
committer | John Hodge <tpg@mutabah.net> | 2016-05-14 15:06:25 +0800 |
commit | d70587b729f9f982e284681d5d16794cf7209e28 (patch) | |
tree | d1c539d2bd6d226dea5a7240734e6e495932e272 /src/hir/type.hpp | |
parent | f043a45fd21bab906cafc8964a892a64def65ec9 (diff) | |
download | mrust-d70587b729f9f982e284681d5d16794cf7209e28.tar.gz |
HIR - Boilerplate code, compiles
Diffstat (limited to 'src/hir/type.hpp')
-rw-r--r-- | src/hir/type.hpp | 47 |
1 files changed, 45 insertions, 2 deletions
diff --git a/src/hir/type.hpp b/src/hir/type.hpp index e0023188..7e09a687 100644 --- a/src/hir/type.hpp +++ b/src/hir/type.hpp @@ -3,11 +3,32 @@ #define _HIR_TYPE_HPP_ #pragma once +#include <tagged_union.hpp> #include <hir/path.hpp> +#include <hir/expr_ptr.hpp> namespace HIR { -class TypeRef +enum class CoreType +{ + Usize, Isize, + U8, I8, + U16, I16, + U32, I32, + U64, I64, + + F32, F64, + + Char, Str, +}; +enum class BorrowType +{ + Shared, + Unique, + Owned, +}; + +struct TypeRef { // Options: // - Primitive @@ -18,7 +39,29 @@ class TypeRef // - Tuple // - Borrow // - Pointer -public: + + TAGGED_UNION(Data, Infer, + (Infer, struct {}), + (Primitive, ::HIR::CoreType), + (Path, ::HIR::Path), + (Array, struct { + ::std::unique_ptr<TypeRef> inner; + ::HIR::ExprPtr size; + }), + (Tuple, ::std::vector<TypeRef>), + (Borrow, struct { + ::HIR::BorrowType type; + ::std::unique_ptr<TypeRef> inner; + }), + (Pointer, struct { + bool is_mut; + ::std::unique_ptr<TypeRef> inner; + }) + ); + + Data type; + + TypeRef(::HIR::Path _); }; |