| ... | @@ -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; |
| 44 | | 44 | |
| 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 | } |
| 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 | const std = @import("std"); | 413 | const std = @import("std"); |
| 461 | const Io = std.Io; | 414 | const Io = std.Io; |
| 462 | const Allocator = std.mem.Allocator; | 415 | const Allocator = std.mem.Allocator; |
| ... | @@ -466,6 +419,7 @@ const Compilation = @import("Compilation.zig"); | ... | @@ -466,6 +419,7 @@ const Compilation = @import("Compilation.zig"); |
| 466 | const Zcu = @import("Zcu.zig"); | 419 | const Zcu = @import("Zcu.zig"); |
| 467 | const InternPool = @import("InternPool.zig"); | 420 | const InternPool = @import("InternPool.zig"); |
| 468 | const Type = @import("Type.zig"); | 421 | const Type = @import("Type.zig"); |
| | 422 | const Value = @import("Value.zig"); |
| 469 | const AnalUnit = InternPool.AnalUnit; | 423 | const AnalUnit = InternPool.AnalUnit; |
| 470 | | 424 | |
| 471 | const IncrementalDebugServer = @This(); | 425 | const IncrementalDebugServer = @This(); |