frontend: update mie api usage to use new context parameter

This commit is contained in:
2025-04-28 15:47:24 +01:00
parent 64d1015a3c
commit 7ba88b65f8
2 changed files with 20 additions and 4 deletions

View File

@@ -8,6 +8,7 @@
#include <ivy/lang/codegen.h>
#include <ivy/lang/lex.h>
#include <mie/convert.h>
#include <mie/ctx.h>
#include <mie/value.h>
#include <stdbool.h>
#include <stdlib.h>
@@ -21,6 +22,7 @@ enum {
struct repl {
bool r_show_lex, r_show_ast, r_show_ir;
struct mie_ctx *r_mie;
struct line_ed *r_ed;
struct ivy_lexer *r_lex;
struct ivy_parser *r_parse;
@@ -115,6 +117,10 @@ static void repl_destroy(struct repl *repl)
line_ed_destroy(repl->r_ed);
}
if (repl->r_mie) {
mie_ctx_destroy(repl->r_mie);
}
free(repl);
}
@@ -127,6 +133,12 @@ static enum ivy_status repl_create(struct repl **out)
memset(repl, 0x0, sizeof *repl);
repl->r_mie = mie_ctx_create();
if (!repl->r_mie) {
repl_destroy(repl);
return IVY_ERR_NO_MEMORY;
}
repl->r_ed = line_ed_create();
if (!repl->r_ed) {
repl_destroy(repl);
@@ -149,13 +161,14 @@ static enum ivy_status repl_create(struct repl **out)
return status;
}
status = ivy_codegen_create(&repl->r_codegen);
status = ivy_codegen_create(repl->r_mie, &repl->r_codegen);
if (status != IVY_OK) {
repl_destroy(repl);
return status;
}
repl->r_converter = mie_ir_converter_create(MIE_IR_MEM, MIE_IR_TEXT);
repl->r_converter
= mie_ir_converter_create(repl->r_mie, MIE_IR_MEM, MIE_IR_TEXT);
if (!repl->r_converter) {
repl_destroy(repl);
return IVY_ERR_NO_MEMORY;