lang: remove references to old mie api
This commit is contained in:
@@ -1,8 +1,6 @@
|
||||
#include "codegen.h"
|
||||
|
||||
#include <mie/ir/block.h>
|
||||
#include <mie/ir/func.h>
|
||||
#include <mie/ir/module.h>
|
||||
|
||||
struct block_codegen_state {
|
||||
struct code_generator_state s_base;
|
||||
@@ -19,7 +17,6 @@ static struct code_generator_result gen_expr(
|
||||
{
|
||||
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);
|
||||
|
||||
codegen_push_generator(
|
||||
gen, CODE_GENERATOR_EXPR, CODEGEN_F_IGNORE_RESULT, NULL);
|
||||
@@ -48,50 +45,21 @@ 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);
|
||||
return CODEGEN_RESULT_ERR(IVY_ERR_NOT_SUPPORTED);
|
||||
}
|
||||
|
||||
static struct code_generator_result gen_loop_break(
|
||||
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;
|
||||
|
||||
if (!state->s_loop_break_target) {
|
||||
return CODEGEN_RESULT_ERR(IVY_ERR_BAD_SYNTAX);
|
||||
}
|
||||
|
||||
mie_builder_br(gen->c_builder, state->s_loop_break_target);
|
||||
|
||||
block->s_result = mie_ctx_get_null(gen->c_ctx);
|
||||
return CODEGEN_RESULT_OK(0);
|
||||
return CODEGEN_RESULT_ERR(IVY_ERR_NOT_SUPPORTED);
|
||||
}
|
||||
|
||||
static struct code_generator_result gen_loop_repeat(
|
||||
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;
|
||||
|
||||
if (!state->s_loop_repeat_target) {
|
||||
return CODEGEN_RESULT_ERR(IVY_ERR_BAD_SYNTAX);
|
||||
}
|
||||
|
||||
mie_builder_br(gen->c_builder, state->s_loop_repeat_target);
|
||||
|
||||
block->s_result = mie_ctx_get_null(gen->c_ctx);
|
||||
return CODEGEN_RESULT_OK(0);
|
||||
return CODEGEN_RESULT_ERR(IVY_ERR_NOT_SUPPORTED);
|
||||
}
|
||||
|
||||
static enum ivy_status state_init(
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
#include "codegen.h"
|
||||
|
||||
#include <mie/ir/func.h>
|
||||
#include <mie/ir/module.h>
|
||||
|
||||
struct cascade_codegen_state {
|
||||
struct code_generator_state s_base;
|
||||
struct mie_value *s_recipient;
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
|
||||
#include <ivy/lang/codegen.h>
|
||||
#include <mie/ir/builder.h>
|
||||
#include <mie/ir/module.h>
|
||||
#include <mie/ir/value.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
@@ -213,22 +211,27 @@ enum ivy_status codegen_resolve_variable(
|
||||
struct mie_value *codegen_load_variable(
|
||||
struct ivy_codegen *gen, struct codegen_var *var)
|
||||
{
|
||||
#if 0
|
||||
if (var->v_flags & CODEGEN_VAR_F_PTR) {
|
||||
return mie_builder_load(
|
||||
gen->c_builder, var->v_type, var->v_value, NULL);
|
||||
}
|
||||
|
||||
return var->v_value;
|
||||
#endif
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void codegen_store_variable(
|
||||
struct ivy_codegen *gen, struct codegen_var *var, struct mie_value *val)
|
||||
{
|
||||
#if 0
|
||||
if (!(var->v_flags & CODEGEN_VAR_F_PTR)) {
|
||||
return;
|
||||
}
|
||||
|
||||
mie_builder_store(gen->c_builder, val, var->v_value);
|
||||
#endif
|
||||
}
|
||||
|
||||
enum ivy_status ivy_codegen_create(struct mie_ctx *ctx, struct ivy_codegen **out)
|
||||
@@ -248,6 +251,7 @@ enum ivy_status ivy_codegen_create(struct mie_ctx *ctx, struct ivy_codegen **out
|
||||
|
||||
void ivy_codegen_destroy(struct ivy_codegen *gen)
|
||||
{
|
||||
#if 0
|
||||
if (gen->c_module) {
|
||||
mie_value_destroy(MIE_VALUE(gen->c_module));
|
||||
}
|
||||
@@ -255,12 +259,14 @@ void ivy_codegen_destroy(struct ivy_codegen *gen)
|
||||
if (gen->c_builder) {
|
||||
mie_builder_destroy(gen->c_builder);
|
||||
}
|
||||
#endif
|
||||
|
||||
free(gen);
|
||||
}
|
||||
|
||||
enum ivy_status ivy_codegen_start_module(struct ivy_codegen *gen)
|
||||
{
|
||||
#if 0
|
||||
if (gen->c_module || gen->c_builder) {
|
||||
return IVY_ERR_BAD_STATE;
|
||||
}
|
||||
@@ -269,6 +275,8 @@ enum ivy_status ivy_codegen_start_module(struct ivy_codegen *gen)
|
||||
gen->c_builder = mie_builder_create(gen->c_ctx, gen->c_module);
|
||||
|
||||
return IVY_OK;
|
||||
#endif
|
||||
return IVY_ERR_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
enum ivy_status ivy_codegen_end_module(
|
||||
@@ -278,6 +286,7 @@ enum ivy_status ivy_codegen_end_module(
|
||||
return IVY_ERR_BAD_STATE;
|
||||
}
|
||||
|
||||
#if 0
|
||||
struct mie_module *module = gen->c_module;
|
||||
mie_builder_destroy(gen->c_builder);
|
||||
|
||||
@@ -287,6 +296,8 @@ enum ivy_status ivy_codegen_end_module(
|
||||
*out = module;
|
||||
|
||||
return IVY_OK;
|
||||
#endif
|
||||
return IVY_ERR_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
struct mie_module *ivy_codegen_get_current_module(struct ivy_codegen *gen)
|
||||
|
||||
@@ -3,9 +3,6 @@
|
||||
|
||||
#include <assert.h>
|
||||
#include <mie/ir/block.h>
|
||||
#include <mie/ir/func.h>
|
||||
#include <mie/ir/phi.h>
|
||||
#include <mie/ir/value.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
@@ -44,8 +41,6 @@ static enum ivy_status state_init(
|
||||
debug_printf("codegen: start of cond group\n");
|
||||
struct cond_group_codegen_state *group
|
||||
= (struct cond_group_codegen_state *)state;
|
||||
struct mie_func *func = mie_builder_get_current_func(gen->c_builder);
|
||||
group->s_end = mie_func_create_block(func, "if.end");
|
||||
return IVY_OK;
|
||||
}
|
||||
|
||||
@@ -53,6 +48,7 @@ static enum ivy_status get_eval_type(
|
||||
struct ivy_codegen *gen, struct cond_group_codegen_state *state,
|
||||
struct mie_type **out)
|
||||
{
|
||||
#if 0
|
||||
struct mie_type *type = NULL;
|
||||
|
||||
fx_queue_entry *entry = fx_queue_first(&state->s_edges);
|
||||
@@ -76,8 +72,11 @@ static enum ivy_status get_eval_type(
|
||||
|
||||
*out = type;
|
||||
return IVY_OK;
|
||||
#endif
|
||||
return IVY_ERR_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
#if 0
|
||||
static enum ivy_status emit_phi_instr(
|
||||
struct ivy_codegen *gen, struct cond_group_codegen_state *state,
|
||||
struct mie_type *type, struct mie_value **result)
|
||||
@@ -110,6 +109,7 @@ static enum ivy_status emit_phi_instr(
|
||||
|
||||
return IVY_OK;
|
||||
}
|
||||
#endif
|
||||
|
||||
static enum ivy_status state_fini(
|
||||
struct ivy_codegen *gen, struct code_generator_state *state,
|
||||
@@ -118,6 +118,7 @@ static enum ivy_status state_fini(
|
||||
debug_printf("codegen: end of cond group\n");
|
||||
struct cond_group_codegen_state *group
|
||||
= (struct cond_group_codegen_state *)state;
|
||||
#if 0
|
||||
struct mie_func *func = mie_builder_get_current_func(gen->c_builder);
|
||||
struct mie_block *block = mie_builder_get_current_block(gen->c_builder);
|
||||
|
||||
@@ -148,6 +149,8 @@ static enum ivy_status state_fini(
|
||||
}
|
||||
|
||||
return IVY_OK;
|
||||
#endif
|
||||
return IVY_ERR_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
static struct code_generator_result value_received(
|
||||
@@ -156,12 +159,15 @@ static struct code_generator_result value_received(
|
||||
{
|
||||
struct cond_group_codegen_state *cond
|
||||
= (struct cond_group_codegen_state *)state;
|
||||
#if 0
|
||||
assert(value->v_type == CODE_GENERATOR_VALUE_PHI_EDGE);
|
||||
|
||||
struct mie_phi_edge *edge = code_generator_value_get_phi_edge(value);
|
||||
fx_queue_push_back(&cond->s_edges, &edge->e_entry);
|
||||
|
||||
return CODEGEN_RESULT_OK(0);
|
||||
#endif
|
||||
return CODEGEN_RESULT_ERR(IVY_ERR_NOT_SUPPORTED);
|
||||
}
|
||||
|
||||
struct code_generator cond_group_generator = {
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
#include "../debug.h"
|
||||
#include "codegen.h"
|
||||
|
||||
#include <mie/ir/func.h>
|
||||
#include <mie/ir/phi.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
@@ -32,6 +30,7 @@ static struct code_generator_result gen_expr(
|
||||
struct ivy_ast_node *node, size_t depth)
|
||||
{
|
||||
struct cond_codegen_state *cond = (struct cond_codegen_state *)state;
|
||||
#if 0
|
||||
struct mie_func *func = mie_builder_get_current_func(gen->c_builder);
|
||||
/* this is either the if-condition, or the if-body for an inline
|
||||
* if-statement */
|
||||
@@ -48,6 +47,8 @@ static struct code_generator_result gen_expr(
|
||||
|
||||
codegen_push_generator(gen, CODE_GENERATOR_EXPR, 0, NULL);
|
||||
return CODEGEN_RESULT_OK(CODEGEN_R_REPEAT_NODE);
|
||||
#endif
|
||||
return CODEGEN_RESULT_ERR(IVY_ERR_NOT_SUPPORTED);
|
||||
}
|
||||
|
||||
static struct code_generator_result gen_block(
|
||||
@@ -55,6 +56,7 @@ static struct code_generator_result gen_block(
|
||||
struct ivy_ast_node *node, size_t depth)
|
||||
{
|
||||
struct cond_codegen_state *cond = (struct cond_codegen_state *)state;
|
||||
#if 0
|
||||
struct mie_func *func = mie_builder_get_current_func(gen->c_builder);
|
||||
|
||||
if (cond->s_cond) {
|
||||
@@ -69,6 +71,8 @@ static struct code_generator_result gen_block(
|
||||
|
||||
codegen_push_generator(gen, CODE_GENERATOR_BLOCK, 0, NULL);
|
||||
return CODEGEN_RESULT_OK(CODEGEN_R_REPEAT_NODE);
|
||||
#endif
|
||||
return CODEGEN_RESULT_ERR(IVY_ERR_NOT_SUPPORTED);
|
||||
}
|
||||
|
||||
static enum ivy_status state_init(
|
||||
@@ -87,6 +91,7 @@ static enum ivy_status state_fini(
|
||||
{
|
||||
debug_printf("codegen: end of cond\n");
|
||||
struct cond_codegen_state *cond = (struct cond_codegen_state *)state;
|
||||
#if 0
|
||||
struct mie_func *func = mie_builder_get_current_func(gen->c_builder);
|
||||
struct mie_block *block = mie_builder_get_current_block(gen->c_builder);
|
||||
|
||||
@@ -101,12 +106,15 @@ static enum ivy_status state_fini(
|
||||
}
|
||||
|
||||
return IVY_OK;
|
||||
#endif
|
||||
return IVY_ERR_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
static void set_cond(
|
||||
struct ivy_codegen *gen, struct cond_codegen_state *cond,
|
||||
struct mie_value *value)
|
||||
{
|
||||
#if 0
|
||||
struct mie_type *cond_type = mie_value_get_type(value, gen->c_ctx);
|
||||
|
||||
if (cond_type->t_id == MIE_TYPE_INT && cond_type->t_width == 1) {
|
||||
@@ -118,6 +126,7 @@ static void set_cond(
|
||||
= mie_builder_cmp_neq(gen->c_builder, value, zero, NULL);
|
||||
cond->s_cond = cmp;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
static struct code_generator_result value_received(
|
||||
|
||||
@@ -105,14 +105,16 @@ static struct code_generator_result gen_int(
|
||||
|
||||
debug_printf("codegen: got int\n");
|
||||
struct ivy_ast_int_node *int_node = (struct ivy_ast_int_node *)node;
|
||||
#if 0
|
||||
struct mie_value *value
|
||||
= mie_ctx_get_int(gen->c_ctx, int_node->n_value->t_int, 32);
|
||||
enum ivy_status status = push_operand(expr, node, value, NULL);
|
||||
if (status != IVY_OK) {
|
||||
return CODEGEN_RESULT_ERR(status);
|
||||
}
|
||||
#endif
|
||||
|
||||
return CODEGEN_RESULT_OK(0);
|
||||
return CODEGEN_RESULT_ERR(IVY_ERR_NOT_SUPPORTED);
|
||||
}
|
||||
|
||||
static struct code_generator_result gen_keyword_const(
|
||||
@@ -123,6 +125,7 @@ static struct code_generator_result gen_keyword_const(
|
||||
|
||||
debug_printf("codegen: got keyword const\n");
|
||||
|
||||
#if 0
|
||||
struct mie_value *value = NULL;
|
||||
|
||||
switch (node->n_type) {
|
||||
@@ -144,8 +147,9 @@ static struct code_generator_result gen_keyword_const(
|
||||
if (status != IVY_OK) {
|
||||
return CODEGEN_RESULT_ERR(status);
|
||||
}
|
||||
#endif
|
||||
|
||||
return CODEGEN_RESULT_OK(0);
|
||||
return CODEGEN_RESULT_ERR(IVY_ERR_NOT_SUPPORTED);
|
||||
}
|
||||
|
||||
static struct code_generator_result gen_string(
|
||||
@@ -158,6 +162,7 @@ static struct code_generator_result gen_string(
|
||||
struct ivy_ast_string_node *string_node
|
||||
= (struct ivy_ast_string_node *)node;
|
||||
|
||||
#if 0
|
||||
struct mie_value *var_ptr = mie_builder_get_string_ptr(
|
||||
gen->c_builder, string_node->n_value->t_str);
|
||||
struct mie_type *str = mie_ctx_get_type(gen->c_ctx, MIE_TYPE_STR);
|
||||
@@ -168,8 +173,9 @@ static struct code_generator_result gen_string(
|
||||
if (status != IVY_OK) {
|
||||
return CODEGEN_RESULT_ERR(status);
|
||||
}
|
||||
#endif
|
||||
|
||||
return CODEGEN_RESULT_OK(0);
|
||||
return CODEGEN_RESULT_ERR(IVY_ERR_NOT_SUPPORTED);
|
||||
}
|
||||
|
||||
static struct code_generator_result gen_fstring(
|
||||
@@ -416,6 +422,7 @@ static enum ivy_status gen_assignment(
|
||||
struct ivy_ast_op_node *op, struct expr_item *left,
|
||||
struct expr_item *right, struct mie_value **result)
|
||||
{
|
||||
#if 0
|
||||
struct mie_value *left_value = left->i_value;
|
||||
struct mie_value *right_value = right->i_value;
|
||||
|
||||
@@ -452,8 +459,9 @@ static enum ivy_status gen_assignment(
|
||||
|
||||
codegen_store_variable(gen, &left->i_var, right_value);
|
||||
*result = right_value;
|
||||
#endif
|
||||
|
||||
return IVY_OK;
|
||||
return IVY_ERR_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
static enum ivy_status gen_op_assignment(
|
||||
@@ -461,6 +469,7 @@ static enum ivy_status gen_op_assignment(
|
||||
struct ivy_ast_op_node *op, struct expr_item *left,
|
||||
struct expr_item *right, struct mie_value **result)
|
||||
{
|
||||
#if 0
|
||||
struct mie_value *op_value = NULL;
|
||||
|
||||
if (left->i_operand_type != EXPR_OPERAND_VAR) {
|
||||
@@ -502,13 +511,15 @@ static enum ivy_status gen_op_assignment(
|
||||
|
||||
codegen_store_variable(gen, &left->i_var, op_value);
|
||||
*result = op_value;
|
||||
#endif
|
||||
|
||||
return IVY_OK;
|
||||
return IVY_ERR_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
static struct mie_value *load_variable(
|
||||
struct ivy_codegen *gen, struct codegen_var *var)
|
||||
{
|
||||
#if 0
|
||||
struct ivy_ast_ident_node *ident = (struct ivy_ast_ident_node *)var->v_node;
|
||||
struct mie_value *var_ptr = NULL;
|
||||
|
||||
@@ -526,12 +537,16 @@ static struct mie_value *load_variable(
|
||||
= mie_builder_load(gen->c_builder, id, var_ptr, NULL);
|
||||
|
||||
return var_value;
|
||||
#endif
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static enum ivy_status state_fini(
|
||||
struct ivy_codegen *gen, struct code_generator_state *state,
|
||||
struct code_generator_value *result)
|
||||
{
|
||||
#if 0
|
||||
#define OP_IS_ASSIGNMENT(id) \
|
||||
((id) == IVY_OP_ASSIGN || (id) == IVY_OP_ADD_ASSIGN \
|
||||
|| (id) == IVY_OP_SUBTRACT_ASSIGN || (id) == IVY_OP_MULTIPLY_ASSIGN \
|
||||
@@ -695,6 +710,8 @@ static enum ivy_status state_fini(
|
||||
result->v_value.mie_value = result_value;
|
||||
|
||||
return status;
|
||||
#endif
|
||||
return IVY_ERR_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
static struct code_generator_result value_received(
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
#include "codegen.h"
|
||||
|
||||
#include <mie/ir/block.h>
|
||||
#include <mie/ir/func.h>
|
||||
#include <mie/ir/module.h>
|
||||
|
||||
struct for_codegen_state {
|
||||
struct code_generator_state s_base;
|
||||
@@ -55,6 +53,7 @@ static struct code_generator_result gen_block(
|
||||
struct ivy_ast_node *node, size_t depth)
|
||||
{
|
||||
struct for_codegen_state *for_loop = (struct for_codegen_state *)state;
|
||||
#if 0
|
||||
struct mie_func *func = mie_builder_get_current_func(gen->c_builder);
|
||||
|
||||
// mie_builder_br(gen->c_builder, for_loop->s_blocks.b_cond);
|
||||
@@ -63,6 +62,8 @@ static struct code_generator_result gen_block(
|
||||
|
||||
codegen_push_generator(gen, CODE_GENERATOR_BLOCK, 0, NULL);
|
||||
return CODEGEN_RESULT_OK(0);
|
||||
#endif
|
||||
return CODEGEN_RESULT_ERR(IVY_ERR_NOT_SUPPORTED);
|
||||
}
|
||||
|
||||
static enum ivy_status state_init(
|
||||
@@ -70,6 +71,7 @@ static enum ivy_status state_init(
|
||||
uintptr_t argv, void *argp)
|
||||
{
|
||||
struct for_codegen_state *for_loop = (struct for_codegen_state *)state;
|
||||
#if 0
|
||||
struct mie_func *func = mie_builder_get_current_func(gen->c_builder);
|
||||
|
||||
for_loop->s_blocks.b_cond = mie_func_create_block(func, "for.cond");
|
||||
@@ -81,11 +83,14 @@ static enum ivy_status state_init(
|
||||
state->s_loop_repeat_target = for_loop->s_blocks.b_inc;
|
||||
|
||||
return IVY_OK;
|
||||
#endif
|
||||
return IVY_ERR_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
static enum ivy_status gen_iterator_start(
|
||||
struct ivy_codegen *gen, struct for_codegen_state *for_loop)
|
||||
{
|
||||
#if 0
|
||||
struct mie_func *func = mie_builder_get_current_func(gen->c_builder);
|
||||
|
||||
struct mie_type *id = mie_ctx_get_type(gen->c_ctx, MIE_TYPE_ID);
|
||||
@@ -95,11 +100,14 @@ static enum ivy_status gen_iterator_start(
|
||||
"for.it");
|
||||
mie_builder_br(gen->c_builder, for_loop->s_blocks.b_cond);
|
||||
return IVY_OK;
|
||||
#endif
|
||||
return IVY_ERR_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
static enum ivy_status gen_cond_block(
|
||||
struct ivy_codegen *gen, struct for_codegen_state *for_loop)
|
||||
{
|
||||
#if 0
|
||||
struct mie_func *func = mie_builder_get_current_func(gen->c_builder);
|
||||
mie_func_insert_block(func, for_loop->s_blocks.b_cond, NULL);
|
||||
mie_builder_set_insert_point(gen->c_builder, for_loop->s_blocks.b_cond);
|
||||
@@ -119,11 +127,14 @@ static enum ivy_status gen_cond_block(
|
||||
for_loop->s_blocks.b_end, for_loop->s_blocks.b_body);
|
||||
|
||||
return IVY_OK;
|
||||
#endif
|
||||
return IVY_ERR_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
static enum ivy_status gen_body(
|
||||
struct ivy_codegen *gen, struct for_codegen_state *for_loop)
|
||||
{
|
||||
#if 0
|
||||
struct mie_func *func = mie_builder_get_current_func(gen->c_builder);
|
||||
mie_func_insert_block(func, for_loop->s_blocks.b_body, NULL);
|
||||
mie_builder_set_insert_point(gen->c_builder, for_loop->s_blocks.b_body);
|
||||
@@ -135,11 +146,14 @@ static enum ivy_status gen_body(
|
||||
gen->c_builder, for_loop->s_it_value, for_loop->s_it_value_inner);
|
||||
|
||||
return IVY_OK;
|
||||
#endif
|
||||
return IVY_ERR_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
static enum ivy_status gen_inc_block(
|
||||
struct ivy_codegen *gen, struct for_codegen_state *for_loop)
|
||||
{
|
||||
#if 0
|
||||
struct mie_func *func = mie_builder_get_current_func(gen->c_builder);
|
||||
mie_builder_br(gen->c_builder, for_loop->s_blocks.b_inc);
|
||||
|
||||
@@ -153,16 +167,21 @@ static enum ivy_status gen_inc_block(
|
||||
mie_builder_br(gen->c_builder, for_loop->s_blocks.b_cond);
|
||||
|
||||
return IVY_OK;
|
||||
#endif
|
||||
return IVY_ERR_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
static enum ivy_status gen_end_block(
|
||||
struct ivy_codegen *gen, struct for_codegen_state *for_loop)
|
||||
{
|
||||
#if 0
|
||||
struct mie_func *func = mie_builder_get_current_func(gen->c_builder);
|
||||
mie_func_insert_block(func, for_loop->s_blocks.b_end, NULL);
|
||||
mie_builder_set_insert_point(gen->c_builder, for_loop->s_blocks.b_end);
|
||||
|
||||
return IVY_OK;
|
||||
#endif
|
||||
return IVY_ERR_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
static enum ivy_status state_fini(
|
||||
@@ -179,6 +198,7 @@ static struct code_generator_result value_received(
|
||||
struct ivy_codegen *gen, struct code_generator_state *state,
|
||||
struct code_generator_value *value)
|
||||
{
|
||||
#if 0
|
||||
struct for_codegen_state *for_loop = (struct for_codegen_state *)state;
|
||||
struct mie_func *func = mie_builder_get_current_func(gen->c_builder);
|
||||
|
||||
@@ -191,6 +211,8 @@ static struct code_generator_result value_received(
|
||||
}
|
||||
|
||||
return CODEGEN_RESULT_OK(0);
|
||||
#endif
|
||||
return CODEGEN_RESULT_ERR(IVY_ERR_NOT_SUPPORTED);
|
||||
}
|
||||
|
||||
static enum ivy_status resolve_var(
|
||||
@@ -199,6 +221,7 @@ static enum ivy_status resolve_var(
|
||||
{
|
||||
struct for_codegen_state *for_loop = (struct for_codegen_state *)state;
|
||||
|
||||
#if 0
|
||||
if (strcmp(ident, for_loop->s_it_ident->n_content->t_str) != 0) {
|
||||
return IVY_ERR_NO_ENTRY;
|
||||
}
|
||||
@@ -209,6 +232,8 @@ static enum ivy_status resolve_var(
|
||||
var->v_flags = CODEGEN_VAR_F_PTR;
|
||||
|
||||
return IVY_OK;
|
||||
#endif
|
||||
return IVY_ERR_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
struct code_generator for_loop_generator = {
|
||||
|
||||
@@ -17,18 +17,7 @@ static struct code_generator_result gen_fstring(
|
||||
struct fstring_codegen_state *fstring
|
||||
= (struct fstring_codegen_state *)state;
|
||||
|
||||
struct mie_value *stringbuilder_ptr
|
||||
= mie_builder_get_data_ptr(gen->c_builder, "StringBuilder");
|
||||
|
||||
struct mie_type *id = mie_ctx_get_type(gen->c_ctx, MIE_TYPE_ID);
|
||||
struct mie_value *stringbuilder_class
|
||||
= mie_builder_load(gen->c_builder, id, stringbuilder_ptr, NULL);
|
||||
struct mie_value *sel = mie_ctx_get_selector(gen->c_ctx, "_M3newE");
|
||||
|
||||
fstring->s_stringbuilder = mie_builder_msg(
|
||||
gen->c_builder, id, stringbuilder_class, sel, NULL, 0, 0, NULL);
|
||||
|
||||
return CODEGEN_RESULT_OK(0);
|
||||
return CODEGEN_RESULT_ERR(IVY_ERR_NOT_SUPPORTED);
|
||||
}
|
||||
|
||||
static struct code_generator_result gen_expr(
|
||||
@@ -55,15 +44,7 @@ static enum ivy_status state_fini(
|
||||
struct fstring_codegen_state *fstring
|
||||
= (struct fstring_codegen_state *)state;
|
||||
|
||||
struct mie_type *id = mie_ctx_get_type(gen->c_ctx, MIE_TYPE_ID);
|
||||
struct mie_value *sel = mie_ctx_get_selector(gen->c_ctx, "_M8toStringE");
|
||||
|
||||
struct mie_value *str = mie_builder_msg(
|
||||
gen->c_builder, id, fstring->s_stringbuilder, sel, NULL, 0, 0,
|
||||
NULL);
|
||||
|
||||
code_generator_value_set_mie_value(result, str);
|
||||
return IVY_OK;
|
||||
return IVY_ERR_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
static struct code_generator_result value_received(
|
||||
@@ -73,14 +54,7 @@ static struct code_generator_result value_received(
|
||||
struct fstring_codegen_state *fstring
|
||||
= (struct fstring_codegen_state *)state;
|
||||
|
||||
struct mie_type *void_type = mie_ctx_get_type(gen->c_ctx, MIE_TYPE_VOID);
|
||||
struct mie_value *sel = mie_ctx_get_selector(gen->c_ctx, "_M06appendE");
|
||||
|
||||
mie_builder_msg(
|
||||
gen->c_builder, void_type, fstring->s_stringbuilder, sel,
|
||||
&value->v_value.mie_value, 1, MIE_BUILDER_IGNORE_RESULT, NULL);
|
||||
|
||||
return CODEGEN_RESULT_OK(0);
|
||||
return CODEGEN_RESULT_ERR(IVY_ERR_NOT_SUPPORTED);
|
||||
}
|
||||
|
||||
struct code_generator fstring_generator = {
|
||||
|
||||
@@ -51,6 +51,7 @@ static struct code_generator_result gen_ident(
|
||||
return gen_value_expr(gen, state, node, depth);
|
||||
}
|
||||
|
||||
#if 0
|
||||
struct ivy_ast_ident_node *ident = (struct ivy_ast_ident_node *)node;
|
||||
const char *var_name = ident->n_content->t_str;
|
||||
|
||||
@@ -64,6 +65,8 @@ static struct code_generator_result gen_ident(
|
||||
global->s_prev_node = IVY_AST_IDENT;
|
||||
|
||||
return CODEGEN_RESULT_OK(0);
|
||||
#endif
|
||||
return CODEGEN_RESULT_ERR(IVY_ERR_NOT_SUPPORTED);
|
||||
}
|
||||
|
||||
#if 0
|
||||
@@ -107,6 +110,7 @@ static enum ivy_status state_fini(
|
||||
debug_printf("codegen: end of global decl\n");
|
||||
struct global_codegen_state *global = (struct global_codegen_state *)state;
|
||||
|
||||
#if 0
|
||||
const char *ident = global->s_var_ident->n_content->t_str;
|
||||
struct mie_type *type = NULL;
|
||||
if (global->s_value) {
|
||||
@@ -133,6 +137,8 @@ static enum ivy_status state_fini(
|
||||
}
|
||||
|
||||
return IVY_OK;
|
||||
#endif
|
||||
return IVY_ERR_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
static struct code_generator_result value_received(
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
#include "codegen.h"
|
||||
|
||||
#include <mie/ir/arg.h>
|
||||
#include <mie/ir/block.h>
|
||||
#include <mie/ir/func.h>
|
||||
#include <mie/ir/module.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
@@ -29,6 +26,7 @@ struct lambda_codegen_state {
|
||||
static enum ivy_status switch_to_lambda_func(
|
||||
struct ivy_codegen *gen, struct lambda_codegen_state *lambda)
|
||||
{
|
||||
#if 0
|
||||
if (!lambda->s_outer_block) {
|
||||
lambda->s_outer_block
|
||||
= mie_builder_get_current_block(gen->c_builder);
|
||||
@@ -48,13 +46,18 @@ static enum ivy_status switch_to_lambda_func(
|
||||
mie_builder_set_insert_point(gen->c_builder, block);
|
||||
|
||||
return IVY_OK;
|
||||
#endif
|
||||
return IVY_ERR_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
static enum ivy_status switch_to_outer_block(
|
||||
struct ivy_codegen *gen, struct lambda_codegen_state *lambda)
|
||||
{
|
||||
#if 0
|
||||
mie_builder_set_insert_point(gen->c_builder, lambda->s_outer_block);
|
||||
return IVY_OK;
|
||||
#endif
|
||||
return IVY_ERR_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
static struct code_generator_result gen_lambda(
|
||||
@@ -62,6 +65,7 @@ static struct code_generator_result gen_lambda(
|
||||
struct ivy_ast_node *node, size_t depth)
|
||||
{
|
||||
struct lambda_codegen_state *lambda = (struct lambda_codegen_state *)state;
|
||||
#if 0
|
||||
if (lambda->s_prev_part != LAMBDA_NONE) {
|
||||
return CODEGEN_RESULT_ERR(IVY_ERR_BAD_SYNTAX);
|
||||
}
|
||||
@@ -89,6 +93,8 @@ static struct code_generator_result gen_lambda(
|
||||
switch_to_lambda_func(gen, lambda);
|
||||
|
||||
return CODEGEN_RESULT_OK(0);
|
||||
#endif
|
||||
return CODEGEN_RESULT_ERR(IVY_ERR_NOT_SUPPORTED);
|
||||
}
|
||||
|
||||
static struct code_generator_result gen_ident(
|
||||
@@ -96,6 +102,7 @@ static struct code_generator_result gen_ident(
|
||||
struct ivy_ast_node *node, size_t depth)
|
||||
{
|
||||
struct lambda_codegen_state *lambda = (struct lambda_codegen_state *)state;
|
||||
#if 0
|
||||
if (lambda->s_prev_part != LAMBDA_START
|
||||
&& lambda->s_prev_part != LAMBDA_ARG) {
|
||||
return CODEGEN_RESULT_ERR(IVY_ERR_BAD_SYNTAX);
|
||||
@@ -117,6 +124,8 @@ static struct code_generator_result gen_ident(
|
||||
codegen_var_map_put(&lambda->s_args, arg_name, &arg_var);
|
||||
|
||||
return CODEGEN_RESULT_OK(0);
|
||||
#endif
|
||||
return CODEGEN_RESULT_ERR(IVY_ERR_NOT_SUPPORTED);
|
||||
}
|
||||
|
||||
static struct code_generator_result gen_block(
|
||||
@@ -151,6 +160,7 @@ static enum ivy_status state_fini(
|
||||
{
|
||||
struct lambda_codegen_state *lambda = (struct lambda_codegen_state *)state;
|
||||
|
||||
#if 0
|
||||
switch_to_outer_block(gen, lambda);
|
||||
mie_module_add_function(gen->c_module, lambda->s_func, ".anon");
|
||||
result->v_type = CODE_GENERATOR_VALUE_MIE_VALUE;
|
||||
@@ -160,6 +170,8 @@ static enum ivy_status state_fini(
|
||||
codegen_var_map_fini(&lambda->s_captured_vars);
|
||||
|
||||
return IVY_OK;
|
||||
#endif
|
||||
return IVY_ERR_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
static enum ivy_status resolve_var(
|
||||
@@ -192,6 +204,7 @@ static enum ivy_status capture_var(
|
||||
{
|
||||
struct lambda_codegen_state *lambda = (struct lambda_codegen_state *)state;
|
||||
|
||||
#if 0
|
||||
struct mie_type *str_type = mie_ctx_get_type(gen->c_ctx, MIE_TYPE_STR);
|
||||
struct mie_type *void_type = mie_ctx_get_type(gen->c_ctx, MIE_TYPE_VOID);
|
||||
struct mie_value *ident_ptr
|
||||
@@ -243,6 +256,8 @@ static enum ivy_status capture_var(
|
||||
*var = capture;
|
||||
|
||||
return IVY_OK;
|
||||
#endif
|
||||
return IVY_ERR_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
struct code_generator lambda_generator = {
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
#include "codegen.h"
|
||||
|
||||
#include <mie/ir/block.h>
|
||||
#include <mie/ir/func.h>
|
||||
#include <mie/ir/module.h>
|
||||
|
||||
struct match_codegen_state {
|
||||
struct code_generator_state s_base;
|
||||
@@ -30,7 +28,9 @@ static struct code_generator_result gen_block(
|
||||
struct ivy_ast_node *node, size_t depth)
|
||||
{
|
||||
struct match_codegen_state *match = (struct match_codegen_state *)state;
|
||||
#if 0
|
||||
struct mie_func *func = mie_builder_get_current_func(gen->c_builder);
|
||||
#endif
|
||||
|
||||
codegen_push_generator(gen, CODE_GENERATOR_BLOCK, 0, NULL);
|
||||
return CODEGEN_RESULT_OK(0);
|
||||
@@ -66,7 +66,9 @@ static struct code_generator_result value_received(
|
||||
struct code_generator_value *value)
|
||||
{
|
||||
struct match_codegen_state *match = (struct match_codegen_state *)state;
|
||||
#if 0
|
||||
struct mie_func *func = mie_builder_get_current_func(gen->c_builder);
|
||||
#endif
|
||||
|
||||
return CODEGEN_RESULT_OK(0);
|
||||
}
|
||||
|
||||
@@ -149,7 +149,8 @@ static void serialise_selector(
|
||||
const char *label = arg->t_str;
|
||||
|
||||
if (label) {
|
||||
fx_stream_write_fmt(out, NULL, "%zu%s", strlen(label), label);
|
||||
fx_stream_write_fmt(
|
||||
out, NULL, "%zu%s", strlen(label), label);
|
||||
} else {
|
||||
fx_stream_write_char(out, '0');
|
||||
}
|
||||
@@ -165,6 +166,7 @@ static enum ivy_status state_fini(
|
||||
struct code_generator_value *result)
|
||||
{
|
||||
debug_printf("codegen: end of msg\n");
|
||||
#if 0
|
||||
|
||||
struct msg_codegen_state *msg = (struct msg_codegen_state *)state;
|
||||
|
||||
@@ -180,7 +182,6 @@ static enum ivy_status state_fini(
|
||||
struct mie_type *ret_type = NULL;
|
||||
const char *value_name = NULL;
|
||||
|
||||
#if 0
|
||||
if (msg->s_flags & CODEGEN_F_IGNORE_RESULT) {
|
||||
ret_type = mie_ctx_get_type(gen->c_ctx, MIE_TYPE_VOID);
|
||||
flags = MIE_BUILDER_IGNORE_RESULT;
|
||||
@@ -188,7 +189,6 @@ static enum ivy_status state_fini(
|
||||
ret_type = mie_ctx_get_type(gen->c_ctx, MIE_TYPE_ID);
|
||||
value_name = "msgtmp";
|
||||
}
|
||||
#endif
|
||||
ret_type = mie_ctx_get_type(gen->c_ctx, MIE_TYPE_ID);
|
||||
value_name = "msgtmp";
|
||||
|
||||
@@ -202,8 +202,9 @@ static enum ivy_status state_fini(
|
||||
|
||||
result->v_type = CODE_GENERATOR_VALUE_MIE_VALUE;
|
||||
result->v_value.mie_value = msg_send;
|
||||
#endif
|
||||
|
||||
return IVY_OK;
|
||||
return IVY_ERR_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
static struct code_generator_result value_received(
|
||||
|
||||
@@ -53,9 +53,9 @@ static enum ivy_status state_fini(
|
||||
debug_printf("codegen: end of return\n");
|
||||
struct return_codegen_state *ret = (struct return_codegen_state *)state;
|
||||
|
||||
mie_builder_ret(gen->c_builder, ret->s_value);
|
||||
// mie_builder_ret(gen->c_builder, ret->s_value);
|
||||
|
||||
return IVY_OK;
|
||||
return IVY_ERR_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
static struct code_generator_result value_received(
|
||||
|
||||
@@ -4,9 +4,6 @@
|
||||
#include <fx/core/stringstream.h>
|
||||
#include <fx/ds/list.h>
|
||||
#include <mie/ir/block.h>
|
||||
#include <mie/ir/func.h>
|
||||
#include <mie/ir/module.h>
|
||||
#include <mie/ir/record.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
enum {
|
||||
@@ -25,6 +22,7 @@ struct unit_codegen_state {
|
||||
static enum ivy_status switch_to_immediate_func(
|
||||
struct ivy_codegen *gen, struct unit_codegen_state *unit, long flags)
|
||||
{
|
||||
#if 0
|
||||
if (!unit->s_immediate) {
|
||||
struct mie_type *ret_type
|
||||
= mie_ctx_get_type(gen->c_ctx, MIE_TYPE_VOID);
|
||||
@@ -56,8 +54,9 @@ static enum ivy_status switch_to_immediate_func(
|
||||
}
|
||||
|
||||
mie_builder_set_insert_point(gen->c_builder, block);
|
||||
#endif
|
||||
|
||||
return IVY_OK;
|
||||
return IVY_ERR_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
#if 0
|
||||
@@ -81,6 +80,7 @@ static struct code_generator_result gen_expr(
|
||||
struct ivy_ast_node *node, size_t depth)
|
||||
{
|
||||
struct unit_codegen_state *unit = (struct unit_codegen_state *)state;
|
||||
#if 0
|
||||
struct mie_builder *builder = gen->c_builder;
|
||||
struct mie_func *current = mie_builder_get_current_func(builder);
|
||||
|
||||
@@ -96,6 +96,8 @@ static struct code_generator_result gen_expr(
|
||||
codegen_push_generator(
|
||||
gen, CODE_GENERATOR_EXPR, CODEGEN_F_IGNORE_RESULT, NULL);
|
||||
return CODEGEN_RESULT_OK(CODEGEN_R_REPEAT_NODE);
|
||||
#endif
|
||||
return CODEGEN_RESULT_ERR(IVY_ERR_NOT_SUPPORTED);
|
||||
}
|
||||
|
||||
static struct code_generator_result gen_for_loop(
|
||||
@@ -103,6 +105,7 @@ static struct code_generator_result gen_for_loop(
|
||||
struct ivy_ast_node *node, size_t depth)
|
||||
{
|
||||
struct unit_codegen_state *unit = (struct unit_codegen_state *)state;
|
||||
#if 0
|
||||
struct mie_builder *builder = gen->c_builder;
|
||||
struct mie_func *current = mie_builder_get_current_func(builder);
|
||||
|
||||
@@ -118,6 +121,8 @@ static struct code_generator_result gen_for_loop(
|
||||
codegen_push_generator(
|
||||
gen, CODE_GENERATOR_FOR_LOOP, CODEGEN_F_IGNORE_RESULT, NULL);
|
||||
return CODEGEN_RESULT_OK(CODEGEN_R_REPEAT_NODE);
|
||||
#endif
|
||||
return CODEGEN_RESULT_ERR(IVY_ERR_NOT_SUPPORTED);
|
||||
}
|
||||
|
||||
static struct code_generator_result gen_while_loop(
|
||||
@@ -125,6 +130,7 @@ static struct code_generator_result gen_while_loop(
|
||||
struct ivy_ast_node *node, size_t depth)
|
||||
{
|
||||
struct unit_codegen_state *unit = (struct unit_codegen_state *)state;
|
||||
#if 0
|
||||
struct mie_builder *builder = gen->c_builder;
|
||||
struct mie_func *current = mie_builder_get_current_func(builder);
|
||||
|
||||
@@ -140,6 +146,8 @@ static struct code_generator_result gen_while_loop(
|
||||
codegen_push_generator(
|
||||
gen, CODE_GENERATOR_WHILE_LOOP, CODEGEN_F_IGNORE_RESULT, NULL);
|
||||
return CODEGEN_RESULT_OK(CODEGEN_R_REPEAT_NODE);
|
||||
#endif
|
||||
return CODEGEN_RESULT_ERR(IVY_ERR_NOT_SUPPORTED);
|
||||
}
|
||||
|
||||
static void serialise_package_name(fx_queue *parts, fx_stringstream *out)
|
||||
@@ -165,6 +173,7 @@ static struct code_generator_result gen_unit_package(
|
||||
struct ivy_ast_unit_package_node *pkg
|
||||
= (struct ivy_ast_unit_package_node *)node;
|
||||
|
||||
#if 0
|
||||
fx_stringstream *str = fx_stringstream_create();
|
||||
serialise_package_name(&pkg->n_ident, str);
|
||||
char *ident = fx_stringstream_steal(str);
|
||||
@@ -176,6 +185,8 @@ static struct code_generator_result gen_unit_package(
|
||||
gen->c_builder, MIE_CONST(ident_val), "package_scope");
|
||||
|
||||
return CODEGEN_RESULT_OK(0);
|
||||
#endif
|
||||
return CODEGEN_RESULT_ERR(IVY_ERR_NOT_SUPPORTED);
|
||||
}
|
||||
|
||||
static struct code_generator_result gen_unit_import(
|
||||
@@ -183,6 +194,7 @@ static struct code_generator_result gen_unit_import(
|
||||
struct ivy_ast_node *node, size_t depth)
|
||||
{
|
||||
struct unit_codegen_state *unit = (struct unit_codegen_state *)state;
|
||||
#if 0
|
||||
struct ivy_ast_unit_package_node *pkg
|
||||
= (struct ivy_ast_unit_package_node *)node;
|
||||
|
||||
@@ -208,6 +220,8 @@ static struct code_generator_result gen_unit_import(
|
||||
fx_list_push_back(import_list->a_values, ident_val);
|
||||
|
||||
return CODEGEN_RESULT_OK(0);
|
||||
#endif
|
||||
return CODEGEN_RESULT_ERR(IVY_ERR_NOT_SUPPORTED);
|
||||
}
|
||||
|
||||
static struct code_generator_result gen_return(
|
||||
@@ -215,6 +229,7 @@ static struct code_generator_result gen_return(
|
||||
struct ivy_ast_node *node, size_t depth)
|
||||
{
|
||||
struct unit_codegen_state *unit = (struct unit_codegen_state *)state;
|
||||
#if 0
|
||||
struct mie_builder *builder = gen->c_builder;
|
||||
struct mie_func *current = mie_builder_get_current_func(builder);
|
||||
|
||||
@@ -229,6 +244,8 @@ static struct code_generator_result gen_return(
|
||||
|
||||
codegen_push_generator(gen, CODE_GENERATOR_RETURN, 0, NULL);
|
||||
return CODEGEN_RESULT_OK(CODEGEN_R_REPEAT_NODE);
|
||||
#endif
|
||||
return CODEGEN_RESULT_ERR(IVY_ERR_NOT_SUPPORTED);
|
||||
}
|
||||
|
||||
static enum ivy_status state_init(
|
||||
@@ -246,6 +263,7 @@ static enum ivy_status state_fini(
|
||||
struct code_generator_value *result)
|
||||
{
|
||||
struct unit_codegen_state *unit = (struct unit_codegen_state *)state;
|
||||
#if 0
|
||||
codegen_var_map_fini(&unit->s_vars);
|
||||
|
||||
struct mie_func *current = mie_builder_get_current_func(gen->c_builder);
|
||||
@@ -261,6 +279,8 @@ static enum ivy_status state_fini(
|
||||
}
|
||||
|
||||
return IVY_OK;
|
||||
#endif
|
||||
return IVY_ERR_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
static enum ivy_status define_var(
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
#include "codegen.h"
|
||||
|
||||
#include <mie/ir/block.h>
|
||||
#include <mie/ir/func.h>
|
||||
#include <mie/ir/module.h>
|
||||
|
||||
struct while_codegen_state {
|
||||
struct code_generator_state s_base;
|
||||
@@ -21,6 +19,7 @@ static struct code_generator_result gen_expr(
|
||||
{
|
||||
struct while_codegen_state *while_loop
|
||||
= (struct while_codegen_state *)state;
|
||||
#if 0
|
||||
|
||||
if (!while_loop->s_cond_value) {
|
||||
mie_builder_br(gen->c_builder, while_loop->s_blocks.b_cond);
|
||||
@@ -34,6 +33,8 @@ static struct code_generator_result gen_expr(
|
||||
|
||||
codegen_push_generator(gen, CODE_GENERATOR_EXPR, 0, NULL);
|
||||
return CODEGEN_RESULT_OK(CODEGEN_R_REPEAT_NODE);
|
||||
#endif
|
||||
return CODEGEN_RESULT_ERR(IVY_ERR_NOT_SUPPORTED);
|
||||
}
|
||||
|
||||
static struct code_generator_result gen_while_loop(
|
||||
@@ -49,6 +50,7 @@ static struct code_generator_result gen_block(
|
||||
{
|
||||
struct while_codegen_state *while_loop
|
||||
= (struct while_codegen_state *)state;
|
||||
#if 0
|
||||
struct mie_func *func = mie_builder_get_current_func(gen->c_builder);
|
||||
|
||||
// mie_builder_br(gen->c_builder, while_loop->s_blocks.b_cond);
|
||||
@@ -57,6 +59,8 @@ static struct code_generator_result gen_block(
|
||||
|
||||
codegen_push_generator(gen, CODE_GENERATOR_BLOCK, 0, NULL);
|
||||
return CODEGEN_RESULT_OK(CODEGEN_R_REPEAT_NODE);
|
||||
#endif
|
||||
return CODEGEN_RESULT_ERR(IVY_ERR_NOT_SUPPORTED);
|
||||
}
|
||||
|
||||
static enum ivy_status state_init(
|
||||
@@ -65,6 +69,7 @@ static enum ivy_status state_init(
|
||||
{
|
||||
struct while_codegen_state *while_loop
|
||||
= (struct while_codegen_state *)state;
|
||||
#if 0
|
||||
struct mie_func *func = mie_builder_get_current_func(gen->c_builder);
|
||||
|
||||
while_loop->s_blocks.b_cond = mie_func_create_block(func, "while.cond");
|
||||
@@ -75,40 +80,48 @@ static enum ivy_status state_init(
|
||||
state->s_loop_repeat_target = while_loop->s_blocks.b_cond;
|
||||
|
||||
return IVY_OK;
|
||||
#endif
|
||||
return IVY_ERR_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
static enum ivy_status gen_cond_branch(
|
||||
struct ivy_codegen *gen, struct while_codegen_state *while_loop)
|
||||
{
|
||||
#if 0
|
||||
struct mie_func *func = mie_builder_get_current_func(gen->c_builder);
|
||||
|
||||
mie_builder_br_if(
|
||||
gen->c_builder, while_loop->s_cond_value,
|
||||
while_loop->s_blocks.b_body, while_loop->s_blocks.b_end);
|
||||
#endif
|
||||
|
||||
return IVY_OK;
|
||||
return IVY_ERR_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
static enum ivy_status gen_body(
|
||||
struct ivy_codegen *gen, struct while_codegen_state *while_loop)
|
||||
{
|
||||
#if 0
|
||||
struct mie_func *func = mie_builder_get_current_func(gen->c_builder);
|
||||
mie_func_insert_block(func, while_loop->s_blocks.b_body, NULL);
|
||||
mie_builder_set_insert_point(gen->c_builder, while_loop->s_blocks.b_body);
|
||||
#endif
|
||||
|
||||
return IVY_OK;
|
||||
return IVY_ERR_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
static enum ivy_status gen_end_block(
|
||||
struct ivy_codegen *gen, struct while_codegen_state *while_loop)
|
||||
{
|
||||
#if 0
|
||||
mie_builder_br(gen->c_builder, while_loop->s_blocks.b_cond);
|
||||
|
||||
struct mie_func *func = mie_builder_get_current_func(gen->c_builder);
|
||||
mie_func_insert_block(func, while_loop->s_blocks.b_end, NULL);
|
||||
mie_builder_set_insert_point(gen->c_builder, while_loop->s_blocks.b_end);
|
||||
#endif
|
||||
|
||||
return IVY_OK;
|
||||
return IVY_ERR_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
static enum ivy_status state_fini(
|
||||
@@ -125,6 +138,7 @@ static struct code_generator_result value_received(
|
||||
struct ivy_codegen *gen, struct code_generator_state *state,
|
||||
struct code_generator_value *value)
|
||||
{
|
||||
#if 0
|
||||
struct while_codegen_state *while_loop
|
||||
= (struct while_codegen_state *)state;
|
||||
struct mie_func *func = mie_builder_get_current_func(gen->c_builder);
|
||||
@@ -136,8 +150,9 @@ static struct code_generator_result value_received(
|
||||
gen_body(gen, while_loop);
|
||||
return CODEGEN_RESULT_OK(0);
|
||||
}
|
||||
#endif
|
||||
|
||||
return CODEGEN_RESULT_OK(0);
|
||||
return CODEGEN_RESULT_ERR(IVY_ERR_NOT_SUPPORTED);
|
||||
}
|
||||
|
||||
struct code_generator while_loop_generator = {
|
||||
|
||||
Reference in New Issue
Block a user