lang: ast: add state size to ast_node_type
This commit is contained in:
@@ -18,8 +18,7 @@ enum ivy_status ivy_parser_create(struct ivy_parser **parser)
|
||||
|
||||
memset(out, 0x0, sizeof *out);
|
||||
|
||||
parser_push_state(
|
||||
out, IVY_AST_UNIT, struct ivy_ast_unit_node, struct parser_state);
|
||||
parser_push_state( out, IVY_AST_UNIT, struct ivy_ast_unit_node);
|
||||
|
||||
*parser = out;
|
||||
return IVY_OK;
|
||||
@@ -67,14 +66,19 @@ struct parser_state *parser_get_state_generic(struct ivy_parser *parser)
|
||||
|
||||
struct parser_state *parser_push_state_generic(
|
||||
struct ivy_parser *parser, enum ivy_ast_node_type type,
|
||||
size_t node_size, size_t state_size)
|
||||
size_t node_size)
|
||||
{
|
||||
struct parser_state *state = malloc(state_size);
|
||||
const struct ast_node_type *node_type = get_ast_node_type(type);
|
||||
if (!node_type) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
struct parser_state *state = malloc(node_type->n_state_size);
|
||||
if (!state) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
memset(state, 0x0, state_size);
|
||||
memset(state, 0x0, node_type->n_state_size);
|
||||
|
||||
b_queue_entry *current_state_entry = b_queue_last(&parser->p_state);
|
||||
if (current_state_entry) {
|
||||
@@ -85,8 +89,7 @@ struct parser_state *parser_push_state_generic(
|
||||
|
||||
state->s_node = ast_node_create_with_size(type, node_size);
|
||||
|
||||
const struct ast_node_type *node_type = get_ast_node_type(type);
|
||||
if (node_type && node_type->n_init_state) {
|
||||
if (node_type->n_init_state) {
|
||||
node_type->n_init_state(state);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user