diff options
author | Mathias Magnusson <mathias@magnusson.space> | 2025-06-07 00:05:22 +0200 |
---|---|---|
committer | Mathias Magnusson <mathias@magnusson.space> | 2025-06-07 00:57:32 +0200 |
commit | 1ed87d6c58cab383f18590093f651ef35c4fa671 (patch) | |
tree | c76bc3b8797f6e9973439462565b015da1dcbd80 /src/main.zig | |
parent | 8c9a56311ac2774bf83eda4ea0aa9bde0aec125f (diff) | |
download | huginn-1ed87d6c58cab383f18590093f651ef35c4fa671.tar.gz |
add variable reassignments and basic block arguments
Diffstat (limited to 'src/main.zig')
-rw-r--r-- | src/main.zig | 26 |
1 files changed, 12 insertions, 14 deletions
diff --git a/src/main.zig b/src/main.zig index 48637c2..314459b 100644 --- a/src/main.zig +++ b/src/main.zig @@ -21,8 +21,6 @@ pub fn main() !void { std.io.getStdOut(); const run = if (args.next()) |arg| std.mem.eql(u8, arg, "run") else false; - const output = out_file.writer(); - // var br = std.io.bufferedReader(std.io.getStdIn().reader()); // const stdin = br.reader(); // @@ -40,11 +38,11 @@ pub fn main() !void { \\{ \\ let x = 10 \\ if x { - \\ let x = read_int(0) + \\ # let x = read_int(0) \\ # print(18446744073709551615) - \\ # print(x + x) + \\ x = x + x \\ } else { - \\ print(10) + \\ x = 69 \\ } \\ print(x) \\} @@ -63,16 +61,16 @@ pub fn main() !void { std.debug.print("Unexpected token {}, expected end of file\n", .{lexer.next()}); } const procedure = try compile.compile(allocator, source, ast); - std.debug.print("Bytecode instructions:\n", .{}); - for (procedure.blocks, 0..) |block, i| { - std.debug.print(" ${}:\n", .{i}); - for (block.instrs.items) |instr| { - std.debug.print(" {}\n", .{instr}); - } - } + 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 output.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(); |