aboutsummaryrefslogtreecommitdiff
path: root/types.c
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2024-05-18 14:38:41 -0400
committerBruce Hill <bruce@bruce-hill.com>2024-05-18 14:38:41 -0400
commita1d18fd4225f67275ea4173532969e4ddf55b39f (patch)
tree6473f7cee0e829783bd64cc3d52af53f5089340f /types.c
parentee9a40f9102f12357e7a46c3b48a486c62c2311e (diff)
Add C string type
Diffstat (limited to 'types.c')
-rw-r--r--types.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/types.c b/types.c
index 1c1f4fd5..788eba4c 100644
--- a/types.c
+++ b/types.c
@@ -16,6 +16,7 @@ CORD type_to_cord(type_t *t) {
case VoidType: return "Void";
case MemoryType: return "Memory";
case BoolType: return "Bool";
+ case CStringType: return "CString";
case TextType: return Match(t, TextType)->lang ? Match(t, TextType)->lang : "Text";
case IntType: return Match(t, IntType)->bits == 64 ? "Int" : CORD_asprintf("Int%ld", Match(t, IntType)->bits);
case NumType: return Match(t, NumType)->bits == 64 ? "Num" : CORD_asprintf("Num%ld", Match(t, NumType)->bits);
@@ -398,6 +399,7 @@ size_t type_size(type_t *t)
case UnknownType: case AbortType: case VoidType: return 0;
case MemoryType: errx(1, "Memory has undefined type size");
case BoolType: return sizeof(bool);
+ case CStringType: return sizeof(char*);
case IntType: return Match(t, IntType)->bits/8;
case NumType: return Match(t, NumType)->bits/8;
case TextType: return sizeof(CORD);
@@ -449,6 +451,7 @@ size_t type_align(type_t *t)
case UnknownType: case AbortType: case VoidType: return 0;
case MemoryType: errx(1, "Memory has undefined type alignment");
case BoolType: return __alignof__(bool);
+ case CStringType: return __alignof__(char*);
case IntType: return Match(t, IntType)->bits/8;
case NumType: return Match(t, NumType)->bits/8;
case TextType: return __alignof__(CORD);