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("--color")
 | 
			
		||||
        .arg(color)
 | 
			
		||||
        .arg("-freference-trace")
 | 
			
		||||
        // Build output
 | 
			
		||||
        .arg("--cache-dir")
 | 
			
		||||
        .arg(out_path.join("zig-cache"))
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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;
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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}),
 | 
			
		||||
            },
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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];
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue