From 55f61417c7d3f6a2f4685e21b7e409ec23b7f41f Mon Sep 17 00:00:00 2001 From: Mustafa Quraish Date: Wed, 2 Feb 2022 17:19:15 -0500 Subject: 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. --- src/types.h | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 src/types.h (limited to 'src/types.h') 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 + +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 -- cgit v1.2.3