From e2dbc82213a6e5da74de2220eeeab78da41fb519 Mon Sep 17 00:00:00 2001 From: Mustafa Quraish Date: Wed, 2 Feb 2022 19:22:15 -0500 Subject: Add initial support for arrays (also no testing) Usual disclaimer at this point: Quick&Dirty implementation, hasn't been tested other than basic sanity checks. Arrays are automatically decayed into pointers when the identifier is accessed. --- src/types.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/types.h') diff --git a/src/types.h b/src/types.h index 5f6f45a..8bbf4e3 100644 --- a/src/types.h +++ b/src/types.h @@ -7,11 +7,13 @@ typedef enum { TYPE_NONE, TYPE_INT, TYPE_PTR, + TYPE_ARRAY, } DataType; typedef struct data_type_node { DataType type; struct data_type_node *ptr; + i64 array_size; } Type; Type *type_new(DataType type); @@ -23,4 +25,6 @@ char *type_to_str(Type *type); 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 +Node *handle_binary_expr_types(Node *, Token *); + +Node *decay_array_to_pointer(Node *, Token *); \ No newline at end of file -- cgit v1.2.3