diff --git a/src/lib/common/executable.c b/src/lib/common/executable.c index f9887f2..9f36dc2 100644 --- a/src/lib/common/executable.c +++ b/src/lib/common/executable.c @@ -185,7 +185,7 @@ void Executable_Free(Executable *exe) } } -void Executable_Dump(Executable *exe) +void Executable_Dump(Executable *exe, FILE *fp) { for(int i = 0; i < exe->bodyl; i += 1) { @@ -197,7 +197,7 @@ void Executable_Dump(Executable *exe) const InstrInfo *info = Executable_GetInstrByOpcode(opcode); - fprintf(stderr, "%d: %s ", i, info->name); + fprintf(fp, "%d: %s ", i, info->name); for(int j = 0; j < opc; j += 1) { @@ -205,15 +205,15 @@ void Executable_Dump(Executable *exe) { case OPTP_IDX: case OPTP_INT: - fprintf(stderr, "%lld ", ops[j].as_int); + fprintf(fp, "%lld ", ops[j].as_int); break; case OPTP_FLOAT: - fprintf(stderr, "%f ", ops[j].as_float); + fprintf(fp, "%f ", ops[j].as_float); break; case OPTP_STRING: - fprintf(stderr, "[%s] ", ops[j].as_string); + fprintf(fp, "[%s] ", ops[j].as_string); break; case OPTP_PROMISE: @@ -222,7 +222,7 @@ void Executable_Dump(Executable *exe) } } - fprintf(stderr, "\n"); + fprintf(fp, "\n"); } } diff --git a/src/lib/common/executable.h b/src/lib/common/executable.h index 9e00ed0..fa7dbc8 100644 --- a/src/lib/common/executable.h +++ b/src/lib/common/executable.h @@ -102,7 +102,7 @@ typedef struct xExeBuilder ExeBuilder; Executable *Executable_Copy(Executable *exe); void Executable_Free(Executable *exe); -void Executable_Dump(Executable *exe); +void Executable_Dump(Executable *exe, FILE *fp); _Bool Executable_Equiv(Executable *exe1, Executable *exe2, FILE *log, const char *log_prefix); _Bool Executable_Fetch(Executable *exe, int index, Opcode *opcode, Operand *ops, int *opc); _Bool Executable_SetSource(Executable *exe, Source *src); diff --git a/src/lib/noja.c b/src/lib/noja.c index b3ead0a..7c31291 100644 --- a/src/lib/noja.c +++ b/src/lib/noja.c @@ -117,7 +117,7 @@ static _Bool disassemble(Source *src) { Executable *exe = compile_source_and_print_error_on_failure(src); if(exe == NULL) return 0; - Executable_Dump(exe); + Executable_Dump(exe, stdout); Executable_Free(exe); return 1; }