diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/analytics/analytics_schema.zig | 12 | ||||
-rw-r--r-- | src/api/schema.zig | 76 | ||||
-rw-r--r-- | src/ast/base.zig | 4 | ||||
-rw-r--r-- | src/bun.js/api/JSBundler.zig | 6 | ||||
-rw-r--r-- | src/bun.js/api/bun/socket.zig | 6 | ||||
-rw-r--r-- | src/bun.js/api/server.zig | 2 | ||||
-rw-r--r-- | src/bun.js/javascript.zig | 2 | ||||
-rw-r--r-- | src/bun.js/node/fs_events.zig | 2 | ||||
-rw-r--r-- | src/bun.js/node/path_watcher.zig | 4 | ||||
-rw-r--r-- | src/bun.js/test/expect.zig | 4 | ||||
-rw-r--r-- | src/bun.js/webcore/blob.zig | 2 | ||||
-rw-r--r-- | src/bundler.zig | 4 | ||||
-rw-r--r-- | src/copy_file.zig | 2 | ||||
-rw-r--r-- | src/css_scanner.zig | 22 | ||||
-rw-r--r-- | src/env_loader.zig | 16 | ||||
-rw-r--r-- | src/fs.zig | 4 | ||||
-rw-r--r-- | src/import_record.zig | 4 | ||||
-rw-r--r-- | src/js_ast.zig | 94 | ||||
-rw-r--r-- | src/js_parser.zig | 38 | ||||
-rw-r--r-- | src/logger.zig | 8 | ||||
-rw-r--r-- | src/output.zig | 2 | ||||
-rw-r--r-- | src/resolver/resolver.zig | 56 | ||||
-rw-r--r-- | src/sync.zig | 2 |
23 files changed, 186 insertions, 186 deletions
diff --git a/src/analytics/analytics_schema.zig b/src/analytics/analytics_schema.zig index fbcc26fb0..3a22ed2b3 100644 --- a/src/analytics/analytics_schema.zig +++ b/src/analytics/analytics_schema.zig @@ -346,8 +346,8 @@ pub const analytics = struct { _, - pub fn jsonStringify(self: *const @This(), opts: anytype, o: anytype) !void { - return try std.json.stringify(@tagName(self), opts, o); + pub fn jsonStringify(self: *const @This(), writer: anytype) !void { + return try writer.write(@tagName(self)); } }; @@ -361,8 +361,8 @@ pub const analytics = struct { _, - pub fn jsonStringify(self: *const @This(), opts: anytype, o: anytype) !void { - return try std.json.stringify(@tagName(self), opts, o); + pub fn jsonStringify(self: *const @This(), writer: anytype) !void { + return try writer.write(@tagName(self)); } }; @@ -411,8 +411,8 @@ pub const analytics = struct { _, - pub fn jsonStringify(self: *const @This(), opts: anytype, o: anytype) !void { - return try std.json.stringify(@tagName(self), opts, o); + pub fn jsonStringify(self: *const @This(), writer: anytype) !void { + return try writer.write(@tagName(self)); } }; diff --git a/src/api/schema.zig b/src/api/schema.zig index ae63af87a..f3141a1b5 100644 --- a/src/api/schema.zig +++ b/src/api/schema.zig @@ -373,8 +373,8 @@ pub const Api = struct { _, - pub fn jsonStringify(self: *const @This(), opts: anytype, o: anytype) !void { - return try std.json.stringify(@tagName(self), opts, o); + pub fn jsonStringify(self: *const @This(), writer: anytype) !void { + return try writer.write(@tagName(self)); } }; @@ -391,8 +391,8 @@ pub const Api = struct { _, - pub fn jsonStringify(self: *const @This(), opts: anytype, o: anytype) !void { - return try std.json.stringify(@tagName(self), opts, o); + pub fn jsonStringify(self: *const @This(), writer: anytype) !void { + return try writer.write(@tagName(self)); } }; @@ -418,8 +418,8 @@ pub const Api = struct { _, - pub fn jsonStringify(self: *const @This(), opts: anytype, o: anytype) !void { - return try std.json.stringify(@tagName(self), opts, o); + pub fn jsonStringify(self: *const @This(), writer: anytype) !void { + return try writer.write(@tagName(self)); } }; @@ -648,8 +648,8 @@ pub const Api = struct { _, - pub fn jsonStringify(self: *const @This(), opts: anytype, o: anytype) !void { - return try std.json.stringify(@tagName(self), opts, o); + pub fn jsonStringify(self: *const @This(), writer: anytype) !void { + return try writer.write(@tagName(self)); } }; @@ -799,8 +799,8 @@ pub const Api = struct { _, - pub fn jsonStringify(self: *const @This(), opts: anytype, o: anytype) !void { - return try std.json.stringify(@tagName(self), opts, o); + pub fn jsonStringify(self: *const @This(), writer: anytype) !void { + return try writer.write(@tagName(self)); } }; @@ -820,8 +820,8 @@ pub const Api = struct { _, - pub fn jsonStringify(self: *const @This(), opts: anytype, o: anytype) !void { - return try std.json.stringify(@tagName(self), opts, o); + pub fn jsonStringify(self: *const @This(), writer: anytype) !void { + return try writer.write(@tagName(self)); } }; @@ -838,8 +838,8 @@ pub const Api = struct { _, - pub fn jsonStringify(self: *const @This(), opts: anytype, o: anytype) !void { - return try std.json.stringify(@tagName(self), opts, o); + pub fn jsonStringify(self: *const @This(), writer: anytype) !void { + return try writer.write(@tagName(self)); } }; @@ -856,8 +856,8 @@ pub const Api = struct { _, - pub fn jsonStringify(self: *const @This(), opts: anytype, o: anytype) !void { - return try std.json.stringify(@tagName(self), opts, o); + pub fn jsonStringify(self: *const @This(), writer: anytype) !void { + return try writer.write(@tagName(self)); } }; @@ -1124,8 +1124,8 @@ pub const Api = struct { _, - pub fn jsonStringify(self: *const @This(), opts: anytype, o: anytype) !void { - return try std.json.stringify(@tagName(self), opts, o); + pub fn jsonStringify(self: *const @This(), writer: anytype) !void { + return try writer.write(@tagName(self)); } }; @@ -1139,8 +1139,8 @@ pub const Api = struct { _, - pub fn jsonStringify(self: *const @This(), opts: anytype, o: anytype) !void { - return try std.json.stringify(@tagName(self), opts, o); + pub fn jsonStringify(self: *const @This(), writer: anytype) !void { + return try writer.write(@tagName(self)); } }; @@ -1246,8 +1246,8 @@ pub const Api = struct { _, - pub fn jsonStringify(self: *const @This(), opts: anytype, o: anytype) !void { - return try std.json.stringify(@tagName(self), opts, o); + pub fn jsonStringify(self: *const @This(), writer: anytype) !void { + return try writer.write(@tagName(self)); } }; @@ -1953,8 +1953,8 @@ pub const Api = struct { _, - pub fn jsonStringify(self: *const @This(), opts: anytype, o: anytype) !void { - return try std.json.stringify(@tagName(self), opts, o); + pub fn jsonStringify(self: *const @This(), writer: anytype) !void { + return try writer.write(@tagName(self)); } }; @@ -2185,8 +2185,8 @@ pub const Api = struct { _, - pub fn jsonStringify(self: *const @This(), opts: anytype, o: anytype) !void { - return try std.json.stringify(@tagName(self), opts, o); + pub fn jsonStringify(self: *const @This(), writer: anytype) !void { + return try writer.write(@tagName(self)); } }; @@ -2200,8 +2200,8 @@ pub const Api = struct { _, - pub fn jsonStringify(self: *const @This(), opts: anytype, o: anytype) !void { - return try std.json.stringify(@tagName(self), opts, o); + pub fn jsonStringify(self: *const @This(), writer: anytype) !void { + return try writer.write(@tagName(self)); } }; @@ -2271,8 +2271,8 @@ pub const Api = struct { _, - pub fn jsonStringify(self: *const @This(), opts: anytype, o: anytype) !void { - return try std.json.stringify(@tagName(self), opts, o); + pub fn jsonStringify(self: *const @This(), writer: anytype) !void { + return try writer.write(@tagName(self)); } }; @@ -2478,8 +2478,8 @@ pub const Api = struct { _, - pub fn jsonStringify(self: *const @This(), opts: anytype, o: anytype) !void { - return try std.json.stringify(@tagName(self), opts, o); + pub fn jsonStringify(self: *const @This(), writer: anytype) !void { + return try writer.write(@tagName(self)); } }; @@ -2511,8 +2511,8 @@ pub const Api = struct { _, - pub fn jsonStringify(self: *const @This(), opts: anytype, o: anytype) !void { - return try std.json.stringify(@tagName(self), opts, o); + pub fn jsonStringify(self: *const @This(), writer: anytype) !void { + return try writer.write(@tagName(self)); } }; @@ -2529,8 +2529,8 @@ pub const Api = struct { _, - pub fn jsonStringify(self: *const @This(), opts: anytype, o: anytype) !void { - return try std.json.stringify(@tagName(self), opts, o); + pub fn jsonStringify(self: *const @This(), writer: anytype) !void { + return try writer.write(@tagName(self)); } }; @@ -3147,8 +3147,8 @@ pub const Api = struct { _, - pub fn jsonStringify(self: *const @This(), opts: anytype, o: anytype) !void { - return try std.json.stringify(@tagName(self), opts, o); + pub fn jsonStringify(self: *const @This(), writer: anytype) !void { + return try writer.write(@tagName(self)); } }; diff --git a/src/ast/base.zig b/src/ast/base.zig index ab96dab3d..fb70e4565 100644 --- a/src/ast/base.zig +++ b/src/ast/base.zig @@ -285,8 +285,8 @@ pub const Ref = packed struct(u64) { return self.tag == .invalid; } - pub fn jsonStringify(self: *const Ref, options: anytype, writer: anytype) !void { - return try std.json.stringify([2]u32{ self.sourceIndex(), self.innerIndex() }, options, writer); + pub fn jsonStringify(self: *const Ref, writer: anytype) !void { + return try writer.write([2]u32{ self.sourceIndex(), self.innerIndex() }); } }; diff --git a/src/bun.js/api/JSBundler.zig b/src/bun.js/api/JSBundler.zig index af1a55ce6..f5c3793ed 100644 --- a/src/bun.js/api/JSBundler.zig +++ b/src/bun.js/api/JSBundler.zig @@ -594,8 +594,8 @@ pub const JSBundler = struct { external: bool = false, pub fn deinit(this: *@This()) void { - bun.default_allocator.destroy(this.path); - bun.default_allocator.destroy(this.namespace); + bun.default_allocator.free(this.path); + bun.default_allocator.free(this.namespace); } }, no_match: void, @@ -747,7 +747,7 @@ pub const JSBundler = struct { pub fn deinit(this: *Value) void { switch (this.*) { .success => |success| { - bun.default_allocator.destroy(success.source_code); + bun.default_allocator.free(success.source_code); }, .err => |*err| { err.deinit(bun.default_allocator); diff --git a/src/bun.js/api/bun/socket.zig b/src/bun.js/api/bun/socket.zig index 5da6c1f40..592fd6540 100644 --- a/src/bun.js/api/bun/socket.zig +++ b/src/bun.js/api/bun/socket.zig @@ -499,10 +499,10 @@ pub const Listener = struct { pub fn deinit(this: UnixOrHost) void { switch (this) { .unix => |u| { - bun.default_allocator.destroy(@as([*]u8, @ptrFromInt(@intFromPtr(u.ptr)))); + bun.default_allocator.free(u); }, .host => |h| { - bun.default_allocator.destroy(@as([*]u8, @ptrFromInt(@intFromPtr(h.host.ptr)))); + bun.default_allocator.free(h.host); }, } } @@ -833,7 +833,7 @@ pub const Listener = struct { this.connection.deinit(); if (this.protos) |protos| { this.protos = null; - bun.default_allocator.destroy(protos); + bun.default_allocator.free(protos); } bun.default_allocator.destroy(this); } diff --git a/src/bun.js/api/server.zig b/src/bun.js/api/server.zig index e96135a5e..64a85d6a4 100644 --- a/src/bun.js/api/server.zig +++ b/src/bun.js/api/server.zig @@ -5131,7 +5131,7 @@ pub fn NewServer(comptime NamespaceType: type, comptime ssl_enabled_: bool, comp this.cached_protocol.deref(); if (this.config.hostname) |host| { - bun.default_allocator.destroy(host); + bun.default_allocator.free(host[0 .. std.mem.len(host) + 1]); } if (this.config.base_url.href.len > 0) { diff --git a/src/bun.js/javascript.zig b/src/bun.js/javascript.zig index 062bd52a2..03cdab205 100644 --- a/src/bun.js/javascript.zig +++ b/src/bun.js/javascript.zig @@ -2558,7 +2558,7 @@ pub const VirtualMachine = struct { } else if (kind.isObject() or kind.isArray()) { var bun_str = bun.String.empty; defer bun_str.deref(); - value.jsonStringify(this.global, 2, &bun_str); + value.jsonStringify(this.global, 2, &bun_str); //2 try writer.print(comptime Output.prettyFmt(" {s}<d>: <r>{any}<r>\n", allow_ansi_color), .{ field, bun_str }); add_extra_line = true; } diff --git a/src/bun.js/node/fs_events.zig b/src/bun.js/node/fs_events.zig index 70b41fc33..ce158a037 100644 --- a/src/bun.js/node/fs_events.zig +++ b/src/bun.js/node/fs_events.zig @@ -488,7 +488,7 @@ pub const FSEventsLoop = struct { CS.FSEventStreamScheduleWithRunLoop(ref, this.loop, CF.RunLoopDefaultMode.*); if (CS.FSEventStreamStart(ref) == 0) { //clean in case of failure - bun.default_allocator.destroy(paths); + bun.default_allocator.free(paths); CF.Release(cf_paths); CS.FSEventStreamInvalidate(ref); CS.FSEventStreamRelease(ref); diff --git a/src/bun.js/node/path_watcher.zig b/src/bun.js/node/path_watcher.zig index 1d81661e9..1f1b9d1a1 100644 --- a/src/bun.js/node/path_watcher.zig +++ b/src/bun.js/node/path_watcher.zig @@ -85,7 +85,7 @@ pub const PathWatcherManager = struct { return info.*; } const cloned_path = try bun.default_allocator.dupeZ(u8, path); - errdefer bun.default_allocator.destroy(cloned_path); + errdefer bun.default_allocator.free(cloned_path); if (std.fs.openIterableDirAbsoluteZ(cloned_path, .{ .access_sub_paths = true, @@ -657,7 +657,7 @@ pub const PathWatcherManager = struct { while (it.next()) |*entry| { const path = entry.value_ptr.*; std.os.close(path.fd); - bun.default_allocator.destroy(path.path); + bun.default_allocator.free(path.path); } this.file_paths.deinit(); diff --git a/src/bun.js/test/expect.zig b/src/bun.js/test/expect.zig index de3f185d5..0d3ff663e 100644 --- a/src/bun.js/test/expect.zig +++ b/src/bun.js/test/expect.zig @@ -1131,12 +1131,12 @@ pub const Expect = struct { if (value.isAnyInt()) { const _value = value.toInt64(); pass = @mod(_value, 2) == 0; - if (_value == -0) { // negative zero is even + if (_value == -0.0) { // negative zero is even pass = true; } } else if (value.isBigInt() or value.isBigInt32()) { const _value = value.toInt64(); - pass = switch (_value == -0) { // negative zero is even + pass = switch (_value == -0.0) { // negative zero is even true => true, else => _value & 1 == 0, }; diff --git a/src/bun.js/webcore/blob.zig b/src/bun.js/webcore/blob.zig index c794ab59b..c5e893a5a 100644 --- a/src/bun.js/webcore/blob.zig +++ b/src/bun.js/webcore/blob.zig @@ -2361,7 +2361,7 @@ pub const Blob = struct { } pub fn doFCopyFile(this: *CopyFile) anyerror!void { - switch (JSC.Node.Syscall.fcopyfile(this.source_fd, this.destination_fd, os.system.COPYFILE.DATA)) { + switch (JSC.Node.Syscall.fcopyfile(this.source_fd, this.destination_fd, os.system.COPYFILE_DATA)) { .err => |errno| { this.system_error = errno.toSystemError(); diff --git a/src/bundler.zig b/src/bundler.zig index 4e8d92e3c..734555ef5 100644 --- a/src/bundler.zig +++ b/src/bundler.zig @@ -653,9 +653,7 @@ pub const Bundler = struct { pub noinline fn dumpEnvironmentVariables(bundler: *const Bundler) void { @setCold(true); const opts = std.json.StringifyOptions{ - .whitespace = std.json.StringifyOptions.Whitespace{ - .separator = true, - }, + .whitespace = .indent_2, }; Output.flush(); std.json.stringify(bundler.env.map.*, opts, Output.writer()) catch unreachable; diff --git a/src/copy_file.zig b/src/copy_file.zig index 4fbac7855..cbf81e549 100644 --- a/src/copy_file.zig +++ b/src/copy_file.zig @@ -24,7 +24,7 @@ const CopyFileError = error{SystemResources} || CopyFileRangeError || os.SendFil // No metadata is transferred over. pub fn copyFile(fd_in: os.fd_t, fd_out: os.fd_t) CopyFileError!void { if (comptime bun.Environment.isMac) { - const rc = os.system.fcopyfile(fd_in, fd_out, null, os.system.COPYFILE.DATA); + const rc = os.system.fcopyfile(fd_in, fd_out, null, os.system.COPYFILE_DATA); switch (os.errno(rc)) { .SUCCESS => return, .INVAL => unreachable, diff --git a/src/css_scanner.zig b/src/css_scanner.zig index e464a6d9f..db5e6ee0d 100644 --- a/src/css_scanner.zig +++ b/src/css_scanner.zig @@ -346,7 +346,7 @@ pub const Scanner = struct { comptime WriterType: type, writer: WriterType, writeChunk: (fn (ctx: WriterType, Chunk) anyerror!void), - ) !void { + ) anyerror!void { scanner.has_newline_before = scanner.end == 0; scanner.has_delimiter_before = false; scanner.step(); @@ -899,7 +899,7 @@ pub fn NewWriter( writer: *Writer, log: *logger.Log, allocator: std.mem.Allocator, - ) !void { + ) anyerror!void { std.debug.assert(writer.source.contents.len > 0); var scanner = Scanner.init( @@ -937,7 +937,7 @@ pub fn NewWriter( writer: *Writer, log: *logger.Log, allocator: std.mem.Allocator, - ) !void { + ) anyerror!void { std.debug.assert(writer.source.contents.len > 0); var scanner = Scanner.init( @@ -950,7 +950,7 @@ pub fn NewWriter( try scanner.next(.keep, @TypeOf(writer), writer, commitChunk); } - fn writeString(writer: *Writer, str: string, quote: Chunk.TextContent.Quote) !void { + fn writeString(writer: *Writer, str: string, quote: Chunk.TextContent.Quote) anyerror!void { switch (quote) { .none => { try writer.ctx.writeAll(str); @@ -974,7 +974,7 @@ pub fn NewWriter( } } - fn writeURL(writer: *Writer, url_str: string, text: Chunk.TextContent) !void { + fn writeURL(writer: *Writer, url_str: string, text: Chunk.TextContent) anyerror!void { switch (text.quote) { .none => { try writer.ctx.writeAll("url("); @@ -1001,7 +1001,7 @@ pub fn NewWriter( } } - pub fn scanChunk(writer: *Writer, chunk: Chunk) !void { + pub fn scanChunk(writer: *Writer, chunk: Chunk) anyerror!void { switch (chunk.content) { .t_url => {}, .t_import => |import| { @@ -1042,15 +1042,15 @@ pub fn NewWriter( } } - pub fn commitChunk(writer: *Writer, chunk: Chunk) !void { + pub fn commitChunk(writer: *Writer, chunk: Chunk) anyerror!void { return try writeChunk(writer, chunk, false); } - pub fn writeBundledChunk(writer: *Writer, chunk: Chunk) !void { + pub fn writeBundledChunk(writer: *Writer, chunk: Chunk) anyerror!void { return try writeChunk(writer, chunk, true); } - pub fn writeChunk(writer: *Writer, chunk: Chunk, comptime omit_imports: bool) !void { + pub fn writeChunk(writer: *Writer, chunk: Chunk, comptime omit_imports: bool) anyerror!void { switch (chunk.content) { .t_url => |url| { const url_str = try writer.linker.resolveCSS( @@ -1259,7 +1259,7 @@ pub fn NewBundler( return logger.Source.initFile(file, this.allocator); } - pub fn addCSSImport(this: *CSSBundler, absolute_path: string) !void { + pub fn addCSSImport(this: *CSSBundler, absolute_path: string) anyerror!void { const hash = Watcher.getHash(absolute_path); if (this.queued.items.len > 0 and std.mem.indexOfScalar(u32, this.queued.items, hash) != null) { return; @@ -1281,7 +1281,7 @@ pub fn NewBundler( try this.bundle_queue.append(hash); } - pub fn writeAll(this: *CSSBundler, buf: anytype) !void { + pub fn writeAll(this: *CSSBundler, buf: anytype) anyerror!void { _ = try this.writer.writeAll(buf); } diff --git a/src/env_loader.zig b/src/env_loader.zig index 088ec2d0c..0da985793 100644 --- a/src/env_loader.zig +++ b/src/env_loader.zig @@ -869,25 +869,25 @@ pub const Map = struct { try this.map.put(key, value); } - pub fn jsonStringify(self: *const @This(), options: anytype, writer: anytype) !void { + pub fn jsonStringify(self: *const @This(), writer: anytype) !void { var iterator = self.map.iterator(); - _ = try writer.writeAll("{"); + _ = try writer.write("{"); while (iterator.next()) |entry| { - _ = try writer.writeAll("\n "); + _ = try writer.write("\n "); - std.json.stringify(entry.key_ptr.*, options, writer) catch unreachable; + writer.write(entry.key_ptr.*) catch unreachable; - _ = try writer.writeAll(": "); + _ = try writer.write(": "); - std.json.stringify(entry.value_ptr.*, options, writer) catch unreachable; + writer.write(entry.value_ptr.*) catch unreachable; if (iterator.index <= self.map.count() - 1) { - _ = try writer.writeAll(", "); + _ = try writer.write(", "); } } - try writer.writeAll("\n}"); + try writer.write("\n}"); } pub inline fn get( diff --git a/src/fs.zig b/src/fs.zig index 51d3fb4b7..3c35d068b 100644 --- a/src/fs.zig +++ b/src/fs.zig @@ -1578,8 +1578,8 @@ pub const Path = struct { this.is_symlink = true; } - pub fn jsonStringify(self: *const @This(), options: anytype, writer: anytype) !void { - return try std.json.stringify(self.text, options, writer); + pub fn jsonStringify(self: *const @This(), writer: anytype) !void { + return try writer.write(self.text); } pub fn generateKey(p: *Path, allocator: std.mem.Allocator) !string { diff --git a/src/import_record.zig b/src/import_record.zig index 8fd29e805..3044c9b47 100644 --- a/src/import_record.zig +++ b/src/import_record.zig @@ -62,8 +62,8 @@ pub const ImportKind = enum(u8) { }; } - pub fn jsonStringify(self: @This(), options: anytype, writer: anytype) !void { - return try std.json.stringify(@tagName(self), options, writer); + pub fn jsonStringify(self: @This(), writer: anytype) !void { + return try writer.write(@tagName(self)); } pub fn isFromCSS(k: ImportKind) bool { diff --git a/src/js_ast.zig b/src/js_ast.zig index aeccdd1f3..673b93bf3 100644 --- a/src/js_ast.zig +++ b/src/js_ast.zig @@ -262,8 +262,8 @@ pub const ImportItemStatus = enum(u2) { // The printer will replace this import with "undefined" missing, - pub fn jsonStringify(self: @This(), opts: anytype, o: anytype) !void { - return try std.json.stringify(@tagName(self), opts, o); + pub fn jsonStringify(self: @This(), writer: anytype) !void { + return try writer.write(@tagName(self)); } }; @@ -271,8 +271,8 @@ pub const AssignTarget = enum(u2) { none = 0, replace = 1, // "a = b" update = 2, // "a += b" - pub fn jsonStringify(self: *const @This(), opts: anytype, o: anytype) !void { - return try std.json.stringify(@tagName(self), opts, o); + pub fn jsonStringify(self: *const @This(), writer: anytype) !void { + return try writer.write(@tagName(self)); } }; @@ -348,8 +348,8 @@ pub const Binding = struct { loc: logger.Loc, }; - pub fn jsonStringify(self: *const @This(), options: anytype, writer: anytype) !void { - return try std.json.stringify(Serializable{ .type = std.meta.activeTag(self.data), .object = "binding", .value = self.data, .loc = self.loc }, options, writer); + pub fn jsonStringify(self: *const @This(), writer: anytype) !void { + return try writer.write(Serializable{ .type = std.meta.activeTag(self.data), .object = "binding", .value = self.data, .loc = self.loc }); } pub fn ToExpr(comptime expr_type: type, comptime func_type: anytype) type { @@ -437,8 +437,8 @@ pub const Binding = struct { b_object, b_missing, - pub fn jsonStringify(self: @This(), opts: anytype, o: anytype) !void { - return try std.json.stringify(@tagName(self), opts, o); + pub fn jsonStringify(self: @This(), writer: anytype) !void { + return try writer.write(@tagName(self)); } }; @@ -844,8 +844,8 @@ pub const G = struct { declare, class_static_block, - pub fn jsonStringify(self: @This(), opts: anytype, o: anytype) !void { - return try std.json.stringify(@tagName(self), opts, o); + pub fn jsonStringify(self: @This(), writer: anytype) !void { + return try writer.write(@tagName(self)); } }; }; @@ -1152,8 +1152,8 @@ pub const Symbol = struct { // This annotates all other symbols that don't have special behavior. other, - pub fn jsonStringify(self: @This(), opts: anytype, o: anytype) !void { - return try std.json.stringify(@tagName(self), opts, o); + pub fn jsonStringify(self: @This(), writer: anytype) !void { + return try writer.write(@tagName(self)); } pub inline fn isPrivate(kind: Symbol.Kind) bool { @@ -1371,8 +1371,8 @@ pub const OptionalChain = enum(u2) { // "(a?.b).c" => ".c" is OptionalChain null ccontinue, - pub fn jsonStringify(self: @This(), opts: anytype, o: anytype) !void { - return try std.json.stringify(@tagName(self), opts, o); + pub fn jsonStringify(self: @This(), writer: anytype) !void { + return try writer.write(@tagName(self)); } }; @@ -1683,8 +1683,8 @@ pub const E = struct { }; pub const Missing = struct { - pub fn jsonStringify(_: *const @This(), opts: anytype, o: anytype) !void { - return try std.json.stringify(null, opts, o); + pub fn jsonStringify(_: *const @This(), writer: anytype) !void { + return try writer.write(null); } }; @@ -1754,8 +1754,8 @@ pub const E = struct { return @as(T, @intFromFloat(@min(@max(@trunc(self.value), 0), comptime @min(std.math.floatMax(f64), std.math.maxInt(T))))); } - pub fn jsonStringify(self: *const Number, opts: anytype, o: anytype) !void { - return try std.json.stringify(self.value, opts, o); + pub fn jsonStringify(self: *const Number, writer: anytype) !void { + return try writer.write(self.value); } pub fn toJS(this: @This()) JSC.JSValue { @@ -1768,8 +1768,8 @@ pub const E = struct { pub var empty = BigInt{ .value = "" }; - pub fn jsonStringify(self: *const @This(), opts: anytype, o: anytype) !void { - return try std.json.stringify(self.value, opts, o); + pub fn jsonStringify(self: *const @This(), writer: anytype) !void { + return try writer.write(self.value); } pub fn toJS(_: @This()) JSC.JSValue { @@ -2401,7 +2401,7 @@ pub const E = struct { } } - pub fn jsonStringify(s: *const String, options: anytype, writer: anytype) !void { + pub fn jsonStringify(s: *const String, writer: anytype) !void { var buf = [_]u8{0} ** 4096; var i: usize = 0; for (s.slice16()) |char| { @@ -2412,7 +2412,7 @@ pub const E = struct { } } - return try std.json.stringify(buf[0..i], options, writer); + return try writer.write(buf[0..i]); } }; @@ -2580,8 +2580,8 @@ pub const E = struct { return ""; } - pub fn jsonStringify(self: *const RegExp, opts: anytype, o: anytype) !void { - return try std.json.stringify(self.value, opts, o); + pub fn jsonStringify(self: *const RegExp, writer: anytype) !void { + return try writer.write(self.value); } }; @@ -2658,8 +2658,8 @@ pub const Stmt = struct { loc: logger.Loc, }; - pub fn jsonStringify(self: *const Stmt, options: anytype, writer: anytype) !void { - return try std.json.stringify(Serializable{ .type = std.meta.activeTag(self.data), .object = "stmt", .value = self.data, .loc = self.loc }, options, writer); + pub fn jsonStringify(self: *const Stmt, writer: anytype) !void { + return try writer.write(Serializable{ .type = std.meta.activeTag(self.data), .object = "stmt", .value = self.data, .loc = self.loc }); } pub fn isTypeScript(self: *Stmt) bool { @@ -2876,8 +2876,8 @@ pub const Stmt = struct { s_while, s_with, - pub fn jsonStringify(self: @This(), opts: anytype, o: anytype) !void { - return try std.json.stringify(@tagName(self), opts, o); + pub fn jsonStringify(self: @This(), writer: anytype) !void { + return try writer.write(@tagName(self)); } pub fn isExportLike(tag: Tag) bool { @@ -3367,8 +3367,8 @@ pub const Expr = struct { } } - pub fn jsonStringify(self: *const @This(), options: anytype, writer: anytype) !void { - return try std.json.stringify(Serializable{ .type = std.meta.activeTag(self.data), .object = "expr", .value = self.data, .loc = self.loc }, options, writer); + pub fn jsonStringify(self: *const @This(), writer: anytype) !void { + return try writer.write(Serializable{ .type = std.meta.activeTag(self.data), .object = "expr", .value = self.data, .loc = self.loc }); } pub fn extractNumericValues(left: Expr.Data, right: Expr.Data) ?[2]f64 { @@ -4258,8 +4258,8 @@ pub const Expr = struct { }; } - pub fn jsonStringify(self: @This(), opts: anytype, o: anytype) !void { - return try std.json.stringify(@tagName(self), opts, o); + pub fn jsonStringify(self: @This(), writer: anytype) !void { + return try writer.write(@tagName(self)); } pub fn isArray(self: Tag) bool { @@ -5112,7 +5112,7 @@ pub const Expr = struct { pub fn toNumber(data: Expr.Data) ?f64 { return switch (data) { .e_null => 0, - .e_undefined => std.math.nan_f64, + .e_undefined => std.math.nan(f64), .e_boolean => @as(f64, if (data.e_boolean.value) 1.0 else 0.0), .e_number => data.e_number.value, else => null, @@ -5598,8 +5598,8 @@ pub const S = struct { k_var, k_let, k_const, - pub fn jsonStringify(self: @This(), opts: anytype, o: anytype) !void { - return try std.json.stringify(@tagName(self), opts, o); + pub fn jsonStringify(self: @This(), writer: anytype) !void { + return try writer.write(@tagName(self)); } }; }; @@ -5734,8 +5734,8 @@ pub const Op = struct { /// Right-associative bin_logical_and_assign, - pub fn jsonStringify(self: @This(), opts: anytype, o: anytype) !void { - return try std.json.stringify(@tagName(self), opts, o); + pub fn jsonStringify(self: @This(), writer: anytype) !void { + return try writer.write(@tagName(self)); } pub fn unaryAssignTarget(code: Op.Code) AssignTarget { @@ -5835,8 +5835,8 @@ pub const Op = struct { }; } - pub fn jsonStringify(self: *const @This(), opts: anytype, o: anytype) !void { - return try std.json.stringify(self.text, opts, o); + pub fn jsonStringify(self: *const @This(), writer: anytype) !void { + return try writer.write(self.text); } pub const TableType: std.EnumArray(Op.Code, Op) = undefined; @@ -6266,8 +6266,8 @@ pub const ExportsKind = enum { return dynamic.contains(self); } - pub fn jsonStringify(self: @This(), opts: anytype, o: anytype) !void { - return try std.json.stringify(@tagName(self), opts, o); + pub fn jsonStringify(self: @This(), writer: anytype) !void { + return try writer.write(@tagName(self)); } pub fn isESMWithDynamicFallback(self: ExportsKind) bool { @@ -6441,8 +6441,8 @@ pub const Part = struct { }; pub const SymbolUseMap = std.ArrayHashMapUnmanaged(Ref, Symbol.Use, RefHashCtx, false); - pub fn jsonStringify(self: *const Part, options: std.json.StringifyOptions, writer: anytype) !void { - return std.json.stringify(self.stmts, options, writer); + pub fn jsonStringify(self: *const Part, writer: anytype) !void { + return writer.write(self.stmts); } }; @@ -6488,8 +6488,8 @@ pub const StrictModeKind = enum(u4) { implicit_strict_mode_export, implicit_strict_mode_top_level_await, implicit_strict_mode_class, - pub fn jsonStringify(self: @This(), opts: anytype, o: anytype) !void { - return try std.json.stringify(@tagName(self), opts, o); + pub fn jsonStringify(self: @This(), writer: anytype) !void { + return try writer.write(@tagName(self)); } }; @@ -6676,8 +6676,8 @@ pub const Scope = struct { function_body, class_static_init, - pub fn jsonStringify(self: @This(), opts: anytype, o: anytype) !void { - return try std.json.stringify(@tagName(self), opts, o); + pub fn jsonStringify(self: @This(), writer: anytype) !void { + return try writer.write(@tagName(self)); } }; diff --git a/src/js_parser.zig b/src/js_parser.zig index b116aa2e4..68e45ace2 100644 --- a/src/js_parser.zig +++ b/src/js_parser.zig @@ -2656,7 +2656,7 @@ pub const Parser = struct { } }; - pub fn scanImports(self: *Parser, scan_pass: *ScanPassResult) !void { + pub fn scanImports(self: *Parser, scan_pass: *ScanPassResult) anyerror!void { if (self.options.ts and self.options.jsx.parse) { return try self._scanImports(TSXImportScanner, scan_pass); } else if (self.options.ts) { @@ -2668,7 +2668,7 @@ pub const Parser = struct { } } - fn _scanImports(self: *Parser, comptime ParserType: type, scan_pass: *ScanPassResult) !void { + fn _scanImports(self: *Parser, comptime ParserType: type, scan_pass: *ScanPassResult) anyerror!void { var p: ParserType = undefined; try ParserType.init(self.allocator, self.log, self.source, self.define, self.lexer, self.options, &p); @@ -5169,7 +5169,7 @@ fn NewParser_( return p.callRuntime(require_args[0].loc, "__require", require_args); } - pub fn recordExport(p: *P, loc: logger.Loc, alias: string, ref: Ref) !void { + pub fn recordExport(p: *P, loc: logger.Loc, alias: string, ref: Ref) anyerror!void { if (p.named_exports.get(alias)) |name| { // Duplicate exports are an error var notes = try p.allocator.alloc(logger.Data, 1); @@ -5320,7 +5320,7 @@ fn NewParser_( additional_stmt: ?Stmt, comptime suffix: string, comptime is_internal: bool, - ) !void { + ) anyerror!void { const allocator = p.allocator; const import_record_i = p.addImportRecordByRange(.stmt, logger.Range.None, import_path); var import_record: *ImportRecord = &p.import_records.items[import_record_i]; @@ -5874,7 +5874,7 @@ fn NewParser_( return .{ .failure = expr }; } - pub fn prepareForVisitPass(p: *P) !void { + pub fn prepareForVisitPass(p: *P) anyerror!void { { var count: usize = 0; for (p.scopes_in_order.items) |item| { @@ -6306,7 +6306,7 @@ fn NewParser_( return head; } - fn pushScopeForVisitPass(p: *P, kind: js_ast.Scope.Kind, loc: logger.Loc) !void { + fn pushScopeForVisitPass(p: *P, kind: js_ast.Scope.Kind, loc: logger.Loc) anyerror!void { // Output.print("\n+Loc: {d}\n", .{loc.start}); // for (p.scopes_in_order.items[p.scopes_in_order_visitor_index..p.scopes_in_order.items.len]) |scope_order, i| { // if (scope_order) |ord| { @@ -6518,7 +6518,7 @@ fn NewParser_( return ExprBindingTuple{ .binding = bind, .expr = initializer }; } - fn forbidLexicalDecl(p: *P, loc: logger.Loc) !void { + fn forbidLexicalDecl(p: *P, loc: logger.Loc) anyerror!void { try p.log.addError(p.source, loc, "Cannot use a declaration in a single-statement context"); } @@ -9479,7 +9479,7 @@ fn NewParser_( ); } - fn skipTypeScriptInterfaceStmt(p: *P, opts: *ParseStatementOptions) !void { + fn skipTypeScriptInterfaceStmt(p: *P, opts: *ParseStatementOptions) anyerror!void { const name = p.lexer.identifier; try p.lexer.expect(.t_identifier); @@ -9750,7 +9750,7 @@ fn NewParser_( }; } - fn forbidInitializers(p: *P, decls: []G.Decl, comptime loop_type: string, is_var: bool) !void { + fn forbidInitializers(p: *P, decls: []G.Decl, comptime loop_type: string, is_var: bool) anyerror!void { switch (decls.len) { 0 => {}, 1 => { @@ -9810,7 +9810,7 @@ fn NewParser_( return ExprOrLetStmt{ .stmt_or_expr = js_ast.StmtOrExpr{ .expr = try p.parseSuffix(expr, .lowest, null, Expr.EFlags.none) } }; } - fn requireInitializers(p: *P, decls: []G.Decl) !void { + fn requireInitializers(p: *P, decls: []G.Decl) anyerror!void { for (decls) |decl| { if (decl.value == null) { switch (decl.binding.data) { @@ -10553,7 +10553,7 @@ fn NewParser_( return stmts.items; } - fn markStrictModeFeature(p: *P, feature: StrictModeFeature, r: logger.Range, detail: string) !void { + fn markStrictModeFeature(p: *P, feature: StrictModeFeature, r: logger.Range, detail: string) anyerror!void { const can_be_transformed = feature == StrictModeFeature.for_in_var_init; const text = switch (feature) { .with_statement => "With statements", @@ -10866,7 +10866,7 @@ fn NewParser_( return E.Arrow{ .args = args, .prefer_expr = true, .body = G.FnBody{ .loc = arrow_loc, .stmts = stmts } }; } - fn declareBinding(p: *P, kind: Symbol.Kind, binding: *BindingNodeIndex, opts: *ParseStatementOptions) !void { + fn declareBinding(p: *P, kind: Symbol.Kind, binding: *BindingNodeIndex, opts: *ParseStatementOptions) anyerror!void { switch (binding.data) { .b_missing => {}, .b_identifier => |bind| { @@ -13956,7 +13956,7 @@ fn NewParser_( }; } - fn appendPart(p: *P, parts: *ListManaged(js_ast.Part), stmts: []Stmt) !void { + fn appendPart(p: *P, parts: *ListManaged(js_ast.Part), stmts: []Stmt) anyerror!void { // Reuse the memory if possible // This is reusable if the last part turned out to be dead p.symbol_uses.clearRetainingCapacity(); @@ -14180,7 +14180,7 @@ fn NewParser_( } } - fn recordDeclaredSymbol(p: *P, ref: Ref) !void { + fn recordDeclaredSymbol(p: *P, ref: Ref) anyerror!void { std.debug.assert(ref.isSymbol()); try p.declared_symbols.append(p.allocator, DeclaredSymbol{ .ref = ref, @@ -17109,7 +17109,7 @@ fn NewParser_( // the value is ignored because that's what the TypeScript compiler does. } - fn visitAndAppendStmt(p: *P, stmts: *ListManaged(Stmt), stmt: *Stmt) !void { + fn visitAndAppendStmt(p: *P, stmts: *ListManaged(Stmt), stmt: *Stmt) anyerror!void { // By default any statement ends the const local prefix const was_after_after_const_local_prefix = p.current_scope.is_after_const_local_prefix; p.current_scope.is_after_const_local_prefix = true; @@ -18537,7 +18537,7 @@ fn NewParser_( } } - pub fn appendIfBodyPreservingScope(p: *P, stmts: *ListManaged(Stmt), body: Stmt) !void { + pub fn appendIfBodyPreservingScope(p: *P, stmts: *ListManaged(Stmt), body: Stmt) anyerror!void { switch (body.data) { .s_block => |block| { var keep_block = false; @@ -19551,7 +19551,7 @@ fn NewParser_( } // Try separating the list for appending, so that it's not a pointer. - fn visitStmts(p: *P, stmts: *ListManaged(Stmt), _: StmtsKind) !void { + fn visitStmts(p: *P, stmts: *ListManaged(Stmt), _: StmtsKind) anyerror!void { if (only_scan_imports_and_do_not_visit) { @compileError("only_scan_imports_and_do_not_visit must not run this."); } @@ -20049,7 +20049,7 @@ fn NewParser_( stmts.* = output; } - fn extractDeclsForBinding(binding: Binding, decls: *ListManaged(G.Decl)) !void { + fn extractDeclsForBinding(binding: Binding, decls: *ListManaged(G.Decl)) anyerror!void { switch (binding.data) { .b_property, .b_missing => {}, .b_identifier => { @@ -21239,7 +21239,7 @@ fn NewParser_( lexer: js_lexer.Lexer, opts: Parser.Options, this: *P, - ) !void { + ) anyerror!void { var scope_order = try ScopeOrderList.initCapacity(allocator, 1); var scope = try allocator.create(Scope); scope.* = Scope{ diff --git a/src/logger.zig b/src/logger.zig index 21a58243c..9ec2dc7ca 100644 --- a/src/logger.zig +++ b/src/logger.zig @@ -84,8 +84,8 @@ pub const Loc = struct { return loc.start == other.start; } - pub fn jsonStringify(self: *const Loc, options: anytype, writer: anytype) !void { - return try std.json.stringify(self.start, options, writer); + pub fn jsonStringify(self: *const Loc, writer: anytype) !void { + return try writer.write(self.start); } }; @@ -616,8 +616,8 @@ pub const Range = struct { return std.math.lossyCast(usize, self.loc.start + self.len); } - pub fn jsonStringify(self: *const Range, options: anytype, writer: anytype) !void { - return try std.json.stringify([2]i32{ self.loc.start, self.len + self.loc.start }, options, writer); + pub fn jsonStringify(self: *const Range, writer: anytype) !void { + return try writer.write([2]i32{ self.loc.start, self.len + self.loc.start }); } }; diff --git a/src/output.zig b/src/output.zig index 4feab6189..2b3f8cca5 100644 --- a/src/output.zig +++ b/src/output.zig @@ -9,6 +9,8 @@ const StringTypes = @import("root").bun.StringTypes; const Global = @import("root").bun.Global; const ComptimeStringMap = @import("root").bun.ComptimeStringMap; const use_mimalloc = @import("root").bun.use_mimalloc; +const writeStream = std.json.writeStream; +const WriteStream = std.json.WriteStream; const SystemTimer = @import("./system_timer.zig").Timer; diff --git a/src/resolver/resolver.zig b/src/resolver/resolver.zig index 2730daf42..08eca8333 100644 --- a/src/resolver/resolver.zig +++ b/src/resolver/resolver.zig @@ -68,34 +68,34 @@ const bufs = struct { // bundling 10 copies of Three.js. It may be worthwhile for more complicated // packages but we lack a decent module resolution benchmark right now. // Potentially revisit after https://github.com/oven-sh/bun/issues/2716 - threadlocal var extension_path: [512]u8 = undefined; - threadlocal var tsconfig_match_full_buf: [bun.MAX_PATH_BYTES]u8 = undefined; - threadlocal var tsconfig_match_full_buf2: [bun.MAX_PATH_BYTES]u8 = undefined; - - threadlocal var esm_subpath: [512]u8 = undefined; - threadlocal var esm_absolute_package_path: [bun.MAX_PATH_BYTES]u8 = undefined; - threadlocal var esm_absolute_package_path_joined: [bun.MAX_PATH_BYTES]u8 = undefined; - - threadlocal var dir_entry_paths_to_resolve: [256]DirEntryResolveQueueItem = undefined; - threadlocal var open_dirs: [256]std.fs.IterableDir = undefined; - threadlocal var resolve_without_remapping: [bun.MAX_PATH_BYTES]u8 = undefined; - threadlocal var index: [bun.MAX_PATH_BYTES]u8 = undefined; - threadlocal var dir_info_uncached_filename: [bun.MAX_PATH_BYTES]u8 = undefined; - threadlocal var node_bin_path: [bun.MAX_PATH_BYTES]u8 = undefined; - threadlocal var dir_info_uncached_path: [bun.MAX_PATH_BYTES]u8 = undefined; - threadlocal var tsconfig_base_url: [bun.MAX_PATH_BYTES]u8 = undefined; - threadlocal var relative_abs_path: [bun.MAX_PATH_BYTES]u8 = undefined; - threadlocal var load_as_file_or_directory_via_tsconfig_base_path: [bun.MAX_PATH_BYTES]u8 = undefined; - threadlocal var node_modules_check: [bun.MAX_PATH_BYTES]u8 = undefined; - threadlocal var field_abs_path: [bun.MAX_PATH_BYTES]u8 = undefined; - threadlocal var tsconfig_path_abs: [bun.MAX_PATH_BYTES]u8 = undefined; - threadlocal var check_browser_map: [bun.MAX_PATH_BYTES]u8 = undefined; - threadlocal var remap_path: [bun.MAX_PATH_BYTES]u8 = undefined; - threadlocal var load_as_file: [bun.MAX_PATH_BYTES]u8 = undefined; - threadlocal var remap_path_trailing_slash: [bun.MAX_PATH_BYTES]u8 = undefined; - threadlocal var path_in_global_disk_cache: [bun.MAX_PATH_BYTES]u8 = undefined; - threadlocal var abs_to_rel: [bun.MAX_PATH_BYTES]u8 = undefined; - threadlocal var node_modules_paths_buf: [bun.MAX_PATH_BYTES]u8 = undefined; + pub threadlocal var extension_path: [512]u8 = undefined; + pub threadlocal var tsconfig_match_full_buf: [bun.MAX_PATH_BYTES]u8 = undefined; + pub threadlocal var tsconfig_match_full_buf2: [bun.MAX_PATH_BYTES]u8 = undefined; + + pub threadlocal var esm_subpath: [512]u8 = undefined; + pub threadlocal var esm_absolute_package_path: [bun.MAX_PATH_BYTES]u8 = undefined; + pub threadlocal var esm_absolute_package_path_joined: [bun.MAX_PATH_BYTES]u8 = undefined; + + pub threadlocal var dir_entry_paths_to_resolve: [256]DirEntryResolveQueueItem = undefined; + pub threadlocal var open_dirs: [256]std.fs.IterableDir = undefined; + pub threadlocal var resolve_without_remapping: [bun.MAX_PATH_BYTES]u8 = undefined; + pub threadlocal var index: [bun.MAX_PATH_BYTES]u8 = undefined; + pub threadlocal var dir_info_uncached_filename: [bun.MAX_PATH_BYTES]u8 = undefined; + pub threadlocal var node_bin_path: [bun.MAX_PATH_BYTES]u8 = undefined; + pub threadlocal var dir_info_uncached_path: [bun.MAX_PATH_BYTES]u8 = undefined; + pub threadlocal var tsconfig_base_url: [bun.MAX_PATH_BYTES]u8 = undefined; + pub threadlocal var relative_abs_path: [bun.MAX_PATH_BYTES]u8 = undefined; + pub threadlocal var load_as_file_or_directory_via_tsconfig_base_path: [bun.MAX_PATH_BYTES]u8 = undefined; + pub threadlocal var node_modules_check: [bun.MAX_PATH_BYTES]u8 = undefined; + pub threadlocal var field_abs_path: [bun.MAX_PATH_BYTES]u8 = undefined; + pub threadlocal var tsconfig_path_abs: [bun.MAX_PATH_BYTES]u8 = undefined; + pub threadlocal var check_browser_map: [bun.MAX_PATH_BYTES]u8 = undefined; + pub threadlocal var remap_path: [bun.MAX_PATH_BYTES]u8 = undefined; + pub threadlocal var load_as_file: [bun.MAX_PATH_BYTES]u8 = undefined; + pub threadlocal var remap_path_trailing_slash: [bun.MAX_PATH_BYTES]u8 = undefined; + pub threadlocal var path_in_global_disk_cache: [bun.MAX_PATH_BYTES]u8 = undefined; + pub threadlocal var abs_to_rel: [bun.MAX_PATH_BYTES]u8 = undefined; + pub threadlocal var node_modules_paths_buf: [bun.MAX_PATH_BYTES]u8 = undefined; pub inline fn bufs(comptime field: std.meta.DeclEnum(@This())) *@TypeOf(@field(@This(), @tagName(field))) { return &@field(@This(), @tagName(field)); diff --git a/src/sync.zig b/src/sync.zig index d2ecd95bd..ec9105cf3 100644 --- a/src/sync.zig +++ b/src/sync.zig @@ -69,7 +69,7 @@ pub const ThreadPool = struct { const allocator = self.allocator; const closure = try allocator.create(Closure); - errdefer allocator.free(closure); + errdefer allocator.destroy(closure); closure.* = Closure{ .func_args = args, .allocator = allocator, |