frontend: update mie api usage to use new context parameter
This commit is contained in:
@@ -9,6 +9,7 @@
|
|||||||
#include <ivy/lang/codegen.h>
|
#include <ivy/lang/codegen.h>
|
||||||
#include <ivy/lang/lex.h>
|
#include <ivy/lang/lex.h>
|
||||||
#include <mie/convert.h>
|
#include <mie/convert.h>
|
||||||
|
#include <mie/ctx.h>
|
||||||
#include <mie/module.h>
|
#include <mie/module.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
@@ -77,8 +78,10 @@ static int compile_file(const char *path, const b_arglist *args)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct mie_ctx *ctx = mie_ctx_create();
|
||||||
|
|
||||||
struct ivy_codegen *codegen;
|
struct ivy_codegen *codegen;
|
||||||
status = ivy_codegen_create(&codegen);
|
status = ivy_codegen_create(ctx, &codegen);
|
||||||
|
|
||||||
if (status != IVY_OK) {
|
if (status != IVY_OK) {
|
||||||
b_err("failed to initialise Ivy code generator");
|
b_err("failed to initialise Ivy code generator");
|
||||||
@@ -170,7 +173,7 @@ static int compile_file(const char *path, const b_arglist *args)
|
|||||||
ivy_codegen_end_module(codegen, &mod);
|
ivy_codegen_end_module(codegen, &mod);
|
||||||
|
|
||||||
struct mie_ir_converter *convert
|
struct mie_ir_converter *convert
|
||||||
= mie_ir_converter_create(MIE_IR_MEM, MIE_IR_TEXT);
|
= mie_ir_converter_create(ctx, MIE_IR_MEM, MIE_IR_TEXT);
|
||||||
mie_ir_converter_set_src_value(convert, MIE_VALUE(mod));
|
mie_ir_converter_set_src_value(convert, MIE_VALUE(mod));
|
||||||
mie_ir_converter_set_dest_file(convert, stdout);
|
mie_ir_converter_set_dest_file(convert, stdout);
|
||||||
mie_ir_converter_process(convert);
|
mie_ir_converter_process(convert);
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
#include <ivy/lang/codegen.h>
|
#include <ivy/lang/codegen.h>
|
||||||
#include <ivy/lang/lex.h>
|
#include <ivy/lang/lex.h>
|
||||||
#include <mie/convert.h>
|
#include <mie/convert.h>
|
||||||
|
#include <mie/ctx.h>
|
||||||
#include <mie/value.h>
|
#include <mie/value.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@@ -21,6 +22,7 @@ enum {
|
|||||||
|
|
||||||
struct repl {
|
struct repl {
|
||||||
bool r_show_lex, r_show_ast, r_show_ir;
|
bool r_show_lex, r_show_ast, r_show_ir;
|
||||||
|
struct mie_ctx *r_mie;
|
||||||
struct line_ed *r_ed;
|
struct line_ed *r_ed;
|
||||||
struct ivy_lexer *r_lex;
|
struct ivy_lexer *r_lex;
|
||||||
struct ivy_parser *r_parse;
|
struct ivy_parser *r_parse;
|
||||||
@@ -115,6 +117,10 @@ static void repl_destroy(struct repl *repl)
|
|||||||
line_ed_destroy(repl->r_ed);
|
line_ed_destroy(repl->r_ed);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (repl->r_mie) {
|
||||||
|
mie_ctx_destroy(repl->r_mie);
|
||||||
|
}
|
||||||
|
|
||||||
free(repl);
|
free(repl);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -127,6 +133,12 @@ static enum ivy_status repl_create(struct repl **out)
|
|||||||
|
|
||||||
memset(repl, 0x0, sizeof *repl);
|
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();
|
repl->r_ed = line_ed_create();
|
||||||
if (!repl->r_ed) {
|
if (!repl->r_ed) {
|
||||||
repl_destroy(repl);
|
repl_destroy(repl);
|
||||||
@@ -149,13 +161,14 @@ static enum ivy_status repl_create(struct repl **out)
|
|||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
status = ivy_codegen_create(&repl->r_codegen);
|
status = ivy_codegen_create(repl->r_mie, &repl->r_codegen);
|
||||||
if (status != IVY_OK) {
|
if (status != IVY_OK) {
|
||||||
repl_destroy(repl);
|
repl_destroy(repl);
|
||||||
return status;
|
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) {
|
if (!repl->r_converter) {
|
||||||
repl_destroy(repl);
|
repl_destroy(repl);
|
||||||
return IVY_ERR_NO_MEMORY;
|
return IVY_ERR_NO_MEMORY;
|
||||||
|
|||||||
Reference in New Issue
Block a user