meta: replace bluelib references with fx
This commit is contained in:
@@ -3,10 +3,10 @@
|
||||
#include "cmd.h"
|
||||
|
||||
#include <assert.h>
|
||||
#include <blue/cmd.h>
|
||||
#include <blue/io/file.h>
|
||||
#include <blue/io/path.h>
|
||||
#include <blue/term.h>
|
||||
#include <fx/cmd.h>
|
||||
#include <fx/io/file.h>
|
||||
#include <fx/io/path.h>
|
||||
#include <fx/term.h>
|
||||
#include <mie/attribute/attribute-definition.h>
|
||||
#include <mie/ctx.h>
|
||||
#include <mie/dialect/arith.h>
|
||||
@@ -57,20 +57,20 @@ static void report_diag(struct mie_ctx *ctx)
|
||||
{
|
||||
struct mie_diag *diag = mie_ctx_pop_diag(ctx);
|
||||
while (diag) {
|
||||
mie_diag_write_pretty(diag, b_stdtty_err);
|
||||
mie_diag_write_pretty(diag, fx_stdtty_err);
|
||||
/* TODO cleanup */
|
||||
diag = mie_ctx_pop_diag(ctx);
|
||||
}
|
||||
}
|
||||
|
||||
static int optimise_file(
|
||||
const b_command *cmd, const char *path, const b_arglist *args)
|
||||
const fx_command *cmd, const char *path, const fx_arglist *args)
|
||||
{
|
||||
b_file *file = NULL;
|
||||
b_result result
|
||||
= b_file_open(NULL, B_RV_PATH(path), B_FILE_READ_ONLY, &file);
|
||||
if (b_result_is_error(result)) {
|
||||
b_throw(result);
|
||||
fx_file *file = NULL;
|
||||
fx_result result
|
||||
= fx_file_open(NULL, FX_RV_PATH(path), FX_FILE_READ_ONLY, &file);
|
||||
if (fx_result_is_error(result)) {
|
||||
fx_throw(result);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -129,19 +129,20 @@ static int optimise_file(
|
||||
|
||||
mie_pass_manager_add_pass(func_pm, prefix_func_with_underscore);
|
||||
|
||||
b_arglist_iterator it;
|
||||
b_arglist_foreach(&it, args)
|
||||
fx_arglist_iterator it;
|
||||
fx_arglist_foreach(&it, args)
|
||||
{
|
||||
if (it.opt_id < OPT_PASS_OFFSET) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const b_command_option *opt = b_command_get_option(cmd, it.opt_id);
|
||||
const fx_command_option *opt
|
||||
= fx_command_get_option(cmd, it.opt_id);
|
||||
if (!opt) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const char *pass_name = b_command_option_get_long_name(opt);
|
||||
const char *pass_name = fx_command_option_get_long_name(opt);
|
||||
struct mie_pass *pass = NULL;
|
||||
enum mie_status status
|
||||
= mie_ctx_get_pass(ctx, pass_name, NULL, &pass);
|
||||
@@ -160,16 +161,16 @@ static int optimise_file(
|
||||
mie_pass_manager_run(pm, root);
|
||||
|
||||
enum mie_print_flags flags = 0;
|
||||
if (b_arglist_get_count(args, OPT_GENERIC, B_COMMAND_INVALID_ID) > 0) {
|
||||
if (fx_arglist_get_count(args, OPT_GENERIC, FX_COMMAND_INVALID_ID) > 0) {
|
||||
flags |= MIE_PRINT_F_GENERIC;
|
||||
}
|
||||
|
||||
if (b_arglist_get_count(args, OPT_NO_ABBREV, B_COMMAND_INVALID_ID) == 0) {
|
||||
if (fx_arglist_get_count(args, OPT_NO_ABBREV, FX_COMMAND_INVALID_ID) == 0) {
|
||||
flags |= MIE_PRINT_F_ABBREVIATED;
|
||||
}
|
||||
|
||||
struct mie_printer printer;
|
||||
mie_printer_init(&printer, ctx, b_stdout, flags);
|
||||
mie_printer_init(&printer, ctx, fx_stdout, flags);
|
||||
mie_printer_print_op(&printer, root);
|
||||
printf("\n");
|
||||
|
||||
@@ -211,18 +212,18 @@ static int optimise_file(
|
||||
|
||||
mie_lex_destroy(lex);
|
||||
mie_line_source_cleanup(&src);
|
||||
b_file_unref(file);
|
||||
fx_file_unref(file);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int optimise(const b_command *cmd, const b_arglist *args, const b_array *_)
|
||||
int optimise(const fx_command *cmd, const fx_arglist *args, const fx_array *_)
|
||||
{
|
||||
b_arglist_iterator it;
|
||||
b_arglist_foreach_filtered(&it, args, B_COMMAND_INVALID_ID, ARG_FILEPATH)
|
||||
fx_arglist_iterator it;
|
||||
fx_arglist_foreach_filtered(&it, args, FX_COMMAND_INVALID_ID, ARG_FILEPATH)
|
||||
{
|
||||
b_arglist_value *path = it.value;
|
||||
if (path->val_type != B_COMMAND_ARG_STRING) {
|
||||
fx_arglist_value *path = it.value;
|
||||
if (path->val_type != FX_COMMAND_ARG_STRING) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -235,35 +236,35 @@ int optimise(const b_command *cmd, const b_arglist *args, const b_array *_)
|
||||
return 0;
|
||||
}
|
||||
|
||||
B_COMMAND(CMD_OPTIMISE, CMD_ROOT)
|
||||
FX_COMMAND(CMD_OPTIMISE, CMD_ROOT)
|
||||
{
|
||||
B_COMMAND_NAME("optimise");
|
||||
B_COMMAND_SHORT_NAME('O');
|
||||
B_COMMAND_DESC("optimise a mie ir file.");
|
||||
B_COMMAND_FLAGS(B_COMMAND_SHOW_HELP_BY_DEFAULT);
|
||||
B_COMMAND_FUNCTION(optimise);
|
||||
FX_COMMAND_NAME("optimise");
|
||||
FX_COMMAND_SHORT_NAME('O');
|
||||
FX_COMMAND_DESC("optimise a mie ir file.");
|
||||
FX_COMMAND_FLAGS(FX_COMMAND_SHOW_HELP_BY_DEFAULT);
|
||||
FX_COMMAND_FUNCTION(optimise);
|
||||
|
||||
B_COMMAND_HELP_OPTION();
|
||||
FX_COMMAND_HELP_OPTION();
|
||||
|
||||
B_COMMAND_ARG(ARG_FILEPATH)
|
||||
FX_COMMAND_ARG(ARG_FILEPATH)
|
||||
{
|
||||
B_ARG_NAME("filepath");
|
||||
B_ARG_DESC("the mie file to optimise");
|
||||
B_ARG_NR_VALUES(1);
|
||||
FX_ARG_NAME("filepath");
|
||||
FX_ARG_DESC("the mie file to optimise");
|
||||
FX_ARG_NR_VALUES(1);
|
||||
}
|
||||
|
||||
B_COMMAND_OPTION(OPT_GENERIC)
|
||||
FX_COMMAND_OPTION(OPT_GENERIC)
|
||||
{
|
||||
B_OPTION_LONG_NAME("generic");
|
||||
B_OPTION_SHORT_NAME('g');
|
||||
B_OPTION_DESC("print operations in generic format.");
|
||||
FX_OPTION_LONG_NAME("generic");
|
||||
FX_OPTION_SHORT_NAME('g');
|
||||
FX_OPTION_DESC("print operations in generic format.");
|
||||
}
|
||||
|
||||
B_COMMAND_OPTION(OPT_NO_ABBREV)
|
||||
FX_COMMAND_OPTION(OPT_NO_ABBREV)
|
||||
{
|
||||
B_OPTION_LONG_NAME("no-abbrev");
|
||||
B_OPTION_SHORT_NAME('n');
|
||||
B_OPTION_DESC(
|
||||
FX_OPTION_LONG_NAME("no-abbrev");
|
||||
FX_OPTION_SHORT_NAME('n');
|
||||
FX_OPTION_DESC(
|
||||
"don't use abbreviations for builtin types and ops.");
|
||||
}
|
||||
|
||||
@@ -271,19 +272,19 @@ B_COMMAND(CMD_OPTIMISE, CMD_ROOT)
|
||||
mie_builtin_passes_register(ctx);
|
||||
|
||||
size_t i = 0;
|
||||
b_btree_node *node = b_btree_first(&ctx->ctx_passes.map_entries);
|
||||
fx_bst_node *node = fx_bst_first(&ctx->ctx_passes.map_entries);
|
||||
while (node) {
|
||||
mie_id *id = b_unbox(mie_id, node, e_node);
|
||||
mie_id *id = fx_unbox(mie_id, node, e_node);
|
||||
struct mie_pass_definition *pass
|
||||
= b_unbox(struct mie_pass_definition, id, p_id);
|
||||
= fx_unbox(struct mie_pass_definition, id, p_id);
|
||||
|
||||
B_COMMAND_OPTION_GEN(OPT_PASS_OFFSET + i)
|
||||
FX_COMMAND_OPTION_GEN(OPT_PASS_OFFSET + i)
|
||||
{
|
||||
B_OPTION_LONG_NAME(pass->p_name);
|
||||
B_OPTION_DESC(pass->p_description);
|
||||
FX_OPTION_LONG_NAME(pass->p_name);
|
||||
FX_OPTION_DESC(pass->p_description);
|
||||
}
|
||||
|
||||
node = b_btree_next(node);
|
||||
node = fx_bst_next(node);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user