This commit is contained in:
2026-02-20 15:33:46 -06:00
parent 11fb213a74
commit 5af76bce9b
40 changed files with 284 additions and 314 deletions

View File

@@ -31,7 +31,7 @@ if (!filename) {
var compiled = shop.mcode_file(filename)
if (!show_pretty) {
print(json.encode(compiled))
log.compile(json.encode(compiled))
$stop()
}
@@ -68,16 +68,16 @@ var dump_function = function(func, name) {
var operands = null
var pc_str = null
var op_str = null
print(`\n=== ${name} (args=${text(nr_args)}, slots=${text(nr_slots)}, closures=${text(nr_close)}) ===`)
log.compile(`\n=== ${name} (args=${text(nr_args)}, slots=${text(nr_slots)}, closures=${text(nr_close)}) ===`)
if (instrs == null || length(instrs) == 0) {
print(" (empty)")
log.compile(" (empty)")
return null
}
while (i < length(instrs)) {
instr = instrs[i]
if (is_text(instr)) {
if (!starts_with(instr, "_nop_")) {
print(`${instr}:`)
log.compile(`${instr}:`)
}
} else if (is_array(instr)) {
op = instr[0]
@@ -91,7 +91,7 @@ var dump_function = function(func, name) {
operands = text(parts, ", ")
pc_str = pad_right(text(pc), 5)
op_str = pad_right(op, 14)
print(` ${pc_str} ${op_str} ${operands}`)
log.compile(` ${pc_str} ${op_str} ${operands}`)
pc = pc + 1
}
i = i + 1