From b8eb76ef8efb2b000cb53d4d92d0c0df509cbdb8 Mon Sep 17 00:00:00 2001 From: Kimplul Date: Sun, 18 Feb 2024 23:05:50 +0200 Subject: implement some basic generic features --- include/ek/ast.h | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/ek/ast.h b/include/ek/ast.h index 211a6a0..ab727eb 100644 --- a/include/ek/ast.h +++ b/include/ek/ast.h @@ -542,7 +542,7 @@ struct ast_return { }; enum ast_primitive { - AST_VOID, AST_I9, AST_I27 + AST_VOID, AST_BOOL, AST_I9, AST_I27, AST_STR }; /** @@ -579,6 +579,8 @@ struct ast_type { struct { enum ast_primitive type; + struct ast_node *def; // for possible user defined + // member functions } _primitive; /** Array type. */ @@ -1013,7 +1015,7 @@ struct ast_node *gen_switch(struct ast_node *cond, struct ast_node *cases, struc */ struct ast_node *gen_case(struct ast_node *expr, struct ast_node *body, struct src_loc loc); -struct ast_node *gen_primitive(enum ast_primitive type, struct src_loc loc); +struct ast_node *gen_primitive(enum ast_primitive type, struct ast_node *def, struct src_loc loc); /** * Generate Ek type (besides primitive). * @@ -1315,4 +1317,7 @@ int same_id(struct ast_node *id1, struct ast_node *id2); int equiv_nodes(struct ast_node *n1, struct ast_node *n2); int equiv_node_chains(struct ast_node *c1, struct ast_node *c2); +#define foreach_node(iter, nodes)\ + for (struct ast_node *iter = nodes; iter; iter = iter->next) + #endif /* AST_H */ -- cgit v1.3