meta: replace bluelib references with fx
This commit is contained in:
@@ -12,9 +12,9 @@ add_executable(mie-tool ${tool_sources} ${rc_file})
|
||||
target_link_libraries(
|
||||
mie-tool
|
||||
mie
|
||||
Bluelib::Core
|
||||
Bluelib::Ds
|
||||
Bluelib::Cmd)
|
||||
FX::Core
|
||||
FX::Ds
|
||||
FX::Cmd)
|
||||
|
||||
set_target_properties(mie-tool PROPERTIES OUTPUT_NAME "mie")
|
||||
target_compile_definitions(mie-tool PRIVATE MIE_STATIC=${MIE_STATIC})
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include "../cmd.h"
|
||||
|
||||
#include <blue/cmd.h>
|
||||
#include <blue/term.h>
|
||||
#include <fx/cmd.h>
|
||||
#include <fx/term.h>
|
||||
#include <mie/attribute/attribute-definition.h>
|
||||
#include <mie/ctx.h>
|
||||
#include <mie/dialect/arith.h>
|
||||
@@ -27,7 +27,7 @@ enum {
|
||||
};
|
||||
|
||||
static int builder_test(
|
||||
const b_command *cmd, const b_arglist *args, const b_array *_)
|
||||
const fx_command *cmd, const fx_arglist *args, const fx_array *_)
|
||||
{
|
||||
struct mie_ctx *ctx = mie_ctx_create();
|
||||
mie_builtin_dialect_create(ctx);
|
||||
@@ -94,19 +94,20 @@ static int builder_test(
|
||||
struct mie_pass_manager *func_pm = mie_pass_manager_nest(pm);
|
||||
mie_pass_manager_filter_op(module_pm, "func", "func");
|
||||
|
||||
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);
|
||||
@@ -121,62 +122,62 @@ static int builder_test(
|
||||
mie_pass_manager_run(pm, module);
|
||||
|
||||
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, module);
|
||||
printf("\n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
B_COMMAND(CMD_INTERNAL_BUILDER_TEST, CMD_INTERNAL)
|
||||
FX_COMMAND(CMD_INTERNAL_BUILDER_TEST, CMD_INTERNAL)
|
||||
{
|
||||
B_COMMAND_NAME("builder-test");
|
||||
B_COMMAND_DESC("mie_builder test");
|
||||
B_COMMAND_FUNCTION(builder_test);
|
||||
FX_COMMAND_NAME("builder-test");
|
||||
FX_COMMAND_DESC("mie_builder test");
|
||||
FX_COMMAND_FUNCTION(builder_test);
|
||||
|
||||
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.");
|
||||
}
|
||||
|
||||
B_COMMAND_HELP_OPTION();
|
||||
FX_COMMAND_HELP_OPTION();
|
||||
|
||||
struct mie_ctx *ctx = mie_ctx_create();
|
||||
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++;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
#include "../cmd.h"
|
||||
|
||||
#include <assert.h>
|
||||
#include <blue/cmd.h>
|
||||
#include <blue/term.h>
|
||||
#include <fx/cmd.h>
|
||||
#include <fx/term.h>
|
||||
#include <mie/attribute/attribute-definition.h>
|
||||
#include <mie/ctx.h>
|
||||
#include <mie/diag/class.h>
|
||||
@@ -35,7 +35,7 @@ static void mie_op_definition_print(const struct mie_op_definition *op)
|
||||
{
|
||||
char id_str[MIE_ID_STRING_MAX];
|
||||
mie_id_to_string(&op->op_id, id_str, sizeof id_str);
|
||||
b_printf(
|
||||
fx_printf(
|
||||
" [bold,red]Op:[reset]%-20s [dark_grey]{%s}[reset]\n",
|
||||
op->op_name, id_str);
|
||||
}
|
||||
@@ -44,7 +44,7 @@ static void mie_type_definition_print(const struct mie_type_definition *type)
|
||||
{
|
||||
char id_str[MIE_ID_STRING_MAX];
|
||||
mie_id_to_string(&type->ty_id, id_str, sizeof id_str);
|
||||
b_printf(
|
||||
fx_printf(
|
||||
" [bold,blue]Ty:[reset]%-20s [dark_grey]{%s}[reset]\n",
|
||||
type->ty_name, id_str);
|
||||
}
|
||||
@@ -53,7 +53,7 @@ static void mie_trait_definition_print(const struct mie_trait_definition *trait)
|
||||
{
|
||||
char id_str[MIE_ID_STRING_MAX];
|
||||
mie_id_to_string(&trait->tr_id, id_str, sizeof id_str);
|
||||
b_printf(
|
||||
fx_printf(
|
||||
" [bold,yellow]Tr:[reset]%-20s [dark_grey]{%s}[reset]\n",
|
||||
trait->tr_name, id_str);
|
||||
}
|
||||
@@ -63,7 +63,7 @@ static void mie_attribute_definition_print(
|
||||
{
|
||||
char id_str[MIE_ID_STRING_MAX];
|
||||
mie_id_to_string(&attribute->a_id, id_str, sizeof id_str);
|
||||
b_printf(
|
||||
fx_printf(
|
||||
" [bold,magenta]At:[reset]%-20s [dark_grey]{%s}[reset]\n",
|
||||
attribute->a_name, id_str);
|
||||
}
|
||||
@@ -73,7 +73,7 @@ static void mie_interface_definition_print(
|
||||
{
|
||||
char id_str[MIE_ID_STRING_MAX];
|
||||
mie_id_to_string(&interface->if_id, id_str, sizeof id_str);
|
||||
b_printf(
|
||||
fx_printf(
|
||||
" [bold,cyan]If:[reset]%-20s [dark_grey]{%s}[reset]\n",
|
||||
interface->if_name, id_str);
|
||||
}
|
||||
@@ -82,7 +82,7 @@ static void mie_pass_definition_print(const struct mie_pass_definition *interfac
|
||||
{
|
||||
char id_str[MIE_ID_STRING_MAX];
|
||||
mie_id_to_string(&interface->p_id, id_str, sizeof id_str);
|
||||
b_printf(
|
||||
fx_printf(
|
||||
" [bold,cyan]Ps:[reset]%-20s [dark_grey]{%s}[reset]\n",
|
||||
interface->p_name, id_str);
|
||||
}
|
||||
@@ -92,19 +92,19 @@ static void mie_diag_class_print(
|
||||
{
|
||||
switch (c->c_type) {
|
||||
case MIE_DIAG_CLASS_HINT:
|
||||
b_printf(" [bold,cyan]Hint:[reset]");
|
||||
fx_printf(" [bold,cyan]Hint:[reset]");
|
||||
break;
|
||||
case MIE_DIAG_CLASS_WARNING:
|
||||
b_printf(" [bold,yellow]Warn:[reset]");
|
||||
fx_printf(" [bold,yellow]Warn:[reset]");
|
||||
break;
|
||||
case MIE_DIAG_CLASS_ERROR:
|
||||
b_printf(" [bold,red]Err: [reset]");
|
||||
fx_printf(" [bold,red]Err: [reset]");
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
b_printf(
|
||||
fx_printf(
|
||||
"%s.%-25s [green]%s[reset]\n", dialect->d_name,
|
||||
c->c_id_str_short, c->c_title);
|
||||
}
|
||||
@@ -112,7 +112,11 @@ static void mie_diag_class_print(
|
||||
static void mie_diag_msg_print(
|
||||
const struct mie_dialect *dialect, const struct mie_diag_msg *msg)
|
||||
{
|
||||
b_printf(
|
||||
if (!msg->msg_id_str_short || !msg->msg_content) {
|
||||
return;
|
||||
}
|
||||
|
||||
fx_printf(
|
||||
" [bold,blue]Msg: [reset]%s.%-25s [green]%s[reset]\n",
|
||||
dialect->d_name, msg->msg_id_str_short, msg->msg_content);
|
||||
}
|
||||
@@ -121,105 +125,110 @@ static void mie_dialect_print(const struct mie_dialect *dialect)
|
||||
{
|
||||
char id_str[MIE_ID_STRING_MAX];
|
||||
mie_id_to_string(&dialect->d_id, id_str, sizeof id_str);
|
||||
b_printf(
|
||||
fx_printf(
|
||||
"[bold,green]D:[reset]%-20s [dark_grey]{%s}[reset]\n",
|
||||
dialect->d_name, id_str);
|
||||
|
||||
b_btree_node *node = b_btree_first(&dialect->d_ops.map_entries);
|
||||
fx_bst_node *node = fx_bst_first(&dialect->d_ops.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_op_definition *op
|
||||
= b_unbox(struct mie_op_definition, id, op_id);
|
||||
= fx_unbox(struct mie_op_definition, id, op_id);
|
||||
|
||||
mie_op_definition_print(op);
|
||||
node = b_btree_next(node);
|
||||
node = fx_bst_next(node);
|
||||
}
|
||||
|
||||
node = b_btree_first(&dialect->d_types.map_entries);
|
||||
node = fx_bst_first(&dialect->d_types.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_type_definition *type
|
||||
= b_unbox(struct mie_type_definition, id, ty_id);
|
||||
= fx_unbox(struct mie_type_definition, id, ty_id);
|
||||
|
||||
mie_type_definition_print(type);
|
||||
node = b_btree_next(node);
|
||||
node = fx_bst_next(node);
|
||||
}
|
||||
|
||||
node = b_btree_first(&dialect->d_traits.map_entries);
|
||||
node = fx_bst_first(&dialect->d_traits.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_trait_definition *trait
|
||||
= b_unbox(struct mie_trait_definition, id, tr_id);
|
||||
= fx_unbox(struct mie_trait_definition, id, tr_id);
|
||||
|
||||
mie_trait_definition_print(trait);
|
||||
node = b_btree_next(node);
|
||||
node = fx_bst_next(node);
|
||||
}
|
||||
|
||||
node = b_btree_first(&dialect->d_attributes.map_entries);
|
||||
node = fx_bst_first(&dialect->d_attributes.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_attribute_definition *attribute
|
||||
= b_unbox(struct mie_attribute_definition, id, a_id);
|
||||
= fx_unbox(struct mie_attribute_definition, id, a_id);
|
||||
|
||||
mie_attribute_definition_print(attribute);
|
||||
node = b_btree_next(node);
|
||||
node = fx_bst_next(node);
|
||||
}
|
||||
|
||||
node = b_btree_first(&dialect->d_interfaces.map_entries);
|
||||
node = fx_bst_first(&dialect->d_interfaces.map_entries);
|
||||
while (node) {
|
||||
mie_id *id = b_unbox(mie_id, node, e_node);
|
||||
struct mie_interface_definition *interface = b_unbox(
|
||||
mie_id *id = fx_unbox(mie_id, node, e_node);
|
||||
struct mie_interface_definition *interface = fx_unbox(
|
||||
struct mie_interface_definition, id, if_id);
|
||||
|
||||
mie_interface_definition_print(interface);
|
||||
node = b_btree_next(node);
|
||||
node = fx_bst_next(node);
|
||||
}
|
||||
}
|
||||
|
||||
static void mie_ctx_print(const struct mie_ctx *ctx)
|
||||
{
|
||||
printf("Dialects:\n");
|
||||
b_btree_node *node = b_btree_first(&ctx->ctx_dialects.map_entries);
|
||||
fx_bst_node *node = fx_bst_first(&ctx->ctx_dialects.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_dialect *dialect
|
||||
= b_unbox(struct mie_dialect, id, d_id);
|
||||
= fx_unbox(struct mie_dialect, id, d_id);
|
||||
|
||||
mie_dialect_print(dialect);
|
||||
node = b_btree_next(node);
|
||||
node = fx_bst_next(node);
|
||||
}
|
||||
|
||||
printf("\nPasses:\n");
|
||||
node = b_btree_first(&ctx->ctx_passes.map_entries);
|
||||
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);
|
||||
|
||||
mie_pass_definition_print(pass);
|
||||
node = b_btree_next(node);
|
||||
node = fx_bst_next(node);
|
||||
}
|
||||
|
||||
printf("\nDiagnostics:\n");
|
||||
node = b_btree_first(&ctx->ctx_dialects.map_entries);
|
||||
node = fx_bst_first(&ctx->ctx_dialects.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_dialect *dialect
|
||||
= b_unbox(struct mie_dialect, id, d_id);
|
||||
= fx_unbox(struct mie_dialect, id, d_id);
|
||||
|
||||
for (size_t i = 0; i < dialect->d_nr_diag_classes; i++) {
|
||||
mie_diag_class_print(dialect, &dialect->d_diag_classes[i]);
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < dialect->d_nr_diag_msgs; i++) {
|
||||
if (!dialect->d_diag_msgs[i].msg_content) {
|
||||
printf(" [%zu] NULL\n", i);
|
||||
}
|
||||
|
||||
mie_diag_msg_print(dialect, &dialect->d_diag_msgs[i]);
|
||||
}
|
||||
|
||||
node = b_btree_next(node);
|
||||
node = fx_bst_next(node);
|
||||
}
|
||||
}
|
||||
|
||||
static int ctx_dump(const b_command *cmd, const b_arglist *args, const b_array *_)
|
||||
static int ctx_dump(
|
||||
const fx_command *cmd, const fx_arglist *args, const fx_array *_)
|
||||
{
|
||||
struct mie_ctx *ctx = mie_ctx_create();
|
||||
mie_builtin_dialect_create(ctx);
|
||||
@@ -267,7 +276,7 @@ static int ctx_dump(const b_command *cmd, const b_arglist *args, const b_array *
|
||||
sizeof func_out_parts / sizeof *func_out_parts));
|
||||
|
||||
struct mie_printer printer;
|
||||
mie_printer_init(&printer, ctx, b_stdout, MIE_PRINT_F_ABBREVIATED);
|
||||
mie_printer_init(&printer, ctx, fx_stdout, MIE_PRINT_F_ABBREVIATED);
|
||||
|
||||
char id_str[MIE_ID_STRING_MAX];
|
||||
mie_id_to_string(&i32->ty_id, id_str, sizeof id_str);
|
||||
@@ -304,11 +313,11 @@ static int ctx_dump(const b_command *cmd, const b_arglist *args, const b_array *
|
||||
return 0;
|
||||
}
|
||||
|
||||
B_COMMAND(CMD_INTERNAL_CTX_DUMP, CMD_INTERNAL)
|
||||
FX_COMMAND(CMD_INTERNAL_CTX_DUMP, CMD_INTERNAL)
|
||||
{
|
||||
B_COMMAND_NAME("ctx-dump");
|
||||
B_COMMAND_DESC("mie_ctx dump");
|
||||
B_COMMAND_FUNCTION(ctx_dump);
|
||||
FX_COMMAND_NAME("ctx-dump");
|
||||
FX_COMMAND_DESC("mie_ctx dump");
|
||||
FX_COMMAND_FUNCTION(ctx_dump);
|
||||
|
||||
B_COMMAND_HELP_OPTION();
|
||||
FX_COMMAND_HELP_OPTION();
|
||||
}
|
||||
|
||||
@@ -1,20 +1,21 @@
|
||||
#include "../cmd.h"
|
||||
|
||||
#include <blue/cmd.h>
|
||||
#include <blue/term.h>
|
||||
#include <fx/cmd.h>
|
||||
#include <fx/term.h>
|
||||
|
||||
static int internal(const b_command *cmd, const b_arglist *args, const b_array *_)
|
||||
static int internal(
|
||||
const fx_command *cmd, const fx_arglist *args, const fx_array *_)
|
||||
{
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
B_COMMAND(CMD_INTERNAL, CMD_ROOT)
|
||||
FX_COMMAND(CMD_INTERNAL, CMD_ROOT)
|
||||
{
|
||||
B_COMMAND_SHORT_NAME('X');
|
||||
B_COMMAND_DESC("internal frontend debugging tools.");
|
||||
B_COMMAND_FUNCTION(internal);
|
||||
B_COMMAND_FLAGS(B_COMMAND_SHOW_HELP_BY_DEFAULT);
|
||||
FX_COMMAND_SHORT_NAME('X');
|
||||
FX_COMMAND_DESC("internal frontend debugging tools.");
|
||||
FX_COMMAND_FUNCTION(internal);
|
||||
FX_COMMAND_FLAGS(FX_COMMAND_SHOW_HELP_BY_DEFAULT);
|
||||
|
||||
B_COMMAND_HELP_OPTION();
|
||||
FX_COMMAND_HELP_OPTION();
|
||||
}
|
||||
|
||||
@@ -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++;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
#include "cmd.h"
|
||||
|
||||
#include <blue/cmd.h>
|
||||
#include <fx/cmd.h>
|
||||
|
||||
B_COMMAND(CMD_ROOT, B_COMMAND_INVALID_ID)
|
||||
FX_COMMAND(CMD_ROOT, FX_COMMAND_INVALID_ID)
|
||||
{
|
||||
B_COMMAND_NAME("mie");
|
||||
B_COMMAND_DESC("Mie IR manipulation tool.");
|
||||
B_COMMAND_HELP_OPTION();
|
||||
B_COMMAND_FLAGS(B_COMMAND_SHOW_HELP_BY_DEFAULT);
|
||||
FX_COMMAND_NAME("mie");
|
||||
FX_COMMAND_DESC("Mie IR manipulation tool.");
|
||||
FX_COMMAND_HELP_OPTION();
|
||||
FX_COMMAND_FLAGS(FX_COMMAND_SHOW_HELP_BY_DEFAULT);
|
||||
|
||||
B_COMMAND_USAGE()
|
||||
{
|
||||
B_COMMAND_USAGE_COMMAND_PLACEHOLDER();
|
||||
B_COMMAND_USAGE_OPT_PLACEHOLDER();
|
||||
B_COMMAND_USAGE_ARG_PLACEHOLDER();
|
||||
}
|
||||
FX_COMMAND_USAGE()
|
||||
{
|
||||
FX_COMMAND_USAGE_COMMAND_PLACEHOLDER();
|
||||
FX_COMMAND_USAGE_OPT_PLACEHOLDER();
|
||||
FX_COMMAND_USAGE_ARG_PLACEHOLDER();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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>
|
||||
@@ -51,19 +51,19 @@ 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 validate_file(const char *path, const b_arglist *args)
|
||||
static int validate_file(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;
|
||||
}
|
||||
|
||||
@@ -130,7 +130,7 @@ static int validate_file(const char *path, const b_arglist *args)
|
||||
|
||||
struct mie_printer printer;
|
||||
mie_printer_init(
|
||||
&printer, ctx, b_stdout,
|
||||
&printer, ctx, fx_stdout,
|
||||
MIE_PRINT_F_ABBREVIATED | MIE_PRINT_F_MARK_UNRESOLVED_ELEMENTS);
|
||||
mie_printer_print_op(&printer, root);
|
||||
printf("\n");
|
||||
@@ -216,18 +216,18 @@ static int validate_file(const char *path, const b_arglist *args)
|
||||
|
||||
mie_line_source_cleanup(&src);
|
||||
|
||||
b_file_unref(file);
|
||||
fx_file_unref(file);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int validate(const b_command *cmd, const b_arglist *args, const b_array *_)
|
||||
int validate(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;
|
||||
}
|
||||
|
||||
@@ -240,21 +240,21 @@ int validate(const b_command *cmd, const b_arglist *args, const b_array *_)
|
||||
return 0;
|
||||
}
|
||||
|
||||
B_COMMAND(CMD_VALIDATE, CMD_ROOT)
|
||||
FX_COMMAND(CMD_VALIDATE, CMD_ROOT)
|
||||
{
|
||||
B_COMMAND_NAME("validate");
|
||||
B_COMMAND_SHORT_NAME('V');
|
||||
B_COMMAND_DESC("validate a mie ir file.");
|
||||
B_COMMAND_HELP_OPTION();
|
||||
B_COMMAND_FLAGS(B_COMMAND_SHOW_HELP_BY_DEFAULT);
|
||||
B_COMMAND_FUNCTION(validate);
|
||||
FX_COMMAND_NAME("validate");
|
||||
FX_COMMAND_SHORT_NAME('V');
|
||||
FX_COMMAND_DESC("validate a mie ir file.");
|
||||
FX_COMMAND_HELP_OPTION();
|
||||
FX_COMMAND_FLAGS(FX_COMMAND_SHOW_HELP_BY_DEFAULT);
|
||||
FX_COMMAND_FUNCTION(validate);
|
||||
|
||||
B_COMMAND_ARG(ARG_FILEPATH)
|
||||
FX_COMMAND_ARG(ARG_FILEPATH)
|
||||
{
|
||||
B_ARG_NAME("filepath");
|
||||
B_ARG_DESC("the mie file to validate");
|
||||
B_ARG_NR_VALUES(1);
|
||||
FX_ARG_NAME("filepath");
|
||||
FX_ARG_DESC("the mie file to validate");
|
||||
FX_ARG_NR_VALUES(1);
|
||||
}
|
||||
|
||||
B_COMMAND_HELP_OPTION();
|
||||
FX_COMMAND_HELP_OPTION();
|
||||
}
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
#ifndef _TOOL_DIAG_DIAG_H_
|
||||
#define _TOOL_DIAG_DIAG_H_
|
||||
|
||||
#include <blue/term/tty.h>
|
||||
#include <fx/term/tty.h>
|
||||
#include <mie/status.h>
|
||||
|
||||
struct mie_diag;
|
||||
|
||||
extern enum mie_status mie_diag_write_pretty(struct mie_diag *diag, b_tty *stream);
|
||||
extern enum mie_status mie_diag_write_pretty(struct mie_diag *diag, fx_tty *stream);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include <assert.h>
|
||||
#include <blue/core/stringstream.h>
|
||||
#include <blue/term/print.h>
|
||||
#include <blue/term/tty.h>
|
||||
#include <fx/core/stringstream.h>
|
||||
#include <fx/term/print.h>
|
||||
#include <fx/term/tty.h>
|
||||
#include <ctype.h>
|
||||
#include <mie/diag/amendment.h>
|
||||
#include <mie/diag/class.h>
|
||||
@@ -15,16 +15,16 @@
|
||||
#define GET_CHAR_CONTINUE -1
|
||||
|
||||
struct snippet_print_ctx {
|
||||
b_tty *ctx_stream;
|
||||
fx_tty *ctx_stream;
|
||||
struct mie_line_source *ctx_line_source;
|
||||
|
||||
size_t ctx_row, ctx_col;
|
||||
size_t ctx_indent_offset;
|
||||
|
||||
bool ctx_has_underline, ctx_in_content;
|
||||
b_stringstream *ctx_underline;
|
||||
const b_string *ctx_linebuf;
|
||||
const b_iterator *ctx_linebuf_ptr;
|
||||
fx_stringstream *ctx_underline;
|
||||
const fx_string *ctx_linebuf;
|
||||
const fx_iterator *ctx_linebuf_ptr;
|
||||
|
||||
struct mie_diag_c_snippet *ctx_snippet;
|
||||
|
||||
@@ -40,31 +40,31 @@ struct snippet_print_ctx {
|
||||
#define __STREAM_COLOUR_RESET "[reset]"
|
||||
|
||||
#define STREAM_COLOUR_ERROR(stream) \
|
||||
b_tty_puts(stream, 0, __STREAM_COLOUR_ERROR);
|
||||
#define STREAM_COLOUR_WARN(stream) b_tty_puts(stream, 0, __STREAM_COLOUR_WARN);
|
||||
#define STREAM_COLOUR_HINT(stream) b_tty_puts(stream, 0, __STREAM_COLOUR_HINT);
|
||||
fx_tty_puts(stream, 0, __STREAM_COLOUR_ERROR);
|
||||
#define STREAM_COLOUR_WARN(stream) fx_tty_puts(stream, 0, __STREAM_COLOUR_WARN);
|
||||
#define STREAM_COLOUR_HINT(stream) fx_tty_puts(stream, 0, __STREAM_COLOUR_HINT);
|
||||
#define STREAM_COLOUR_ACCENT(stream) \
|
||||
b_tty_puts(stream, 0, __STREAM_COLOUR_ACCENT);
|
||||
fx_tty_puts(stream, 0, __STREAM_COLOUR_ACCENT);
|
||||
#define STREAM_COLOUR_LINE_NO(stream) \
|
||||
b_tty_puts(stream, 0, __STREAM_COLOUR_LINE_NO);
|
||||
fx_tty_puts(stream, 0, __STREAM_COLOUR_LINE_NO);
|
||||
#define STREAM_COLOUR_RESET(stream) \
|
||||
b_tty_puts(stream, 0, __STREAM_COLOUR_RESET);
|
||||
fx_tty_puts(stream, 0, __STREAM_COLOUR_RESET);
|
||||
|
||||
#define STREAM_COLOUR_ERROR_B(stream, str) \
|
||||
b_stream_write_string(str, __STREAM_COLOUR_ERROR, NULL);
|
||||
fx_stream_write_string(str, __STREAM_COLOUR_ERROR, NULL);
|
||||
#define STREAM_COLOUR_WARN_B(stream, str) \
|
||||
b_stream_write_string(str, __STREAM_COLOUR_WARN, NULL);
|
||||
fx_stream_write_string(str, __STREAM_COLOUR_WARN, NULL);
|
||||
#define STREAM_COLOUR_HINT_B(stream, str) \
|
||||
b_stream_write_string(str, __STREAM_COLOUR_HINT, NULL);
|
||||
fx_stream_write_string(str, __STREAM_COLOUR_HINT, NULL);
|
||||
#define STREAM_COLOUR_ACCENT_B(stream, str) \
|
||||
b_stream_write_string(str, __STREAM_COLOUR_ACCENT, NULL);
|
||||
fx_stream_write_string(str, __STREAM_COLOUR_ACCENT, NULL);
|
||||
#define STREAM_COLOUR_RESET_B(stream, str) \
|
||||
b_stream_write_string(str, __STREAM_COLOUR_RESET, NULL);
|
||||
fx_stream_write_string(str, __STREAM_COLOUR_RESET, NULL);
|
||||
|
||||
static void print_header(struct mie_diag *diag, b_tty *dest)
|
||||
static void print_header(struct mie_diag *diag, fx_tty *dest)
|
||||
{
|
||||
unsigned int w;
|
||||
b_tty_get_dimensions(dest, &w, NULL);
|
||||
fx_tty_get_dimensions(dest, &w, NULL);
|
||||
|
||||
const struct mie_diag_class *diag_class = diag->diag_class;
|
||||
assert(diag_class);
|
||||
@@ -72,51 +72,51 @@ static void print_header(struct mie_diag *diag, b_tty *dest)
|
||||
STREAM_COLOUR_ACCENT(dest);
|
||||
|
||||
size_t nr_written = 0;
|
||||
nr_written += b_tty_puts(dest, 0, "--- ");
|
||||
nr_written += fx_tty_puts(dest, 0, "--- ");
|
||||
|
||||
const char *s = diag_class->c_title;
|
||||
while (*s) {
|
||||
b_tty_putc(dest, 0, toupper(*s));
|
||||
fx_tty_putc(dest, 0, toupper(*s));
|
||||
s++;
|
||||
nr_written++;
|
||||
}
|
||||
|
||||
b_tty_putc(dest, 0, ' ');
|
||||
fx_tty_putc(dest, 0, ' ');
|
||||
nr_written++;
|
||||
|
||||
while (nr_written < w) {
|
||||
b_tty_putc(dest, 0, '-');
|
||||
fx_tty_putc(dest, 0, '-');
|
||||
nr_written++;
|
||||
}
|
||||
|
||||
STREAM_COLOUR_RESET(dest);
|
||||
|
||||
b_tty_putc(dest, 0, '\n');
|
||||
fx_tty_putc(dest, 0, '\n');
|
||||
}
|
||||
|
||||
static void print_location(struct mie_diag *diag, b_tty *out)
|
||||
static void print_location(struct mie_diag *diag, fx_tty *out)
|
||||
{
|
||||
size_t x;
|
||||
const char *name = mie_line_source_get_path(diag->diag_src);
|
||||
|
||||
b_tty_puts(out, 0, " ");
|
||||
fx_tty_puts(out, 0, " ");
|
||||
STREAM_COLOUR_ACCENT(out);
|
||||
b_tty_puts(out, 0, "> ");
|
||||
fx_tty_puts(out, 0, "> ");
|
||||
STREAM_COLOUR_RESET(out);
|
||||
b_tty_printf(
|
||||
fx_tty_printf(
|
||||
out, 0, "%s:%lu:%lu\n", name, diag->diag_loc.c_row,
|
||||
diag->diag_loc.c_col);
|
||||
}
|
||||
|
||||
static void print_msg(
|
||||
struct mie_diag *diag, struct mie_diag_c_msg *msg, b_tty *stream)
|
||||
struct mie_diag *diag, struct mie_diag_c_msg *msg, fx_tty *stream)
|
||||
{
|
||||
b_paragraph_format format = {
|
||||
fx_paragraph_format format = {
|
||||
.p_left_margin = 2,
|
||||
.p_right_margin = 2,
|
||||
};
|
||||
|
||||
b_print_paragraph(msg->msg_content, stream, &format);
|
||||
fx_print_paragraph(msg->msg_content, stream, &format);
|
||||
}
|
||||
|
||||
static bool highlight_contains_cell(
|
||||
@@ -181,7 +181,7 @@ static bool amendment_contains_cell(
|
||||
}
|
||||
|
||||
limit = a->a_replace.a_loc.c_row
|
||||
+ b_max(ulong, a->a_replace.a_length, a->__x) - 1;
|
||||
+ fx_max(ulong, a->a_replace.a_length, a->__x) - 1;
|
||||
|
||||
if (col > limit) {
|
||||
return false;
|
||||
@@ -280,7 +280,7 @@ static void update_highlighting(struct snippet_print_ctx *ctx)
|
||||
static enum mie_status read_row(struct snippet_print_ctx *ctx, size_t row)
|
||||
{
|
||||
if (ctx->ctx_linebuf_ptr) {
|
||||
b_iterator_unref(ctx->ctx_linebuf_ptr);
|
||||
fx_iterator_unref(ctx->ctx_linebuf_ptr);
|
||||
ctx->ctx_linebuf_ptr = NULL;
|
||||
}
|
||||
|
||||
@@ -293,7 +293,7 @@ static enum mie_status read_row(struct snippet_print_ctx *ctx, size_t row)
|
||||
return status;
|
||||
}
|
||||
|
||||
ctx->ctx_linebuf_ptr = b_iterator_cbegin(ctx->ctx_linebuf);
|
||||
ctx->ctx_linebuf_ptr = fx_iterator_cbegin(ctx->ctx_linebuf);
|
||||
return MIE_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -309,7 +309,7 @@ static int get_char_amendment(struct snippet_print_ctx *ctx)
|
||||
- 1;
|
||||
return a->a_add.a_str[i];
|
||||
case MIE_DIAG_AMENDMENT_REMOVE:
|
||||
b_iterator_move_next(ctx->ctx_linebuf_ptr);
|
||||
fx_iterator_move_next(ctx->ctx_linebuf_ptr);
|
||||
return GET_CHAR_CONTINUE;
|
||||
case MIE_DIAG_AMENDMENT_REPLACE:
|
||||
i = ctx->ctx_col - a->a_add.a_loc.c_col;
|
||||
@@ -320,7 +320,7 @@ static int get_char_amendment(struct snippet_print_ctx *ctx)
|
||||
|
||||
c = a->a_replace.a_str[i];
|
||||
if (i < a->a_replace.a_length) {
|
||||
b_iterator_move_next(ctx->ctx_linebuf_ptr);
|
||||
fx_iterator_move_next(ctx->ctx_linebuf_ptr);
|
||||
}
|
||||
|
||||
if (c != 0) {
|
||||
@@ -341,15 +341,15 @@ static int get_char(struct snippet_print_ctx *ctx)
|
||||
return get_char_amendment(ctx);
|
||||
}
|
||||
|
||||
b_wchar c = B_WCHAR_INVALID;
|
||||
fx_wchar c = FX_WCHAR_INVALID;
|
||||
|
||||
while (1) {
|
||||
c = b_iterator_get_cvalue(ctx->ctx_linebuf_ptr).v_int;
|
||||
if (c == B_WCHAR_INVALID) {
|
||||
c = fx_iterator_get_cvalue(ctx->ctx_linebuf_ptr).v_int;
|
||||
if (c == FX_WCHAR_INVALID) {
|
||||
return GET_CHAR_STOP;
|
||||
}
|
||||
|
||||
b_iterator_move_next(ctx->ctx_linebuf_ptr);
|
||||
fx_iterator_move_next(ctx->ctx_linebuf_ptr);
|
||||
|
||||
if (isspace(c) && !ctx->ctx_in_content) {
|
||||
ctx->ctx_indent_offset++;
|
||||
@@ -364,7 +364,7 @@ static int get_char(struct snippet_print_ctx *ctx)
|
||||
static void update_underline(struct snippet_print_ctx *ctx)
|
||||
{
|
||||
if (!ctx->ctx_hl) {
|
||||
b_stream_write_char(ctx->ctx_underline, ' ');
|
||||
fx_stream_write_char(ctx->ctx_underline, ' ');
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -372,10 +372,10 @@ static void update_underline(struct snippet_print_ctx *ctx)
|
||||
case MIE_DIAG_HIGHLIGHT_ERROR:
|
||||
case MIE_DIAG_HIGHLIGHT_WARNING:
|
||||
case MIE_DIAG_HIGHLIGHT_HINT:
|
||||
b_stream_write_char(ctx->ctx_underline, '^');
|
||||
fx_stream_write_char(ctx->ctx_underline, '^');
|
||||
break;
|
||||
default:
|
||||
b_stream_write_char(ctx->ctx_underline, ' ');
|
||||
fx_stream_write_char(ctx->ctx_underline, ' ');
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -388,28 +388,28 @@ static void write_underline(struct snippet_print_ctx *ctx)
|
||||
|
||||
STREAM_COLOUR_RESET(ctx->ctx_stream);
|
||||
STREAM_COLOUR_LINE_NO(ctx->ctx_stream);
|
||||
b_tty_puts(ctx->ctx_stream, 0, " : ");
|
||||
b_tty_puts(ctx->ctx_stream, 0, b_stringstream_ptr(ctx->ctx_underline));
|
||||
fx_tty_puts(ctx->ctx_stream, 0, " : ");
|
||||
fx_tty_puts(ctx->ctx_stream, 0, fx_stringstream_ptr(ctx->ctx_underline));
|
||||
STREAM_COLOUR_RESET(ctx->ctx_stream);
|
||||
b_tty_putc(ctx->ctx_stream, 0, '\n');
|
||||
fx_tty_putc(ctx->ctx_stream, 0, '\n');
|
||||
}
|
||||
|
||||
static void print_snippet(
|
||||
struct mie_diag *diag, struct mie_diag_c_snippet *snippet, b_tty *stream)
|
||||
struct mie_diag *diag, struct mie_diag_c_snippet *snippet, fx_tty *stream)
|
||||
{
|
||||
enum mie_status status = MIE_SUCCESS;
|
||||
|
||||
struct snippet_print_ctx printer = {
|
||||
.ctx_stream = stream,
|
||||
.ctx_snippet = snippet,
|
||||
.ctx_underline = b_stringstream_create(),
|
||||
.ctx_underline = fx_stringstream_create(),
|
||||
.ctx_line_source = diag->diag_src,
|
||||
};
|
||||
|
||||
for (unsigned long row = snippet->s_first_line;
|
||||
row <= snippet->s_last_line; row++) {
|
||||
STREAM_COLOUR_LINE_NO(stream);
|
||||
b_tty_printf(stream, 0, " %4lu | ", row);
|
||||
fx_tty_printf(stream, 0, " %4lu | ", row);
|
||||
printer.ctx_row = row;
|
||||
|
||||
status = read_row(&printer, row);
|
||||
@@ -433,23 +433,23 @@ static void print_snippet(
|
||||
update_highlighting(&printer);
|
||||
|
||||
if (c == '[') {
|
||||
b_tty_putc(stream, 0, c);
|
||||
fx_tty_putc(stream, 0, c);
|
||||
}
|
||||
|
||||
b_tty_putc(stream, 0, c);
|
||||
fx_tty_putc(stream, 0, c);
|
||||
|
||||
update_underline(&printer);
|
||||
}
|
||||
|
||||
b_tty_putc(stream, 0, '\n');
|
||||
fx_tty_putc(stream, 0, '\n');
|
||||
write_underline(&printer);
|
||||
}
|
||||
|
||||
b_stringstream_unref(printer.ctx_underline);
|
||||
fx_stringstream_unref(printer.ctx_underline);
|
||||
}
|
||||
|
||||
static void print_component(
|
||||
struct mie_diag *diag, struct mie_diag_component *component, b_tty *stream)
|
||||
struct mie_diag *diag, struct mie_diag_component *component, fx_tty *stream)
|
||||
{
|
||||
switch (component->c_type) {
|
||||
case MIE_DIAG_COMPONENT_MSG:
|
||||
@@ -463,20 +463,20 @@ static void print_component(
|
||||
}
|
||||
}
|
||||
|
||||
enum mie_status mie_diag_write_pretty(struct mie_diag *diag, b_tty *stream)
|
||||
enum mie_status mie_diag_write_pretty(struct mie_diag *diag, fx_tty *stream)
|
||||
{
|
||||
print_header(diag, stream);
|
||||
print_location(diag, stream);
|
||||
|
||||
b_queue_entry *entry = b_queue_first(&diag->diag_components);
|
||||
fx_queue_entry *entry = fx_queue_first(&diag->diag_components);
|
||||
while (entry) {
|
||||
struct mie_diag_component *c
|
||||
= b_unbox(struct mie_diag_component, entry, c_entry);
|
||||
= fx_unbox(struct mie_diag_component, entry, c_entry);
|
||||
|
||||
b_tty_putc(stream, 0, '\n');
|
||||
fx_tty_putc(stream, 0, '\n');
|
||||
print_component(diag, c, stream);
|
||||
|
||||
entry = b_queue_next(entry);
|
||||
entry = fx_queue_next(entry);
|
||||
}
|
||||
|
||||
return MIE_SUCCESS;
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
#include "cmd/cmd.h"
|
||||
|
||||
#include <blue/cmd.h>
|
||||
#include <fx/cmd.h>
|
||||
#include <mie/id.h>
|
||||
#include <stdio.h>
|
||||
|
||||
int main(int argc, const char **argv)
|
||||
{
|
||||
return b_command_dispatch(CMD_ROOT, argc, argv);
|
||||
return fx_command_dispatch(CMD_ROOT, argc, argv);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user