From 63978e36b026909f3bb5c6c9ac9bbc44466eaa1f Mon Sep 17 00:00:00 2001 From: pentuppup Date: Tue, 29 Sep 2026 14:33:22 -0400 Subject: [PATCH] IncrementalDebugServer: update nav formatting and set reuse_address --- src/IncrementalDebugServer.zig | 54 +++------------------------------- 1 file changed, 4 insertions(+), 50 deletions(-) diff --git a/src/IncrementalDebugServer.zig b/src/IncrementalDebugServer.zig index d88691372b30f5f0bfd2ce7638c07816a6661723..c8cb5a26907835fa808d8f05eb6ba1d567131dc5 100644 --- a/src/IncrementalDebugServer.zig +++ b/src/IncrementalDebugServer.zig @@ -43,7 +43,7 @@ fn runServer(ids: *IncrementalDebugServer) void { const io = ids.zcu.comp.io; const addr: Io.net.IpAddress = .{ .ip6 = .loopback(port) }; - var server = addr.listen(io, .{}) catch |err| switch (err) { + var server = addr.listen(io, .{ .reuse_address = true }) catch |err| switch (err) { error.Canceled => return, else => |e| { 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 create_gen, }); if (nav.resolved) |r| { - try w.writeAll("status: resolved\n type: "); - try printType(.fromInterned(r.type), zcu, w); + try w.print("status: resolved\n type: {f}", .{Type.fromInterned(r.type).fmt(zcu)}); try w.writeAll("\n value: "); if (r.value == .none) { try w.writeAll("(unresolved)"); } else { - try printType(.fromInterned(r.type), zcu, w); + try w.print("{f}", .{Value.fromInterned(r.value).fmtValue(zcu)}); } try w.writeByte('\n'); } else { @@ -411,52 +410,6 @@ fn printAnalUnit(unit: AnalUnit, buf: *[32]u8) []const u8 { return std.mem.print(buf, "{s} {d}", .{ @tagName(unit.unwrap()), idx }) catch unreachable; } -fn printType(ty: Type, zcu: *const Zcu, w: *Io.Writer) Io.Writer.Error!void { - const ip = &zcu.intern_pool; - switch (ip.indexToKey(ty.toIntern())) { - .int_type => |int| try w.print("{c}{d}", .{ - @as(u8, if (int.signedness == .unsigned) 'u' else 'i'), - int.bits, - }), - .tuple_type => try w.writeAll("(tuple)"), - .error_set_type => try w.writeAll("(error set)"), - .inferred_error_set_type => try w.writeAll("(inferred error set)"), - .func_type => try w.writeAll("(function)"), - .anyframe_type => try w.writeAll("(anyframe)"), - .vector_type => { - try w.print("@Vector({d}, ", .{ty.vectorLen(zcu)}); - try printType(ty.childType(zcu), zcu, w); - try w.writeByte(')'); - }, - .array_type => { - try w.print("[{d}]", .{ty.arrayLen(zcu)}); - try printType(ty.childType(zcu), zcu, w); - }, - .opt_type => { - try w.writeByte('?'); - try printType(ty.optionalChild(zcu), zcu, w); - }, - .error_union_type => { - try printType(ty.errorUnionSet(zcu), zcu, w); - try w.writeByte('!'); - try printType(ty.errorUnionPayload(zcu), zcu, w); - }, - .ptr_type => { - try w.writeAll("*(attrs) "); - try printType(ty.childType(zcu), zcu, w); - }, - .simple_type => |simple| try w.writeAll(@tagName(simple)), - - .struct_type, - .union_type, - .enum_type, - .opaque_type, - => try w.print("{f}[{d}]", .{ ty.containerTypeName(ip).fqn.fmt(ip), @backingInt(ty.toIntern()) }), - - else => unreachable, - } -} - const std = @import("std"); const Io = std.Io; const Allocator = std.mem.Allocator; @@ -466,6 +419,7 @@ const Compilation = @import("Compilation.zig"); const Zcu = @import("Zcu.zig"); const InternPool = @import("InternPool.zig"); const Type = @import("Type.zig"); +const Value = @import("Value.zig"); const AnalUnit = InternPool.AnalUnit; const IncrementalDebugServer = @This(); -- 2.54.0