lang: codegen: remove old var declaration generator
This commit is contained in:
@@ -166,27 +166,6 @@ static struct code_generator_result gen_unit_import(
|
||||
return CODEGEN_RESULT_OK(0);
|
||||
}
|
||||
|
||||
static struct code_generator_result gen_var_declaration(
|
||||
struct ivy_codegen *gen, struct code_generator_state *state,
|
||||
struct ivy_ast_node *node, size_t depth)
|
||||
{
|
||||
struct unit_codegen_state *unit = (struct unit_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 (!current || current != unit->s_immediate) {
|
||||
status = switch_to_immediate_func(gen, unit, ENSURE_OPEN_BLOCK);
|
||||
}
|
||||
|
||||
if (status != IVY_OK) {
|
||||
return CODEGEN_RESULT_ERR(status);
|
||||
}
|
||||
|
||||
codegen_push_generator(gen, CODE_GENERATOR_VAR, 0, NULL);
|
||||
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)
|
||||
@@ -208,43 +187,6 @@ static struct code_generator_result gen_return(
|
||||
return CODEGEN_RESULT_OK(CODEGEN_R_REPEAT_NODE);
|
||||
}
|
||||
|
||||
#if 0
|
||||
static struct code_generator_result gen_var_declaration(
|
||||
struct ivy_codegen *gen, struct code_generator_state *state,
|
||||
struct ivy_ast_node *node)
|
||||
{
|
||||
struct unit_codegen_state *unit = (struct unit_codegen_state *)state;
|
||||
struct mie_builder *builder = gen->c_builder;
|
||||
|
||||
struct mie_block *current_block
|
||||
= mie_builder_get_current_block(gen->c_builder);
|
||||
|
||||
enum ivy_status status = IVY_OK;
|
||||
if (!current_block || current_block != unit->s_immediate_alloca) {
|
||||
status = switch_to_immediate_alloca(gen, unit);
|
||||
}
|
||||
|
||||
struct codegen_value *value = codegen_pop_value(gen);
|
||||
struct codegen_value *dest = codegen_pop_value(gen);
|
||||
|
||||
if (!dest) {
|
||||
return CODEGEN_RESULT_ERR(IVY_ERR_BAD_SYNTAX);
|
||||
}
|
||||
|
||||
struct mie_type *id_type = mie_ctx_get_type(gen->c_ctx, MIE_TYPE_ID);
|
||||
struct mie_value *var_ptr = mie_builder_alloca(builder, id_type, NULL);
|
||||
|
||||
if (value) {
|
||||
mie_builder_store(builder, value->v_value, var_ptr);
|
||||
}
|
||||
|
||||
code_generator_scope_put_variable(
|
||||
unit->s_scope, (struct ivy_ast_ident_node *)dest->v_node, var_ptr);
|
||||
|
||||
return CODEGEN_RESULT_OK(0);
|
||||
}
|
||||
#endif
|
||||
|
||||
static enum ivy_status state_init(
|
||||
struct ivy_codegen *gen, struct code_generator_state *state,
|
||||
uintptr_t argv, void *argp)
|
||||
@@ -308,7 +250,6 @@ struct code_generator unit_generator = {
|
||||
.g_state_init = state_init,
|
||||
.g_state_fini = state_fini,
|
||||
.g_node_generators = {
|
||||
NODE_CODEGEN(VAR, gen_var_declaration),
|
||||
NODE_CODEGEN(RETURN, gen_return),
|
||||
NODE_CODEGEN(UNIT_PACKAGE, gen_unit_package),
|
||||
NODE_CODEGEN(UNIT_IMPORT, gen_unit_import),
|
||||
|
||||
Reference in New Issue
Block a user