aboutsummaryrefslogtreecommitdiff
path: root/src/types.h
diff options
context:
space:
mode:
authorMustafa Quraish <[email protected]>2022-02-02 23:49:46 -0500
committerMustafa Quraish <[email protected]>2022-02-02 23:49:46 -0500
commit3f083b4286d8e2ed990d72f61febb7f5f4f96626 (patch)
tree553680d0ed918853d06e7843f6c40bcb54e911fa /src/types.h
parentRemove default initialization to 0 for variable declarations (diff)
downloadcup-3f083b4286d8e2ed990d72f61febb7f5f4f96626.tar.xz
cup-3f083b4286d8e2ed990d72f61febb7f5f4f96626.zip
Add support for `char` type + string/char literals
This commit does a few things in one go: - Add support for a `char` type + some changes to support the new size - Add support for character literals. We need some escaping here to be able to use `\n` and `\0`, etc. - Add support for string literals. These are all stored in the `.data` section. Fortunately NASM already handles the escape characters. - Fix some bugs with code generation, specifically using `movsx` to sign extend the smaller types into 64-bit registers.
Diffstat (limited to 'src/types.h')
-rw-r--r--src/types.h6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/types.h b/src/types.h
index 8bbf4e3..7aadd8d 100644
--- a/src/types.h
+++ b/src/types.h
@@ -5,7 +5,9 @@
typedef enum {
TYPE_NONE,
+ TYPE_ANY, // This is a hack for builtins till we can cast types
TYPE_INT,
+ TYPE_CHAR,
TYPE_PTR,
TYPE_ARRAY,
} DataType;
@@ -18,9 +20,11 @@ typedef struct data_type_node {
Type *type_new(DataType type);
i64 size_for_type(Type *type);
-bool type_equals(Type *a, Type *b);
char *type_to_str(Type *type);
+bool type_equals(Type *a, Type *b);
+bool is_string_type(Type *type);
+
// Type checking / casting expressions to right types
typedef struct ast_node Node;