authorgravatar for pentuppup@noreply.codeberg.orgpentuppup <pentuppup@noreply.codeberg.org> 2026-09-29 14:33:22-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2026-10-10 00:23:53+02:00
log1f011a9bac506ae62fff5e5e2c7843be7365419c
tree092d4e26870ed56babbf00f01446e1f6467ac71f
parent85c863e348d5ba2a1aca3455fefa073047e77e4b

IncrementalDebugServer: update nav formatting and set reuse_address


1 files changed, 4 insertions(+), 50 deletions(-)

src/IncrementalDebugServer.zig+4-50
......@@ -43,7 +43,7 @@ fn runServer(ids: *IncrementalDebugServer) void {
4343 const io = ids.zcu.comp.io;
4444
4545 const addr: Io.net.IpAddress = .{ .ip6 = .loopback(port) };
46 var server = addr.listen(io, .{}) catch |err| switch (err) {
46 var server = addr.listen(io, .{ .reuse_address = true }) catch |err| switch (err) {
4747 error.Canceled => return,
4848 else => |e| {
4949 log.err("listen failed ({t}); closing server", .{e});
......@@ -223,13 +223,12 @@ fn handleCommand(zcu: *Zcu, w: *Io.Writer, cmd_str: []const u8, arg_str: []const
223223 create_gen,
224224 });
225225 if (nav.resolved) |r| {
226 try w.writeAll("status: resolved\n type: ");
227 try printType(.fromInterned(r.type), zcu, w);
226 try w.print("status: resolved\n type: {f}", .{Type.fromInterned(r.type).fmt(zcu)});
228227 try w.writeAll("\n value: ");
229228 if (r.value == .none) {
230229 try w.writeAll("(unresolved)");
231230 } else {
232 try printType(.fromInterned(r.type), zcu, w);
231 try w.print("{f}", .{Value.fromInterned(r.value).fmtValue(zcu)});
233232 }
234233 try w.writeByte('\n');
235234 } else {
......@@ -411,52 +410,6 @@ fn printAnalUnit(unit: AnalUnit, buf: *[32]u8) []const u8 {
411410 return std.mem.print(buf, "{s} {d}", .{ @tagName(unit.unwrap()), idx }) catch unreachable;
412411}
413412
414fn printType(ty: Type, zcu: *const Zcu, w: *Io.Writer) Io.Writer.Error!void {
415 const ip = &zcu.intern_pool;
416 switch (ip.indexToKey(ty.toIntern())) {
417 .int_type => |int| try w.print("{c}{d}", .{
418 @as(u8, if (int.signedness == .unsigned) 'u' else 'i'),
419 int.bits,
420 }),
421 .tuple_type => try w.writeAll("(tuple)"),
422 .error_set_type => try w.writeAll("(error set)"),
423 .inferred_error_set_type => try w.writeAll("(inferred error set)"),
424 .func_type => try w.writeAll("(function)"),
425 .anyframe_type => try w.writeAll("(anyframe)"),
426 .vector_type => {
427 try w.print("@Vector({d}, ", .{ty.vectorLen(zcu)});
428 try printType(ty.childType(zcu), zcu, w);
429 try w.writeByte(')');
430 },
431 .array_type => {
432 try w.print("[{d}]", .{ty.arrayLen(zcu)});
433 try printType(ty.childType(zcu), zcu, w);
434 },
435 .opt_type => {
436 try w.writeByte('?');
437 try printType(ty.optionalChild(zcu), zcu, w);
438 },
439 .error_union_type => {
440 try printType(ty.errorUnionSet(zcu), zcu, w);
441 try w.writeByte('!');
442 try printType(ty.errorUnionPayload(zcu), zcu, w);
443 },
444 .ptr_type => {
445 try w.writeAll("*(attrs) ");
446 try printType(ty.childType(zcu), zcu, w);
447 },
448 .simple_type => |simple| try w.writeAll(@tagName(simple)),
449
450 .struct_type,
451 .union_type,
452 .enum_type,
453 .opaque_type,
454 => try w.print("{f}[{d}]", .{ ty.containerTypeName(ip).fqn.fmt(ip), @backingInt(ty.toIntern()) }),
455
456 else => unreachable,
457 }
458}
459
460413const std = @import("std");
461414const Io = std.Io;
462415const Allocator = std.mem.Allocator;
......@@ -466,6 +419,7 @@ const Compilation = @import("Compilation.zig");
466419const Zcu = @import("Zcu.zig");
467420const InternPool = @import("InternPool.zig");
468421const Type = @import("Type.zig");
422const Value = @import("Value.zig");
469423const AnalUnit = InternPool.AnalUnit;
470424
471425const IncrementalDebugServer = @This();