hachem.wtf
aboutsummaryrefslogtreecommitdiff
path: root/eval.c
diff options
context:
space:
mode:
authorhachem <im@hachem.wtf>2026-09-19 16:15:50 +0200
committerhachem <im@hachem.wtf>2026-09-19 16:15:50 +0200
commit0a9605b6b13f2e066a69662f5802b397f8b89424 (patch)
treefe063a37fb8de67f3e176ec99cc4a1cc1cadf21d /eval.c
parentbe43ea893018090044cd411bc5b50787b99087b8 (diff)
feat: char and integral_constant types
Diffstat (limited to 'eval.c')
-rw-r--r--eval.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/eval.c b/eval.c
index 2f79a5d..170b122 100644
--- a/eval.c
+++ b/eval.c
@@ -130,6 +130,13 @@ static int evaluate_type(struct Machine* machine, const struct Node* node, struc
case TYPE_INT32: out->kind = KIND_INT32; return 0;
case TYPE_BYTE: out->kind = KIND_BYTE; return 0;
case TYPE_SIZE: out->kind = KIND_SIZE; return 0;
+ case TYPE_CHAR: out->kind = KIND_CHAR; return 0;
+ case TYPE_CHAR_CONSTANT:
+ if (evaluate_value(machine, node->first, &out->number))
+ return 1;
+
+ out->kind = KIND_CHAR_CONSTANT;
+ return 0;
case TYPE_REMOVE_CV: return evaluate_type(machine, node->first, out);
case TYPE_ARRAY:
if (evaluate_type(machine, node->first, &element) ||
@@ -248,6 +255,8 @@ static enum RunStatus emit(struct Machine* machine, const struct Node* node)
case KIND_BYTE: (void)printf("byte\n"); break;
case KIND_SIZE: (void)printf("size_t\n"); break;
case KIND_ARRAY: (void)printf("array[%" PRId64 "]\n", type.number); break;
+ case KIND_CHAR: (void)printf("char\n"); break;
+ case KIND_CHAR_CONSTANT: (void)printf("%c\n", (char)type.number); break;
case KIND_VALUE: (void)printf("%" PRId64 "\n", type.number); break;
}