diff options
author | Himbeer <himbeer@disroot.org> | 2025-05-06 11:50:07 +0200 |
---|---|---|
committer | Himbeer <himbeer@disroot.org> | 2025-05-06 11:50:07 +0200 |
commit | bba151c9fa9a0a0c630577dc6e20cc8809a337d9 (patch) | |
tree | d74cbdec8e513d7794f2f96fa00296eca1725f6f /include/type.h | |
parent | b49e96941fb9f07426d49adeef50cd8c1716bf15 (diff) |
Simplify type system to primitives only
Diffstat (limited to 'include/type.h')
-rw-r--r-- | include/type.h | 95 |
1 files changed, 21 insertions, 74 deletions
diff --git a/include/type.h b/include/type.h index c8a6b76..d871106 100644 --- a/include/type.h +++ b/include/type.h @@ -10,87 +10,34 @@ #define PLATBITS 64 struct cer_int { - bool sign; - short bits; + int bits; + int issigned; }; struct cer_float { - bool is64; + int bits; }; -struct cer_array { - struct type *member_type; - struct disjunction_e *length; -}; - -struct field { - const char *name; - struct type *type; -}; - -struct cer_struct { - struct field *fields; - int fieldsz, fieldlen; -}; - -struct variant { - const char *name; - uint64_t tag; -}; - -struct cer_enum { - struct type *tag_type; - struct variant *variants; - int variantsz, variantlen; -}; - -struct cer_union { - struct type *tag_type; - struct type *alts; - int altsz, altlen; -}; - -enum type_kind { - TYP_ARRAY, - TYP_BOOL, - TYP_ENUM, - TYP_FALLIBLE, - TYP_FLOAT, - TYP_INT, - TYP_OPTIONAL, - TYP_PATH, - TYP_POINTER, - TYP_SLICE, - TYP_STRUCT, - TYP_UNION, -}; - -union type_desc { - struct cer_int i; - struct cer_float f; - struct cer_array array; - struct cer_struct s; - struct cer_enum en; - struct cer_union un; - struct type *inner; - struct path path; +enum typekind { + TK_INT, + TK_FLOAT, + TK_BOOL, }; struct type { - enum type_kind kind; - union type_desc desc; -}; - -/** - * Builtin types - */ - -extern const struct cer_int int8_b, uint8_b; -extern const struct cer_int int16_b, uint16_b; -extern const struct cer_int int32_b, uint32_b; -extern const struct cer_int int64_b, uint64_b; -extern const struct cer_int int_b, uint_b; - -extern const struct cer_float float32_b, float64_b; + enum typekind kind; + union { + struct cer_int i; + struct cer_float fp; + } desc; +}; + +extern const struct cer_int cer_int8_t, cer_uint8_t; +extern const struct cer_int cer_int16_t, cer_uint16_t; +extern const struct cer_int cer_int32_t, cer_uint32_t; +extern const struct cer_int cer_int64_t, cer_uint64_t; +extern const struct cer_int cer_int_t, cer_uint_t; +extern const struct cer_float cer_float32_t; +extern const struct cer_float cer_float64_t; #endif |