From 45099916fe6b4fc7211dc081ff3d16adf8ea4121 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=83=AA=E3=82=AD=E8=90=8C?= Date: Tue, 2 Sep 2025 20:15:35 +0200 Subject: [PATCH] update Zig code to 0.15.0 --- crates/haku2/build.rs | 1 + crates/haku2/src/haku2.zig | 3 ++- crates/haku2/src/value.zig | 24 ++++++++++++------------ crates/haku2/src/vm.zig | 4 ++-- 4 files changed, 17 insertions(+), 15 deletions(-) diff --git a/crates/haku2/build.rs b/crates/haku2/build.rs index a68dc93..3d49a8b 100644 --- a/crates/haku2/build.rs +++ b/crates/haku2/build.rs @@ -46,6 +46,7 @@ fn main() -> Result<(), Box> { .arg("--prominent-compile-errors") .arg("--color") .arg(color) + .arg("-freference-trace") // Build output .arg("--cache-dir") .arg(out_path.join("zig-cache")) diff --git a/crates/haku2/src/haku2.zig b/crates/haku2/src/haku2.zig index ec428fc..cfadabe 100644 --- a/crates/haku2/src/haku2.zig +++ b/crates/haku2/src/haku2.zig @@ -22,8 +22,9 @@ pub const std_options: std.Options = .{ }; pub fn enableLogScope(scope: @TypeOf(.enum_literal)) bool { + // Replace any of the false returns below to enable log scopes for the build. if (scope == .vm) - return false + return true else return true; } diff --git a/crates/haku2/src/value.zig b/crates/haku2/src/value.zig index d1498ff..e34bc24 100644 --- a/crates/haku2/src/value.zig +++ b/crates/haku2/src/value.zig @@ -69,24 +69,24 @@ pub const Value = union(enum) { }; } - pub fn format(value: Value, comptime fmt: []const u8, options: std.fmt.FormatOptions, writer: anytype) !void { + pub fn format(value: Value, writer: *std.Io.Writer) !void { switch (value) { - .nil => try std.fmt.formatBuf("Nil", options, writer), - .false => try std.fmt.formatBuf("False", options, writer), - .true => try std.fmt.formatBuf("True", options, writer), - inline .tag, .number => |x| try std.fmt.format(writer, "{d}", .{x}), - inline .vec4, .rgba => |x| try std.fmt.format(writer, "{s}{d}", .{ @tagName(value), x }), + .nil => try writer.writeAll("Nil"), + .false => try writer.writeAll("False"), + .true => try writer.writeAll("True"), + inline .tag, .number => |x| try writer.print("{d}", .{x}), + inline .vec4, .rgba => |x| try writer.print("{s}{d}", .{ @tagName(value), x }), .ref => |ref| switch (ref.*) { - .closure => |c| try std.fmt.format(writer, "function {s}", .{c.name}), + .closure => |c| try writer.print("function {s}", .{c.name}), .list => |l| { - try std.fmt.formatBuf("[", options, writer); + try writer.writeAll("["); for (l, 0..) |elem, i| { - if (i != 0) try std.fmt.formatBuf(", ", options, writer); - try elem.format(fmt, options, writer); + if (i != 0) try writer.writeAll(", "); + try elem.format(writer); } - try std.fmt.formatBuf("]", options, writer); + try writer.writeAll("]"); }, - inline .shape, .scribble, .reticle => |x| try std.fmt.format(writer, "{}", .{x}), + inline .shape, .scribble, .reticle => |x| try writer.print("{}", .{x}), }, } } diff --git a/crates/haku2/src/vm.zig b/crates/haku2/src/vm.zig index 9f90953..910cb13 100644 --- a/crates/haku2/src/vm.zig +++ b/crates/haku2/src/vm.zig @@ -167,7 +167,7 @@ pub fn push(vm: *Vm, val: Value) Error!void { if (vm.stack_top >= vm.stack.len) { return vm.throw("too many live temporary values (local variables and expression operands)", .{}); } - log.debug("PUSH {any} <- {}", .{ vm.stack[0..vm.stack_top], val }); + log.debug("PUSH {any} <- {f}", .{ vm.stack[0..vm.stack_top], val }); vm.stack[vm.stack_top] = val; vm.stack_top += 1; } @@ -176,7 +176,7 @@ pub fn pop(vm: *Vm) Error!Value { try vm.validateBytecode(vm.stack_top > 0, "value stack underflow", .{}); vm.stack_top -= 1; const result = vm.stack[vm.stack_top]; - log.debug("POP {any} -> {}", .{ vm.stack[0..vm.stack_top], result }); + log.debug("POP {any} -> {f}", .{ vm.stack[0..vm.stack_top], result }); return vm.stack[vm.stack_top]; }