aboutsummaryrefslogtreecommitdiff
path: root/src/types.h
diff options
context:
space:
mode:
authorMustafa Quraish <[email protected]>2022-02-02 17:19:15 -0500
committerMustafa Quraish <[email protected]>2022-02-02 17:54:31 -0500
commit55f61417c7d3f6a2f4685e21b7e409ec23b7f41f (patch)
treead5d78d16f3f66046bdac74c2eade63414e55c0c /src/types.h
parentFix examples to include return type on main function (diff)
downloadcup-55f61417c7d3f6a2f4685e21b7e409ec23b7f41f.tar.xz
cup-55f61417c7d3f6a2f4685e21b7e409ec23b7f41f.zip
Move type-related stuff to a separate file
It was getting a bit unwieldy in `parser.c`, and this will potentially help when we start dealing with more complex type-stuff such as casting / conversions / etc.
Diffstat (limited to 'src/types.h')
-rw-r--r--src/types.h26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/types.h b/src/types.h
new file mode 100644
index 0000000..5f6f45a
--- /dev/null
+++ b/src/types.h
@@ -0,0 +1,26 @@
+#pragma once
+
+#include "common.h"
+#include <stdio.h>
+
+typedef enum {
+ TYPE_NONE,
+ TYPE_INT,
+ TYPE_PTR,
+} DataType;
+
+typedef struct data_type_node {
+ DataType type;
+ struct data_type_node *ptr;
+} Type;
+
+Type *type_new(DataType type);
+i64 size_for_type(Type *type);
+bool type_equals(Type *a, Type *b);
+char *type_to_str(Type *type);
+
+// Type checking / casting expressions to right types
+typedef struct ast_node Node;
+
+Node *handle_unary_expr_types(Node *, Token *);
+Node *handle_binary_expr_types(Node *, Token *); \ No newline at end of file