update Zig code to 0.15.0
This commit is contained in:
parent
449f2b59df
commit
45099916fe
4 changed files with 17 additions and 15 deletions
|
@ -46,6 +46,7 @@ fn main() -> Result<(), Box<dyn Error>> {
|
||||||
.arg("--prominent-compile-errors")
|
.arg("--prominent-compile-errors")
|
||||||
.arg("--color")
|
.arg("--color")
|
||||||
.arg(color)
|
.arg(color)
|
||||||
|
.arg("-freference-trace")
|
||||||
// Build output
|
// Build output
|
||||||
.arg("--cache-dir")
|
.arg("--cache-dir")
|
||||||
.arg(out_path.join("zig-cache"))
|
.arg(out_path.join("zig-cache"))
|
||||||
|
|
|
@ -22,8 +22,9 @@ pub const std_options: std.Options = .{
|
||||||
};
|
};
|
||||||
|
|
||||||
pub fn enableLogScope(scope: @TypeOf(.enum_literal)) bool {
|
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)
|
if (scope == .vm)
|
||||||
return false
|
return true
|
||||||
else
|
else
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -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) {
|
switch (value) {
|
||||||
.nil => try std.fmt.formatBuf("Nil", options, writer),
|
.nil => try writer.writeAll("Nil"),
|
||||||
.false => try std.fmt.formatBuf("False", options, writer),
|
.false => try writer.writeAll("False"),
|
||||||
.true => try std.fmt.formatBuf("True", options, writer),
|
.true => try writer.writeAll("True"),
|
||||||
inline .tag, .number => |x| try std.fmt.format(writer, "{d}", .{x}),
|
inline .tag, .number => |x| try writer.print("{d}", .{x}),
|
||||||
inline .vec4, .rgba => |x| try std.fmt.format(writer, "{s}{d}", .{ @tagName(value), x }),
|
inline .vec4, .rgba => |x| try writer.print("{s}{d}", .{ @tagName(value), x }),
|
||||||
.ref => |ref| switch (ref.*) {
|
.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| {
|
.list => |l| {
|
||||||
try std.fmt.formatBuf("[", options, writer);
|
try writer.writeAll("[");
|
||||||
for (l, 0..) |elem, i| {
|
for (l, 0..) |elem, i| {
|
||||||
if (i != 0) try std.fmt.formatBuf(", ", options, writer);
|
if (i != 0) try writer.writeAll(", ");
|
||||||
try elem.format(fmt, options, writer);
|
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}),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -167,7 +167,7 @@ pub fn push(vm: *Vm, val: Value) Error!void {
|
||||||
if (vm.stack_top >= vm.stack.len) {
|
if (vm.stack_top >= vm.stack.len) {
|
||||||
return vm.throw("too many live temporary values (local variables and expression operands)", .{});
|
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[vm.stack_top] = val;
|
||||||
vm.stack_top += 1;
|
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", .{});
|
try vm.validateBytecode(vm.stack_top > 0, "value stack underflow", .{});
|
||||||
vm.stack_top -= 1;
|
vm.stack_top -= 1;
|
||||||
const result = vm.stack[vm.stack_top];
|
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];
|
return vm.stack[vm.stack_top];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue