aboutsummaryrefslogtreecommitdiffhomepage
path: root/ast.c
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2025-08-03 13:19:40 +0900
committernsfisis <nsfisis@gmail.com>2025-08-15 10:06:21 +0900
commite1de8fc36f11ac932707c7113eb4bf3ebc4b1f74 (patch)
tree65c0a362dc9343b09a6e452d5526e39da834b986 /ast.c
parent185778aa3ae35252ae992f12a9dfc39a4eab5758 (diff)
downloadducc-e1de8fc36f11ac932707c7113eb4bf3ebc4b1f74.tar.gz
ducc-e1de8fc36f11ac932707c7113eb4bf3ebc4b1f74.tar.zst
ducc-e1de8fc36f11ac932707c7113eb4bf3ebc4b1f74.zip
feat: support short type
Diffstat (limited to 'ast.c')
-rw-r--r--ast.c5
1 files changed, 5 insertions, 0 deletions
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) {