lang: codegen: implement return generation
This commit is contained in:
@@ -40,6 +40,24 @@ static struct code_generator_result gen_var_declaration(
|
||||
return CODEGEN_RESULT_OK(CODEGEN_R_REPEAT_NODE);
|
||||
}
|
||||
|
||||
static struct code_generator_result gen_return(
|
||||
struct ivy_codegen *gen, struct code_generator_state *state,
|
||||
struct ivy_ast_node *node, size_t depth)
|
||||
{
|
||||
struct block_codegen_state *block = (struct block_codegen_state *)state;
|
||||
struct mie_builder *builder = gen->c_builder;
|
||||
struct mie_func *current = mie_builder_get_current_func(builder);
|
||||
|
||||
enum ivy_status status = IVY_OK;
|
||||
|
||||
if (status != IVY_OK) {
|
||||
return CODEGEN_RESULT_ERR(status);
|
||||
}
|
||||
|
||||
codegen_push_generator(gen, CODE_GENERATOR_RETURN, 0, NULL);
|
||||
return CODEGEN_RESULT_OK(CODEGEN_R_REPEAT_NODE);
|
||||
}
|
||||
|
||||
static enum ivy_status state_init(
|
||||
struct ivy_codegen *gen, struct code_generator_state *state,
|
||||
uintptr_t argv, void *argp)
|
||||
@@ -62,6 +80,7 @@ struct code_generator block_generator = {
|
||||
.g_state_fini = state_fini,
|
||||
.g_node_generators = {
|
||||
NODE_CODEGEN(VAR, gen_var_declaration),
|
||||
NODE_CODEGEN(RETURN, gen_return),
|
||||
},
|
||||
.g_expr_generator = gen_expr,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user