From 4f9d0247549b06ddb25b76bb425541190105cb48 Mon Sep 17 00:00:00 2001 From: Carson Fleming Date: Sun, 26 Jul 2026 19:20:30 -0700 Subject: functioning type system perhaps? --- type.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 type.c (limited to 'type.c') diff --git a/type.c b/type.c new file mode 100644 index 0000000..c5f6e65 --- /dev/null +++ b/type.c @@ -0,0 +1,52 @@ +#include "type.h" +#include + +const struct data_type void_type = { + .name = "void", + .sz = 0, + .is_floating = false, +}; +const struct data_type char_type = { + .name = "char", + .sz = 1, + .is_floating = false, +}; +const struct data_type short_type = { + .name = "short", + .sz = 2, + .is_floating = false, +}; +const struct data_type int_type = { + .name = "int", + .sz = 4, + .is_floating = false, +}; +const struct data_type long_type = { + .name = "long", + .sz = 8, + .is_floating = false, +}; +const struct data_type long_long_type = { + .name = "long long", + .sz = 8, + .is_floating = false, +}; +const struct data_type float_type = { + .name = "float", + .sz = 4, + .is_floating = true, +}; +const struct data_type double_type = { + .name = "double", + .sz = 8, + .is_floating = true, +}; + +const struct data_type* integral_type = &long_type; +const struct data_type* floating_type = &double_type; +const struct data_type* character_type = &char_type; +const struct data_type* primitive_types[] = { + &void_type, &char_type, &short_type, &int_type, &long_type, &long_long_type, + &float_type, &double_type, + NULL +}; -- cgit v1.2.3