diff --git a/README.md b/README.md index 13695631..654062f0 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,7 @@ A small/lightweight statically typed scripting language written in Zig ## How to build and install -_Latest zig version supported: 0.12.0-dev.3245+4f782d1e8_ +_Latest zig version supported: 0.12.0-dev.3666+a2b834e8c_ ### Requirements - Since this is built with Zig, you should be able to build buzz on a wide variety of architectures even though this has only been tested on x86/M1. diff --git a/build.zig b/build.zig index 721dae1c..6812c216 100644 --- a/build.zig +++ b/build.zig @@ -90,13 +90,13 @@ const BuzzBuildOptions = struct { }; fn getBuzzPrefix(b: *Build) []const u8 { - return std.os.getenv("BUZZ_PATH") orelse std.fs.path.dirname(b.exe_dir).?; + return std.posix.getenv("BUZZ_PATH") orelse std.fs.path.dirname(b.exe_dir).?; } pub fn build(b: *Build) !void { // Check minimum zig version const current_zig = builtin.zig_version; - const min_zig = std.SemanticVersion.parse("0.12.0-dev.3245+4f782d1e8") catch return; + const min_zig = std.SemanticVersion.parse("0.12.0-dev.3666+a2b834e8c") catch return; if (current_zig.order(min_zig).compare(.lt)) { @panic(b.fmt("Your Zig version v{} does not meet the minimum build requirement of v{}", .{ current_zig, min_zig })); } @@ -128,8 +128,8 @@ pub fn build(b: *Build) !void { "\n \t", ), // Current commit sha - .sha = std.os.getenv("GIT_SHA") orelse - std.os.getenv("GITHUB_SHA") orelse std.mem.trim( + .sha = std.posix.getenv("GIT_SHA") orelse + std.posix.getenv("GITHUB_SHA") orelse std.mem.trim( u8, (std.ChildProcess.run(.{ .allocator = b.allocator, @@ -320,7 +320,7 @@ pub fn build(b: *Build) !void { const prefix = if (result) |r| std.mem.trim(u8, r.stdout, "\n") else - std.os.getenv("HOMEBREW_PREFIX") orelse "/opt/homebrew"; + std.posix.getenv("HOMEBREW_PREFIX") orelse "/opt/homebrew"; var include = std.ArrayList(u8).init(b.allocator); include.writer().print("{s}{s}include", .{ prefix, std.fs.path.sep_str }) catch unreachable; diff --git a/src/Parser.zig b/src/Parser.zig index b07134e6..caa0ff1b 100644 --- a/src/Parser.zig +++ b/src/Parser.zig @@ -139,7 +139,7 @@ pub fn defaultBuzzPrefix() []const u8 { var _buzz_path_buffer: [4096]u8 = undefined; pub fn buzzPrefix() []const u8 { - if (std.os.getenv("BUZZ_PATH")) |buzz_path| return buzz_path; + if (std.posix.getenv("BUZZ_PATH")) |buzz_path| return buzz_path; const path = if (!is_wasm) std.fs.selfExePath(&_buzz_path_buffer) catch return defaultBuzzPrefix() else diff --git a/src/Reporter.zig b/src/Reporter.zig index fec4d801..78c63a02 100644 --- a/src/Reporter.zig +++ b/src/Reporter.zig @@ -186,7 +186,7 @@ pub const Report = struct { pub fn report(self: *Report, reporter: *Self, out: anytype) !void { assert(self.items.len > 0); - const colorterm = std.os.getenv("COLORTERM"); + const colorterm = std.posix.getenv("COLORTERM"); const true_color = if (colorterm) |ct| std.mem.eql(u8, ct, "24bit") or std.mem.eql(u8, ct, "truecolor") else diff --git a/src/builtin/list.zig b/src/builtin/list.zig index 992b4b5e..c02a2b38 100644 --- a/src/builtin/list.zig +++ b/src/builtin/list.zig @@ -20,7 +20,7 @@ pub fn append(ctx: *NativeCtx) c_int { const messageValue: Value = (ctx.vm.gc.copyString("Could not append to list") catch { std.debug.print("Could not append to list", .{}); if (!is_wasm) { - std.os.exit(1); + std.posix.exit(1); } else { unreachable; } @@ -49,7 +49,7 @@ pub fn insert(ctx: *NativeCtx) c_int { const messageValue: Value = (ctx.vm.gc.copyString("Could not insert into list") catch { std.debug.print("Could not insert into list", .{}); if (!is_wasm) { - std.os.exit(1); + std.posix.exit(1); } else { unreachable; } @@ -114,7 +114,7 @@ pub fn remove(ctx: *NativeCtx) c_int { ctx.vm.gc.markObjDirty(&list.obj) catch { std.debug.print("Could not remove from list", .{}); if (!is_wasm) { - std.os.exit(1); + std.posix.exit(1); } else { unreachable; } diff --git a/src/ext/clap b/src/ext/clap index 209ba4da..8c98e640 160000 --- a/src/ext/clap +++ b/src/ext/clap @@ -1 +1 @@ -Subproject commit 209ba4da76e46412acfe18f711cb0b041ff37f10 +Subproject commit 8c98e6404b22aafc0184e999d8f068b81cc22fa1 diff --git a/src/jit_extern_api.zig b/src/jit_extern_api.zig index b494281c..ca337c91 100644 --- a/src/jit_extern_api.zig +++ b/src/jit_extern_api.zig @@ -6,7 +6,7 @@ const JIT = @import("Jit.zig"); const jmp = @import("jmp.zig").jmp; export fn bz_exit(code: c_int) noreturn { - std.os.exit(@truncate(@as(c_uint, @bitCast(code)))); + std.posix.exit(@truncate(@as(c_uint, @bitCast(code)))); } pub const ExternApi = enum { diff --git a/src/lib/buzz_http.zig b/src/lib/buzz_http.zig index b4a4861a..111e323c 100644 --- a/src/lib/buzz_http.zig +++ b/src/lib/buzz_http.zig @@ -86,7 +86,7 @@ pub export fn HttpClientSend(ctx: *api.NativeCtx) c_int { return -1; }; - request.send(.{ .raw_uri = false }) catch |err| { + request.send() catch |err| { handleStartError(ctx, err); return -1; @@ -295,7 +295,7 @@ fn handleWaitError(ctx: *api.NativeCtx, err: anytype) void { error.UnexpectedWriteFailure, error.UnknownHostName, error.UnsupportedTransferEncoding, - error.UnsupportedUrlScheme, + error.UnsupportedUriScheme, error.UriMissingHost, => ctx.vm.pushErrorEnum("http.HttpError", @errorName(err)), } @@ -331,7 +331,7 @@ fn handleError(ctx: *api.NativeCtx, err: anytype) void { error.UnexpectedWriteFailure, error.UnknownHostName, error.UnsupportedTransferEncoding, - error.UnsupportedUrlScheme, + error.UnsupportedUriScheme, error.UriMissingHost, => ctx.vm.pushErrorEnum("http.HttpError", @errorName(err)), } diff --git a/src/lib/buzz_io.zig b/src/lib/buzz_io.zig index 379ff10b..cfc086b4 100644 --- a/src/lib/buzz_io.zig +++ b/src/lib/buzz_io.zig @@ -24,7 +24,7 @@ pub export fn FileIsTTY(ctx: api.NativeCtx) c_int { ctx.vm.bz_peek(0).integer(), ); - ctx.vm.bz_pushBool(std.os.isatty(handle)); + ctx.vm.bz_pushBool(std.posix.isatty(handle)); return 1; } diff --git a/src/lib/buzz_os.zig b/src/lib/buzz_os.zig index 00574173..dcc33c62 100644 --- a/src/lib/buzz_os.zig +++ b/src/lib/buzz_os.zig @@ -27,7 +27,7 @@ pub export fn env(ctx: *api.NativeCtx) c_int { const key_slice = api.VM.allocator.dupeZ(u8, key.?[0..len]) catch @panic("Out of memory"); defer api.VM.allocator.free(key_slice); - if (std.os.getenvZ(key_slice)) |value| { + if (std.posix.getenvZ(key_slice)) |value| { ctx.vm.bz_pushString(api.ObjString.bz_string(ctx.vm, if (value.len > 0) @as([*]const u8, @ptrCast(value)) else null, value.len) orelse { @panic("Out of memory"); }); @@ -43,7 +43,7 @@ pub export fn env(ctx: *api.NativeCtx) c_int { fn sysTempDir() []const u8 { return switch (builtin.os.tag) { .windows => unreachable, // TODO: GetTempPath - else => std.os.getenv("TMPDIR") orelse std.os.getenv("TMP") orelse std.os.getenv("TEMP") orelse std.os.getenv("TEMPDIR") orelse "/tmp", + else => std.posix.getenv("TMPDIR") orelse std.posix.getenv("TMP") orelse std.posix.getenv("TEMP") orelse std.posix.getenv("TEMPDIR") orelse "/tmp", }; } @@ -92,11 +92,11 @@ pub export fn tmpFilename(ctx: *api.NativeCtx) c_int { return 1; } -// If it was named `exit` it would be considered by zig as a callback when std.os.exit is called +// If it was named `exit` it would be considered by zig as a callback when std.posix.exit is called pub export fn buzzExit(ctx: *api.NativeCtx) c_int { const exitCode: i32 = ctx.vm.bz_peek(0).integer(); - std.os.exit(@intCast(exitCode)); + std.posix.exit(@intCast(exitCode)); return 0; } @@ -332,11 +332,11 @@ pub export fn SocketConnect(ctx: *api.NativeCtx) c_int { } pub export fn SocketClose(ctx: *api.NativeCtx) c_int { - const socket: std.os.socket_t = @intCast( + const socket: std.posix.socket_t = @intCast( ctx.vm.bz_peek(0).integer(), ); - std.os.shutdown(socket, .both) catch @panic("Could not stop socket"); + std.posix.shutdown(socket, .both) catch @panic("Could not stop socket"); return 0; } @@ -376,7 +376,7 @@ pub export fn SocketRead(ctx: *api.NativeCtx) c_int { return -1; } - const handle: std.os.socket_t = @intCast( + const handle: std.posix.socket_t = @intCast( ctx.vm.bz_peek(1).integer(), ); @@ -434,7 +434,7 @@ fn handleReadLineError(ctx: *api.NativeCtx, err: anytype) void { } pub export fn SocketReadLine(ctx: *api.NativeCtx) c_int { - const handle: std.os.socket_t = @intCast( + const handle: std.posix.socket_t = @intCast( ctx.vm.bz_peek(1).integer(), ); const max_size = ctx.vm.bz_peek(0); @@ -479,7 +479,7 @@ pub export fn SocketReadLine(ctx: *api.NativeCtx) c_int { } pub export fn SocketReadAll(ctx: *api.NativeCtx) c_int { - const handle: std.os.socket_t = @intCast( + const handle: std.posix.socket_t = @intCast( ctx.vm.bz_peek(1).integer(), ); const max_size = ctx.vm.bz_peek(0); @@ -523,7 +523,7 @@ pub export fn SocketReadAll(ctx: *api.NativeCtx) c_int { } pub export fn SocketWrite(ctx: *api.NativeCtx) c_int { - const handle: std.os.socket_t = @intCast( + const handle: std.posix.socket_t = @intCast( ctx.vm.bz_peek(1).integer(), ); diff --git a/src/lib/buzz_std.zig b/src/lib/buzz_std.zig index 344ecf4d..a6f9a39b 100644 --- a/src/lib/buzz_std.zig +++ b/src/lib/buzz_std.zig @@ -219,7 +219,7 @@ pub export fn assert(ctx: *api.NativeCtx) c_int { } if (!is_wasm) { - std.os.exit(1); + std.posix.exit(1); } } diff --git a/src/lib/http.buzz b/src/lib/http.buzz index 99c4c8df..6d2cb52c 100644 --- a/src/lib/http.buzz +++ b/src/lib/http.buzz @@ -44,7 +44,7 @@ export enum HttpError { UnexpectedWriteFailure, UnknownHostName, UnsupportedTransferEncoding, - UnsupportedUrlScheme, + UnsupportedUriScheme, UriMissingHost, } diff --git a/src/main.zig b/src/main.zig index 43c97dc3..ec50afa8 100644 --- a/src/main.zig +++ b/src/main.zig @@ -256,7 +256,7 @@ pub fn main() !void { printBanner(std.io.getStdOut().writer(), true); if (!is_wasm) { - std.os.exit(0); + std.posix.exit(0); } } @@ -283,7 +283,7 @@ pub fn main() !void { ); if (!is_wasm) { - std.os.exit(0); + std.posix.exit(0); } } @@ -325,7 +325,7 @@ pub fn main() !void { if (!is_wasm and flavor == .Repl) { repl(allocator) catch { if (!is_wasm) { - std.os.exit(1); + std.posix.exit(1); } std.debug.print("REPL stopped", .{}); @@ -338,7 +338,7 @@ pub fn main() !void { flavor, ) catch { if (!is_wasm) { - std.os.exit(1); + std.posix.exit(1); } std.debug.print("VM stopped", .{}); @@ -350,7 +350,7 @@ pub fn main() !void { } if (!is_wasm) { - std.os.exit(0); + std.posix.exit(0); } } @@ -460,5 +460,5 @@ test "Testing behavior" { fail_count, }); - std.os.exit(if (fail_count == 0) 0 else 1); + std.posix.exit(if (fail_count == 0) 0 else 1); } diff --git a/src/obj.zig b/src/obj.zig index 96131aa2..9b946a7d 100644 --- a/src/obj.zig +++ b/src/obj.zig @@ -66,7 +66,7 @@ pub const Obj = struct { return null; } - return @fieldParentPtr(T, "obj", obj); + return @alignCast(@fieldParentPtr("obj", obj)); } pub inline fn access(obj: *Obj, comptime T: type, obj_type: ObjType, gc: *GarbageCollector) ?*T { diff --git a/src/repl.zig b/src/repl.zig index d5aab054..19a23513 100644 --- a/src/repl.zig +++ b/src/repl.zig @@ -85,7 +85,7 @@ pub fn printBanner(out: std.fs.File.Writer, full: bool) void { } pub fn repl(allocator: std.mem.Allocator) !void { - const colorterm = std.os.getenv("COLORTERM"); + const colorterm = std.posix.getenv("COLORTERM"); const true_color = if (colorterm) |ct| std.mem.eql(u8, ct, "24bit") or std.mem.eql(u8, ct, "truecolor") else @@ -143,7 +143,7 @@ pub fn repl(allocator: std.mem.Allocator) !void { try buzz_history_path.writer().print( "{s}/.buzz_history\x00", - .{std.os.getenv("HOME") orelse "."}, + .{std.posix.getenv("HOME") orelse "."}, ); _ = ln.linenoiseHistorySetMaxLen(100); diff --git a/src/vm.zig b/src/vm.zig index d296e993..9aae2f76 100644 --- a/src/vm.zig +++ b/src/vm.zig @@ -777,7 +777,7 @@ pub const VM = struct { fn vmPanic(e: anytype) void { std.debug.print("{}\n", .{e}); if (!is_wasm) { - std.os.exit(1); + std.posix.exit(1); } } @@ -3904,7 +3904,7 @@ pub const VM = struct { ); if (!is_wasm) { - std.os.exit(1); + std.posix.exit(1); } else { return Error.RuntimeError; }