From e1de8fc36f11ac932707c7113eb4bf3ebc4b1f74 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Sun, 3 Aug 2025 13:19:40 +0900 Subject: feat: support short type --- ast.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'ast.c') diff --git a/ast.c b/ast.c index 3bcc9c7..e1c9ba6 100644 --- a/ast.c +++ b/ast.c @@ -3,6 +3,7 @@ enum TypeKind { TypeKind_char, TypeKind_int, + TypeKind_short, TypeKind_long, TypeKind_void, TypeKind_ptr, @@ -70,6 +71,8 @@ int type_sizeof(Type* ty) { return 8; } else if (ty->kind == TypeKind_char) { return 1; + } else if (ty->kind == TypeKind_short) { + return 2; } else if (ty->kind == TypeKind_int) { return 4; } else if (ty->kind == TypeKind_long) { @@ -92,6 +95,8 @@ int type_alignof(Type* ty) { return 8; } else if (ty->kind == TypeKind_char) { return 1; + } else if (ty->kind == TypeKind_short) { + return 2; } else if (ty->kind == TypeKind_int) { return 4; } else if (ty->kind == TypeKind_long) { -- cgit v1.2.3-70-g09d2