lang: codegen: implement cascade operator generation

This commit is contained in:
2025-09-12 10:01:07 +01:00
parent 8541b3bc5b
commit 7bb4803b9e
4 changed files with 98 additions and 0 deletions

View File

@@ -87,6 +87,16 @@ static enum ivy_status push_operator(
return IVY_OK;
}
static struct code_generator_result gen_cascade(
struct ivy_codegen *gen, struct code_generator_state *state,
struct ivy_ast_node *node, size_t depth)
{
struct expr_codegen_state *expr = (struct expr_codegen_state *)state;
codegen_push_generator(gen, CODE_GENERATOR_CASCADE, 0, NULL);
return CODEGEN_RESULT_OK(CODEGEN_R_REPEAT_NODE);
}
static struct code_generator_result gen_int(
struct ivy_codegen *gen, struct code_generator_state *state,
struct ivy_ast_node *node, size_t depth)
@@ -705,6 +715,7 @@ struct code_generator expr_generator = {
NODE_CODEGEN(C_TRUE, gen_keyword_const),
NODE_CODEGEN(C_FALSE, gen_keyword_const),
NODE_CODEGEN(C_NULL, gen_keyword_const),
NODE_CODEGEN(CASCADE, gen_cascade),
NODE_CODEGEN(INT, gen_int),
NODE_CODEGEN(OP, gen_op),
NODE_CODEGEN(MSG, gen_msg),