summaryrefslogtreecommitdiff
path: root/src/hir/type.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/hir/type.hpp')
-rw-r--r--src/hir/type.hpp47
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 _);
};