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