authorgravatar for pentuppup@noreply.codeberg.orgpentuppup <pentuppup@noreply.codeberg.org> 2026-09-29 14:33:22-04:00
committergravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2026-10-10 09:13:00+02:00
log63978e36b026909f3bb5c6c9ac9bbc44466eaa1f
tree0a5e2763bfc63fb4b87ef43c34706716ec1743fb
parente2636e8c868f472a4b7a2b4a0d1386f1560fda80
signature Signed by SSH key SHA256:7B/LJ7bpR1eX8aCXSr4mtd5M45VMPKcx9zY8e95b5QM

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 {...@@ -43,7 +43,7 @@ fn runServer(ids: *IncrementalDebugServer) void {
43 const io = ids.zcu.comp.io;43 const io = ids.zcu.comp.io;
4444
45 const addr: Io.net.IpAddress = .{ .ip6 = .loopback(port) };45 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) {
47 error.Canceled => return,47 error.Canceled => return,
48 else => |e| {48 else => |e| {
49 log.err("listen failed ({t}); closing server", .{e});49 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...@@ -223,13 +223,12 @@ fn handleCommand(zcu: *Zcu, w: *Io.Writer, cmd_str: []const u8, arg_str: []const
223 create_gen,223 create_gen,
224 });224 });
225 if (nav.resolved) |r| {225 if (nav.resolved) |r| {
226 try w.writeAll("status: resolved\n type: ");226 try w.print("status: resolved\n type: {f}", .{Type.fromInterned(r.type).fmt(zcu)});
227 try printType(.fromInterned(r.type), zcu, w);
228 try w.writeAll("\n value: ");227 try w.writeAll("\n value: ");
229 if (r.value == .none) {228 if (r.value == .none) {
230 try w.writeAll("(unresolved)");229 try w.writeAll("(unresolved)");
231 } else {230 } else {
232 try printType(.fromInterned(r.type), zcu, w);231 try w.print("{f}", .{Value.fromInterned(r.value).fmtValue(zcu)});
233 }232 }
234 try w.writeByte('\n');233 try w.writeByte('\n');
235 } else {234 } else {
...@@ -411,52 +410,6 @@ fn printAnalUnit(unit: AnalUnit, buf: *[32]u8) []const u8 {...@@ -411,52 +410,6 @@ fn printAnalUnit(unit: AnalUnit, buf: *[32]u8) []const u8 {
411 return std.mem.print(buf, "{s} {d}", .{ @tagName(unit.unwrap()), idx }) catch unreachable;410 return std.mem.print(buf, "{s} {d}", .{ @tagName(unit.unwrap()), idx }) catch unreachable;
412}411}
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
460const std = @import("std");413const std = @import("std");
461const Io = std.Io;414const Io = std.Io;
462const Allocator = std.mem.Allocator;415const Allocator = std.mem.Allocator;
...@@ -466,6 +419,7 @@ const Compilation = @import("Compilation.zig");...@@ -466,6 +419,7 @@ const Compilation = @import("Compilation.zig");
466const Zcu = @import("Zcu.zig");419const Zcu = @import("Zcu.zig");
467const InternPool = @import("InternPool.zig");420const InternPool = @import("InternPool.zig");
468const Type = @import("Type.zig");421const Type = @import("Type.zig");
422const Value = @import("Value.zig");
469const AnalUnit = InternPool.AnalUnit;423const AnalUnit = InternPool.AnalUnit;
470424
471const IncrementalDebugServer = @This();425const IncrementalDebugServer = @This();