aboutsummaryrefslogtreecommitdiff
path: root/src/main.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.zig')
-rw-r--r--src/main.zig16
1 files changed, 6 insertions, 10 deletions
diff --git a/src/main.zig b/src/main.zig
index becbf97..5ee36da 100644
--- a/src/main.zig
+++ b/src/main.zig
@@ -67,15 +67,8 @@ pub fn main() !void {
}
const procedure = try compile.compile(allocator, source, ast);
std.debug.print("Bytecode instructions:\n{}", .{procedure});
- // for (procedure.blocks, 0..) |block, i| {
- // std.debug.print(" ${}:\n", .{i});
- // for (block.instrs.items) |instr| {
- // std.debug.print(" {}\n", .{instr});
- // }
- // }
- // std.debug.print("Last use of each virtual register: {}\n", .{fmtHashMap(block.vreg_last_use)});
- // const elf = try codegen.create_elf(allocator, procedure);
- // try out_file.writer().writeAll(elf);
+ const elf = try codegen.create_elf(allocator, procedure);
+ try out_file.writer().writeAll(elf);
std.debug.print("Run output:\n", .{});
if (run) {
out_file.close();
@@ -104,7 +97,10 @@ fn HashMapFormatter(HashMap: type) type {
var it = hash_map.iterator();
var first = true;
while (it.next()) |kv| {
- try writer.print("{s} {any}: {any}", .{ if (first) "" else ",", kv.key_ptr.*, kv.value_ptr.* });
+ try writer.print(
+ "{s} {" ++ (if (@TypeOf(kv.key_ptr.*) == []const u8) "s" else "any") ++ "}: {any}",
+ .{ if (first) "" else ",", kv.key_ptr.*, kv.value_ptr.* },
+ );
first = false;
}
try writer.writeAll(if (first) "}" else " }");