lang: ast: move recipient tracking from msg handler node to selector node

This commit is contained in:
2024-11-28 16:58:01 +00:00
parent 4304b94491
commit 2a33ae44a5
4 changed files with 131 additions and 13 deletions

View File

@@ -41,9 +41,8 @@ static struct token_parse_result parse_plus(
struct parser_state *msgh_state = parser_get_state_generic(ctx);
struct ivy_ast_msgh_node *msgh
= (struct ivy_ast_msgh_node *)msgh_state->s_node;
msgh->n_recipient = IVY_AST_MSGH_CLASS;
return PARSE_RESULT(IVY_OK, 0);
return PARSE_RESULT(IVY_OK, PARSE_REPEAT_TOKEN);
}
static struct token_parse_result parse_hyphen(
@@ -60,9 +59,8 @@ static struct token_parse_result parse_hyphen(
struct parser_state *msgh_state = parser_get_state_generic(ctx);
struct ivy_ast_msgh_node *msgh
= (struct ivy_ast_msgh_node *)msgh_state->s_node;
msgh->n_recipient = IVY_AST_MSGH_OBJECT;
return PARSE_RESULT(IVY_OK, 0);
return PARSE_RESULT(IVY_OK, PARSE_REPEAT_TOKEN);
}
static struct token_parse_result parse_ident(
@@ -157,10 +155,29 @@ static void init_state(struct ivy_parser *ctx, struct parser_state *sp)
state->s_current_area = AREA_IDENT;
}
static void collect_children(
struct ivy_ast_node *node, struct ivy_ast_node_iterator *iterator)
{
struct ivy_ast_class_node *c = (struct ivy_ast_class_node *)node;
b_queue_iterator it = {0};
b_queue_foreach (&it, &c->n_properties) {
struct ivy_ast_node *child
= b_unbox(struct ivy_ast_node, it.entry, n_entry);
ast_node_iterator_enqueue_node(iterator, node, child);
}
b_queue_foreach (&it, &c->n_msg_handlers) {
struct ivy_ast_node *child
= b_unbox(struct ivy_ast_node, it.entry, n_entry);
ast_node_iterator_enqueue_node(iterator, node, child);
}
}
struct ast_node_type class_node_ops = {
.n_add_child = add_child,
.n_print = print,
.n_init_state = init_state,
.n_collect_children = collect_children,
.n_state_size = sizeof(struct class_parser_state),
.n_node_size = sizeof(struct ivy_ast_class_node),
.n_symbol_parsers = {