mirror of
https://github.com/ziglang/zig.git
synced 2026-02-21 16:54:52 +00:00
sync
This commit is contained in:
parent
c9915e949e
commit
dd4eb86bc1
@ -1887,18 +1887,23 @@ pub const NullTerminatedString = enum(u32) {
|
|||||||
const FormatData = struct {
|
const FormatData = struct {
|
||||||
string: NullTerminatedString,
|
string: NullTerminatedString,
|
||||||
ip: *const InternPool,
|
ip: *const InternPool,
|
||||||
|
id: bool,
|
||||||
};
|
};
|
||||||
fn format(data: FormatData, bw: *std.io.Writer, comptime specifier: []const u8) std.io.Writer.Error!void {
|
fn format(data: FormatData, writer: *std.io.Writer) std.io.Writer.Error!void {
|
||||||
const slice = data.string.toSlice(data.ip);
|
const slice = data.string.toSlice(data.ip);
|
||||||
if (comptime std.mem.eql(u8, specifier, "")) {
|
if (!data.id) {
|
||||||
try bw.writeAll(slice);
|
try writer.writeAll(slice);
|
||||||
} else if (comptime std.mem.eql(u8, specifier, "i")) {
|
} else {
|
||||||
try bw.print("{fp}", .{std.zig.fmtId(slice)});
|
try writer.print("{f}", .{std.zig.fmtIdP(slice)});
|
||||||
} else @compileError("invalid format string '" ++ specifier ++ "' for '" ++ @typeName(NullTerminatedString) ++ "'");
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn fmt(string: NullTerminatedString, ip: *const InternPool) std.fmt.Formatter(format) {
|
pub fn fmt(string: NullTerminatedString, ip: *const InternPool) std.fmt.Formatter(FormatData, format) {
|
||||||
return .{ .data = .{ .string = string, .ip = ip } };
|
return .{ .data = .{ .string = string, .ip = ip, .id = false } };
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn fmtId(string: NullTerminatedString, ip: *const InternPool) std.fmt.Formatter(FormatData, format) {
|
||||||
|
return .{ .data = .{ .string = string, .ip = ip, .id = true } };
|
||||||
}
|
}
|
||||||
|
|
||||||
const debug_state = InternPool.debug_state;
|
const debug_state = InternPool.debug_state;
|
||||||
@ -11409,7 +11414,7 @@ pub fn dumpGenericInstancesFallible(ip: *const InternPool, allocator: Allocator)
|
|||||||
var it = instances.iterator();
|
var it = instances.iterator();
|
||||||
while (it.next()) |entry| {
|
while (it.next()) |entry| {
|
||||||
const generic_fn_owner_nav = ip.getNav(ip.funcDeclInfo(entry.key_ptr.*).owner_nav);
|
const generic_fn_owner_nav = ip.getNav(ip.funcDeclInfo(entry.key_ptr.*).owner_nav);
|
||||||
try stderr_bw.print("{f} ({}): \n", .{ generic_fn_owner_nav.name.fmt(ip), entry.value_ptr.items.len });
|
try stderr_bw.print("{f} ({d}): \n", .{ generic_fn_owner_nav.name.fmt(ip), entry.value_ptr.items.len });
|
||||||
for (entry.value_ptr.items) |index| {
|
for (entry.value_ptr.items) |index| {
|
||||||
const unwrapped_index = index.unwrap(ip);
|
const unwrapped_index = index.unwrap(ip);
|
||||||
const func = ip.extraFuncInstance(unwrapped_index.tid, unwrapped_index.getExtra(ip), unwrapped_index.getData(ip));
|
const func = ip.extraFuncInstance(unwrapped_index.tid, unwrapped_index.getExtra(ip), unwrapped_index.getData(ip));
|
||||||
|
|||||||
@ -80,19 +80,19 @@ fn dumpStatusReport() !void {
|
|||||||
var fba = std.heap.FixedBufferAllocator.init(&crash_heap);
|
var fba = std.heap.FixedBufferAllocator.init(&crash_heap);
|
||||||
const allocator = fba.allocator();
|
const allocator = fba.allocator();
|
||||||
|
|
||||||
var stderr_fw = std.fs.File.stderr().writer();
|
var stderr_fw = std.fs.File.stderr().writer(&.{});
|
||||||
var stderr_bw = stderr_fw.interface().unbuffered();
|
const stderr = &stderr_fw.interface;
|
||||||
const block: *Sema.Block = anal.block;
|
const block: *Sema.Block = anal.block;
|
||||||
const zcu = anal.sema.pt.zcu;
|
const zcu = anal.sema.pt.zcu;
|
||||||
|
|
||||||
const file, const src_base_node = Zcu.LazySrcLoc.resolveBaseNode(block.src_base_inst, zcu) orelse {
|
const file, const src_base_node = Zcu.LazySrcLoc.resolveBaseNode(block.src_base_inst, zcu) orelse {
|
||||||
const file = zcu.fileByIndex(block.src_base_inst.resolveFile(&zcu.intern_pool));
|
const file = zcu.fileByIndex(block.src_base_inst.resolveFile(&zcu.intern_pool));
|
||||||
try stderr_bw.print("Analyzing lost instruction in file '{f}'. This should not happen!\n\n", .{file.path.fmt(zcu.comp)});
|
try stderr.print("Analyzing lost instruction in file '{f}'. This should not happen!\n\n", .{file.path.fmt(zcu.comp)});
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
|
|
||||||
try stderr_bw.writeAll("Analyzing ");
|
try stderr.writeAll("Analyzing ");
|
||||||
try stderr_bw.print("Analyzing '{f}'\n", .{file.path.fmt(zcu.comp)});
|
try stderr.print("Analyzing '{f}'\n", .{file.path.fmt(zcu.comp)});
|
||||||
|
|
||||||
print_zir.renderInstructionContext(
|
print_zir.renderInstructionContext(
|
||||||
allocator,
|
allocator,
|
||||||
@ -101,12 +101,12 @@ fn dumpStatusReport() !void {
|
|||||||
file,
|
file,
|
||||||
src_base_node,
|
src_base_node,
|
||||||
6, // indent
|
6, // indent
|
||||||
&stderr_bw,
|
stderr,
|
||||||
) catch |err| switch (err) {
|
) catch |err| switch (err) {
|
||||||
error.OutOfMemory => try stderr_bw.writeAll(" <out of memory dumping zir>\n"),
|
error.OutOfMemory => try stderr.writeAll(" <out of memory dumping zir>\n"),
|
||||||
else => |e| return e,
|
else => |e| return e,
|
||||||
};
|
};
|
||||||
try stderr_bw.print(
|
try stderr.print(
|
||||||
\\ For full context, use the command
|
\\ For full context, use the command
|
||||||
\\ zig ast-check -t {f}
|
\\ zig ast-check -t {f}
|
||||||
\\
|
\\
|
||||||
@ -117,30 +117,30 @@ fn dumpStatusReport() !void {
|
|||||||
while (parent) |curr| {
|
while (parent) |curr| {
|
||||||
fba.reset();
|
fba.reset();
|
||||||
const cur_block_file = zcu.fileByIndex(curr.block.src_base_inst.resolveFile(&zcu.intern_pool));
|
const cur_block_file = zcu.fileByIndex(curr.block.src_base_inst.resolveFile(&zcu.intern_pool));
|
||||||
try stderr_bw.print(" in {f}\n", .{cur_block_file.path.fmt(zcu.comp)});
|
try stderr.print(" in {f}\n", .{cur_block_file.path.fmt(zcu.comp)});
|
||||||
_, const cur_block_src_base_node = Zcu.LazySrcLoc.resolveBaseNode(curr.block.src_base_inst, zcu) orelse {
|
_, const cur_block_src_base_node = Zcu.LazySrcLoc.resolveBaseNode(curr.block.src_base_inst, zcu) orelse {
|
||||||
try stderr_bw.writeAll(" > [lost instruction; this should not happen]\n");
|
try stderr.writeAll(" > [lost instruction; this should not happen]\n");
|
||||||
parent = curr.parent;
|
parent = curr.parent;
|
||||||
continue;
|
continue;
|
||||||
};
|
};
|
||||||
try stderr_bw.writeAll(" > ");
|
try stderr.writeAll(" > ");
|
||||||
print_zir.renderSingleInstruction(
|
print_zir.renderSingleInstruction(
|
||||||
allocator,
|
allocator,
|
||||||
curr.body[curr.body_index],
|
curr.body[curr.body_index],
|
||||||
cur_block_file,
|
cur_block_file,
|
||||||
cur_block_src_base_node,
|
cur_block_src_base_node,
|
||||||
6, // indent
|
6, // indent
|
||||||
&stderr_bw,
|
stderr,
|
||||||
) catch |err| switch (err) {
|
) catch |err| switch (err) {
|
||||||
error.OutOfMemory => try stderr_bw.writeAll(" <out of memory dumping zir>\n"),
|
error.OutOfMemory => try stderr.writeAll(" <out of memory dumping zir>\n"),
|
||||||
else => |e| return e,
|
else => |e| return e,
|
||||||
};
|
};
|
||||||
try stderr_bw.writeAll("\n");
|
try stderr.writeAll("\n");
|
||||||
|
|
||||||
parent = curr.parent;
|
parent = curr.parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
try stderr_bw.writeByte('\n');
|
try stderr.writeByte('\n');
|
||||||
}
|
}
|
||||||
|
|
||||||
var crash_heap: [16 * 4096]u8 = undefined;
|
var crash_heap: [16 * 4096]u8 = undefined;
|
||||||
@ -269,9 +269,9 @@ const StackContext = union(enum) {
|
|||||||
debug.dumpCurrentStackTrace(ct.ret_addr);
|
debug.dumpCurrentStackTrace(ct.ret_addr);
|
||||||
},
|
},
|
||||||
.exception => |context| {
|
.exception => |context| {
|
||||||
var stderr_fw = std.fs.File.stderr().writer();
|
var stderr_fw = std.fs.File.stderr().writer(&.{});
|
||||||
var stderr_bw = stderr_fw.interface().unbuffered();
|
const stderr = &stderr_fw.interface;
|
||||||
debug.dumpStackTraceFromBase(context, &stderr_bw);
|
debug.dumpStackTraceFromBase(context, stderr);
|
||||||
},
|
},
|
||||||
.not_supported => {
|
.not_supported => {
|
||||||
std.fs.File.stderr().writeAll("Stack trace not supported on this platform.\n") catch {};
|
std.fs.File.stderr().writeAll("Stack trace not supported on this platform.\n") catch {};
|
||||||
@ -381,20 +381,20 @@ const PanicSwitch = struct {
|
|||||||
|
|
||||||
state.recover_stage = .release_mutex;
|
state.recover_stage = .release_mutex;
|
||||||
|
|
||||||
var stderr_fw = std.fs.File.stderr().writer();
|
var stderr_fw = std.fs.File.stderr().writer(&.{});
|
||||||
var stderr_bw = stderr_fw.interface().unbuffered();
|
const stderr = &stderr_fw.interface;
|
||||||
if (builtin.single_threaded) {
|
if (builtin.single_threaded) {
|
||||||
stderr_bw.print("panic: ", .{}) catch goTo(releaseMutex, .{state});
|
stderr.print("panic: ", .{}) catch goTo(releaseMutex, .{state});
|
||||||
} else {
|
} else {
|
||||||
const current_thread_id = std.Thread.getCurrentId();
|
const current_thread_id = std.Thread.getCurrentId();
|
||||||
stderr_bw.print("thread {} panic: ", .{current_thread_id}) catch goTo(releaseMutex, .{state});
|
stderr.print("thread {} panic: ", .{current_thread_id}) catch goTo(releaseMutex, .{state});
|
||||||
}
|
}
|
||||||
stderr_bw.print("{s}\n", .{msg}) catch goTo(releaseMutex, .{state});
|
stderr.print("{s}\n", .{msg}) catch goTo(releaseMutex, .{state});
|
||||||
|
|
||||||
state.recover_stage = .report_stack;
|
state.recover_stage = .report_stack;
|
||||||
|
|
||||||
dumpStatusReport() catch |err| {
|
dumpStatusReport() catch |err| {
|
||||||
stderr_bw.print("\nIntercepted error.{} while dumping current state. Continuing...\n", .{err}) catch {};
|
stderr.print("\nIntercepted error.{} while dumping current state. Continuing...\n", .{err}) catch {};
|
||||||
};
|
};
|
||||||
|
|
||||||
goTo(reportStack, .{state});
|
goTo(reportStack, .{state});
|
||||||
@ -409,9 +409,9 @@ const PanicSwitch = struct {
|
|||||||
recover(state, trace, stack, msg);
|
recover(state, trace, stack, msg);
|
||||||
|
|
||||||
state.recover_stage = .release_mutex;
|
state.recover_stage = .release_mutex;
|
||||||
var stderr_fw = std.fs.File.stderr().writer();
|
var stderr_fw = std.fs.File.stderr().writer(&.{});
|
||||||
var stderr_bw = stderr_fw.interface().unbuffered();
|
const stderr = &stderr_fw.interface;
|
||||||
stderr_bw.writeAll("\nOriginal Error:\n") catch {};
|
stderr.writeAll("\nOriginal Error:\n") catch {};
|
||||||
goTo(reportStack, .{state});
|
goTo(reportStack, .{state});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -481,9 +481,9 @@ const PanicSwitch = struct {
|
|||||||
recover(state, trace, stack, msg);
|
recover(state, trace, stack, msg);
|
||||||
|
|
||||||
state.recover_stage = .silent_abort;
|
state.recover_stage = .silent_abort;
|
||||||
var stderr_fw = std.fs.File.stderr().writer();
|
var stderr_fw = std.fs.File.stderr().writer(&.{});
|
||||||
var stderr_bw = stderr_fw.interface().unbuffered();
|
const stderr = &stderr_fw.interface;
|
||||||
stderr_bw.writeAll("Aborting...\n") catch {};
|
stderr.writeAll("Aborting...\n") catch {};
|
||||||
goTo(abort, .{});
|
goTo(abort, .{});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -510,11 +510,11 @@ const PanicSwitch = struct {
|
|||||||
// lower the verbosity, and restore it at the end if we don't panic.
|
// lower the verbosity, and restore it at the end if we don't panic.
|
||||||
state.recover_verbosity = .message_only;
|
state.recover_verbosity = .message_only;
|
||||||
|
|
||||||
var stderr_fw = std.fs.File.stderr().writer();
|
var stderr_fw = std.fs.File.stderr().writer(&.{});
|
||||||
var stderr_bw = stderr_fw.interface().unbuffered();
|
const stderr = &stderr_fw.interface;
|
||||||
stderr_bw.writeAll("\nPanicked during a panic: ") catch {};
|
stderr.writeAll("\nPanicked during a panic: ") catch {};
|
||||||
stderr_bw.writeAll(msg) catch {};
|
stderr.writeAll(msg) catch {};
|
||||||
stderr_bw.writeAll("\nInner panic stack:\n") catch {};
|
stderr.writeAll("\nInner panic stack:\n") catch {};
|
||||||
if (trace) |t| {
|
if (trace) |t| {
|
||||||
debug.dumpStackTrace(t.*);
|
debug.dumpStackTrace(t.*);
|
||||||
}
|
}
|
||||||
@ -525,11 +525,11 @@ const PanicSwitch = struct {
|
|||||||
.message_only => {
|
.message_only => {
|
||||||
state.recover_verbosity = .silent;
|
state.recover_verbosity = .silent;
|
||||||
|
|
||||||
var stderr_fw = std.fs.File.stderr().writer();
|
var stderr_fw = std.fs.File.stderr().writer(&.{});
|
||||||
var stderr_bw = stderr_fw.interface().unbuffered();
|
const stderr = &stderr_fw.interface;
|
||||||
stderr_bw.writeAll("\nPanicked while dumping inner panic stack: ") catch {};
|
stderr.writeAll("\nPanicked while dumping inner panic stack: ") catch {};
|
||||||
stderr_bw.writeAll(msg) catch {};
|
stderr.writeAll(msg) catch {};
|
||||||
stderr_bw.writeByte('\n') catch {};
|
stderr.writeByte('\n') catch {};
|
||||||
|
|
||||||
// If we succeed, restore all the way to dumping the stack.
|
// If we succeed, restore all the way to dumping the stack.
|
||||||
state.recover_verbosity = .message_and_stack;
|
state.recover_verbosity = .message_and_stack;
|
||||||
|
|||||||
@ -206,7 +206,7 @@ pub fn flush(
|
|||||||
var error_info: std.io.Writer.Allocating = .init(self.object.gpa);
|
var error_info: std.io.Writer.Allocating = .init(self.object.gpa);
|
||||||
defer error_info.deinit();
|
defer error_info.deinit();
|
||||||
|
|
||||||
try error_info.interface.writeAll("zig_errors:");
|
try error_info.writer.writeAll("zig_errors:");
|
||||||
const ip = &self.base.comp.zcu.?.intern_pool;
|
const ip = &self.base.comp.zcu.?.intern_pool;
|
||||||
for (ip.global_error_set.getNamesFromMainThread()) |name| {
|
for (ip.global_error_set.getNamesFromMainThread()) |name| {
|
||||||
// Errors can contain pretty much any character - to encode them in a string we must escape
|
// Errors can contain pretty much any character - to encode them in a string we must escape
|
||||||
@ -214,9 +214,9 @@ pub fn flush(
|
|||||||
// name if it contains no strange characters is nice for debugging. URI encoding fits the bill.
|
// name if it contains no strange characters is nice for debugging. URI encoding fits the bill.
|
||||||
// We're using : as separator, which is a reserved character.
|
// We're using : as separator, which is a reserved character.
|
||||||
|
|
||||||
try error_info.interface.writeByte(':');
|
try error_info.writer.writeByte(':');
|
||||||
try std.Uri.Component.percentEncode(
|
try std.Uri.Component.percentEncode(
|
||||||
&error_info.interface,
|
&error_info.writer,
|
||||||
name.toSlice(ip),
|
name.toSlice(ip),
|
||||||
struct {
|
struct {
|
||||||
fn isValidChar(c: u8) bool {
|
fn isValidChar(c: u8) bool {
|
||||||
|
|||||||
@ -42,7 +42,7 @@ pub fn renderAsText(gpa: Allocator, tree: ?Ast, zir: Zir, bw: *std.io.Writer) !v
|
|||||||
|
|
||||||
const import_path = zir.nullTerminatedString(item.data.name);
|
const import_path = zir.nullTerminatedString(item.data.name);
|
||||||
try bw.print(" @import(\"{f}\") ", .{
|
try bw.print(" @import(\"{f}\") ", .{
|
||||||
std.zig.fmtEscapes(import_path),
|
std.zig.fmtString(import_path),
|
||||||
});
|
});
|
||||||
try writer.writeSrcTokAbs(bw, item.data.token);
|
try writer.writeSrcTokAbs(bw, item.data.token);
|
||||||
try bw.writeAll("\n");
|
try bw.writeAll("\n");
|
||||||
@ -785,7 +785,7 @@ const Writer = struct {
|
|||||||
) Error!void {
|
) Error!void {
|
||||||
const inst_data = self.code.instructions.items(.data)[@intFromEnum(inst)].str;
|
const inst_data = self.code.instructions.items(.data)[@intFromEnum(inst)].str;
|
||||||
const str = inst_data.get(self.code);
|
const str = inst_data.get(self.code);
|
||||||
try stream.print("\"{f}\")", .{std.zig.fmtEscapes(str)});
|
try stream.print("\"{f}\")", .{std.zig.fmtString(str)});
|
||||||
}
|
}
|
||||||
|
|
||||||
fn writeSliceStart(self: *Writer, stream: *std.io.Writer, inst: Zir.Inst.Index) !void {
|
fn writeSliceStart(self: *Writer, stream: *std.io.Writer, inst: Zir.Inst.Index) !void {
|
||||||
@ -942,7 +942,7 @@ const Writer = struct {
|
|||||||
const extra = self.code.extraData(Zir.Inst.Param, inst_data.payload_index);
|
const extra = self.code.extraData(Zir.Inst.Param, inst_data.payload_index);
|
||||||
const body = self.code.bodySlice(extra.end, extra.data.type.body_len);
|
const body = self.code.bodySlice(extra.end, extra.data.type.body_len);
|
||||||
try stream.print("\"{f}\", ", .{
|
try stream.print("\"{f}\", ", .{
|
||||||
std.zig.fmtEscapes(self.code.nullTerminatedString(extra.data.name)),
|
std.zig.fmtString(self.code.nullTerminatedString(extra.data.name)),
|
||||||
});
|
});
|
||||||
|
|
||||||
if (extra.data.type.is_generic) try stream.writeAll("[generic] ");
|
if (extra.data.type.is_generic) try stream.writeAll("[generic] ");
|
||||||
@ -1212,7 +1212,7 @@ const Writer = struct {
|
|||||||
try stream.writeAll(", ");
|
try stream.writeAll(", ");
|
||||||
} else {
|
} else {
|
||||||
const asm_source = self.code.nullTerminatedString(extra.data.asm_source);
|
const asm_source = self.code.nullTerminatedString(extra.data.asm_source);
|
||||||
try stream.print("\"{f}\", ", .{std.zig.fmtEscapes(asm_source)});
|
try stream.print("\"{f}\", ", .{std.zig.fmtString(asm_source)});
|
||||||
}
|
}
|
||||||
try stream.writeAll(", ");
|
try stream.writeAll(", ");
|
||||||
|
|
||||||
@ -1230,7 +1230,7 @@ const Writer = struct {
|
|||||||
const name = self.code.nullTerminatedString(output.data.name);
|
const name = self.code.nullTerminatedString(output.data.name);
|
||||||
const constraint = self.code.nullTerminatedString(output.data.constraint);
|
const constraint = self.code.nullTerminatedString(output.data.constraint);
|
||||||
try stream.print("output({fp}, \"{f}\", ", .{
|
try stream.print("output({fp}, \"{f}\", ", .{
|
||||||
std.zig.fmtId(name), std.zig.fmtEscapes(constraint),
|
std.zig.fmtId(name), std.zig.fmtString(constraint),
|
||||||
});
|
});
|
||||||
try self.writeFlag(stream, "->", is_type);
|
try self.writeFlag(stream, "->", is_type);
|
||||||
try self.writeInstRef(stream, output.data.operand);
|
try self.writeInstRef(stream, output.data.operand);
|
||||||
@ -1249,7 +1249,7 @@ const Writer = struct {
|
|||||||
const name = self.code.nullTerminatedString(input.data.name);
|
const name = self.code.nullTerminatedString(input.data.name);
|
||||||
const constraint = self.code.nullTerminatedString(input.data.constraint);
|
const constraint = self.code.nullTerminatedString(input.data.constraint);
|
||||||
try stream.print("input({fp}, \"{f}\", ", .{
|
try stream.print("input({fp}, \"{f}\", ", .{
|
||||||
std.zig.fmtId(name), std.zig.fmtEscapes(constraint),
|
std.zig.fmtId(name), std.zig.fmtString(constraint),
|
||||||
});
|
});
|
||||||
try self.writeInstRef(stream, input.data.operand);
|
try self.writeInstRef(stream, input.data.operand);
|
||||||
try stream.writeAll(")");
|
try stream.writeAll(")");
|
||||||
@ -1308,7 +1308,7 @@ const Writer = struct {
|
|||||||
.field => {
|
.field => {
|
||||||
const field_name = self.code.nullTerminatedString(extra.data.field_name_start);
|
const field_name = self.code.nullTerminatedString(extra.data.field_name_start);
|
||||||
try self.writeInstRef(stream, extra.data.obj_ptr);
|
try self.writeInstRef(stream, extra.data.obj_ptr);
|
||||||
try stream.print(", \"{f}\"", .{std.zig.fmtEscapes(field_name)});
|
try stream.print(", \"{f}\"", .{std.zig.fmtString(field_name)});
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
try stream.writeAll(", [");
|
try stream.writeAll(", [");
|
||||||
@ -2212,7 +2212,7 @@ const Writer = struct {
|
|||||||
const extra = self.code.extraData(Zir.Inst.Field, inst_data.payload_index).data;
|
const extra = self.code.extraData(Zir.Inst.Field, inst_data.payload_index).data;
|
||||||
const name = self.code.nullTerminatedString(extra.field_name_start);
|
const name = self.code.nullTerminatedString(extra.field_name_start);
|
||||||
try self.writeInstRef(stream, extra.lhs);
|
try self.writeInstRef(stream, extra.lhs);
|
||||||
try stream.print(", \"{f}\") ", .{std.zig.fmtEscapes(name)});
|
try stream.print(", \"{f}\") ", .{std.zig.fmtString(name)});
|
||||||
try self.writeSrcNode(stream, inst_data.src_node);
|
try self.writeSrcNode(stream, inst_data.src_node);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2253,7 +2253,7 @@ const Writer = struct {
|
|||||||
) Error!void {
|
) Error!void {
|
||||||
const inst_data = self.code.instructions.items(.data)[@intFromEnum(inst)].str_tok;
|
const inst_data = self.code.instructions.items(.data)[@intFromEnum(inst)].str_tok;
|
||||||
const str = inst_data.get(self.code);
|
const str = inst_data.get(self.code);
|
||||||
try stream.print("\"{f}\") ", .{std.zig.fmtEscapes(str)});
|
try stream.print("\"{f}\") ", .{std.zig.fmtString(str)});
|
||||||
try self.writeSrcTok(stream, inst_data.src_tok);
|
try self.writeSrcTok(stream, inst_data.src_tok);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2261,7 +2261,7 @@ const Writer = struct {
|
|||||||
const inst_data = self.code.instructions.items(.data)[@intFromEnum(inst)].str_op;
|
const inst_data = self.code.instructions.items(.data)[@intFromEnum(inst)].str_op;
|
||||||
const str = inst_data.getStr(self.code);
|
const str = inst_data.getStr(self.code);
|
||||||
try self.writeInstRef(stream, inst_data.operand);
|
try self.writeInstRef(stream, inst_data.operand);
|
||||||
try stream.print(", \"{f}\")", .{std.zig.fmtEscapes(str)});
|
try stream.print(", \"{f}\")", .{std.zig.fmtString(str)});
|
||||||
}
|
}
|
||||||
|
|
||||||
fn writeFunc(
|
fn writeFunc(
|
||||||
@ -2703,10 +2703,10 @@ const Writer = struct {
|
|||||||
try self.writeInstIndex(stream, ptr_inst);
|
try self.writeInstIndex(stream, ptr_inst);
|
||||||
},
|
},
|
||||||
.decl_val => |str| try stream.print("decl_val \"{f}\"", .{
|
.decl_val => |str| try stream.print("decl_val \"{f}\"", .{
|
||||||
std.zig.fmtEscapes(self.code.nullTerminatedString(str)),
|
std.zig.fmtString(self.code.nullTerminatedString(str)),
|
||||||
}),
|
}),
|
||||||
.decl_ref => |str| try stream.print("decl_ref \"{f}\"", .{
|
.decl_ref => |str| try stream.print("decl_ref \"{f}\"", .{
|
||||||
std.zig.fmtEscapes(self.code.nullTerminatedString(str)),
|
std.zig.fmtString(self.code.nullTerminatedString(str)),
|
||||||
}),
|
}),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2839,7 +2839,7 @@ const Writer = struct {
|
|||||||
const extra = self.code.extraData(Zir.Inst.Import, inst_data.payload_index).data;
|
const extra = self.code.extraData(Zir.Inst.Import, inst_data.payload_index).data;
|
||||||
try self.writeInstRef(stream, extra.res_ty);
|
try self.writeInstRef(stream, extra.res_ty);
|
||||||
const import_path = self.code.nullTerminatedString(extra.path);
|
const import_path = self.code.nullTerminatedString(extra.path);
|
||||||
try stream.print(", \"{f}\") ", .{std.zig.fmtEscapes(import_path)});
|
try stream.print(", \"{f}\") ", .{std.zig.fmtString(import_path)});
|
||||||
try self.writeSrcTok(stream, inst_data.src_tok);
|
try self.writeSrcTok(stream, inst_data.src_tok);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@ -72,8 +72,8 @@ const PrintZon = struct {
|
|||||||
},
|
},
|
||||||
.float_literal => |x| try pz.w.print("float({d})", .{x}),
|
.float_literal => |x| try pz.w.print("float({d})", .{x}),
|
||||||
.char_literal => |x| try pz.w.print("char({d})", .{x}),
|
.char_literal => |x| try pz.w.print("char({d})", .{x}),
|
||||||
.enum_literal => |x| try pz.w.print("enum_literal({fp})", .{std.zig.fmtId(x.get(zoir))}),
|
.enum_literal => |x| try pz.w.print("enum_literal({f})", .{std.zig.fmtIdP(x.get(zoir))}),
|
||||||
.string_literal => |x| try pz.w.print("str(\"{f}\")", .{std.zig.fmtEscapes(x)}),
|
.string_literal => |x| try pz.w.print("str(\"{f}\")", .{std.zig.fmtString(x)}),
|
||||||
.empty_literal => try pz.w.writeAll("empty_literal(.{})"),
|
.empty_literal => try pz.w.writeAll("empty_literal(.{})"),
|
||||||
.array_literal => |vals| {
|
.array_literal => |vals| {
|
||||||
try pz.w.writeAll("array_literal({");
|
try pz.w.writeAll("array_literal({");
|
||||||
@ -92,7 +92,7 @@ const PrintZon = struct {
|
|||||||
pz.indent += 1;
|
pz.indent += 1;
|
||||||
for (s.names, 0..s.vals.len) |name, idx| {
|
for (s.names, 0..s.vals.len) |name, idx| {
|
||||||
try pz.newline();
|
try pz.newline();
|
||||||
try pz.w.print("[{fp}] ", .{std.zig.fmtId(name.get(zoir))});
|
try pz.w.print("[{f}] ", .{std.zig.fmtIdP(name.get(zoir))});
|
||||||
try pz.renderNode(s.vals.at(@intCast(idx)));
|
try pz.renderNode(s.vals.at(@intCast(idx)));
|
||||||
try pz.w.writeByte(',');
|
try pz.w.writeByte(',');
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user