From 686663239af6afd8dea814a9fe6a8885f06d6cb3 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Wed, 29 Aug 2018 19:00:24 -0400 Subject: printing info from the ModuleInfo substream of DebugInfo --- std/io.zig | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'std/io.zig') diff --git a/std/io.zig b/std/io.zig index 369f6eede3..2de52493b1 100644 --- a/std/io.zig +++ b/std/io.zig @@ -34,13 +34,13 @@ pub fn getStdIn() GetStdIoErrs!File { /// Implementation of InStream trait for File pub const FileInStream = struct { - file: *File, + file: File, stream: Stream, pub const Error = @typeOf(File.read).ReturnType.ErrorSet; pub const Stream = InStream(Error); - pub fn init(file: *File) FileInStream { + pub fn init(file: File) FileInStream { return FileInStream{ .file = file, .stream = Stream{ .readFn = readFn }, @@ -55,13 +55,13 @@ pub const FileInStream = struct { /// Implementation of OutStream trait for File pub const FileOutStream = struct { - file: *File, + file: File, stream: Stream, pub const Error = File.WriteError; pub const Stream = OutStream(Error); - pub fn init(file: *File) FileOutStream { + pub fn init(file: File) FileOutStream { return FileOutStream{ .file = file, .stream = Stream{ .writeFn = writeFn }, -- cgit v1.2.3 From 99170aa13db236b47aa8fda4a3d94b49e6b7f93c Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Fri, 31 Aug 2018 01:01:37 -0400 Subject: finding source file, line, and column info --- std/io.zig | 2 +- std/pdb.zig | 122 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 118 insertions(+), 6 deletions(-) (limited to 'std/io.zig') diff --git a/std/io.zig b/std/io.zig index 2de52493b1..a1a77271e1 100644 --- a/std/io.zig +++ b/std/io.zig @@ -210,7 +210,7 @@ pub fn InStream(comptime ReadError: type) type { pub fn readStruct(self: *Self, comptime T: type, ptr: *T) !void { // Only extern and packed structs have defined in-memory layout. - assert(@typeInfo(T).Struct.layout != builtin.TypeInfo.ContainerLayout.Auto); + comptime assert(@typeInfo(T).Struct.layout != builtin.TypeInfo.ContainerLayout.Auto); return self.readNoEof(@sliceToBytes((*[1]T)(ptr)[0..])); } }; diff --git a/std/pdb.zig b/std/pdb.zig index e67ca7cf0c..c1fb863b67 100644 --- a/std/pdb.zig +++ b/std/pdb.zig @@ -365,7 +365,8 @@ const ProcSym = packed struct { CodeOffset: u32, Segment: u16, Flags: ProcSymFlags, - Name: u8, + // following is a null terminated string + // Name: [*]u8, }; const ProcSymFlags = packed struct { @@ -389,6 +390,51 @@ const RecordPrefix = packed struct { RecordKind: SymbolKind, /// Record kind enum (SymRecordKind or TypeRecordKind) }; +const LineFragmentHeader = packed struct { + RelocOffset: u32, /// Code offset of line contribution. + RelocSegment: u16, /// Code segment of line contribution. + Flags: LineFlags, + CodeSize: u32, /// Code size of this line contribution. +}; + +const LineFlags = packed struct { + LF_HaveColumns: bool, /// CV_LINES_HAVE_COLUMNS + unused: u15, +}; + +/// The following two variable length arrays appear immediately after the +/// header. The structure definitions follow. +/// LineNumberEntry Lines[NumLines]; +/// ColumnNumberEntry Columns[NumLines]; +const LineBlockFragmentHeader = packed struct { + /// Offset of FileChecksum entry in File + /// checksums buffer. The checksum entry then + /// contains another offset into the string + /// table of the actual name. + NameIndex: u32, + NumLines: u32, + BlockSize: u32, /// code size of block, in bytes +}; + + +const LineNumberEntry = packed struct { + Offset: u32, /// Offset to start of code bytes for line number + Flags: u32, + + /// TODO runtime crash when I make the actual type of Flags this + const Flags = packed struct { + Start: u24, + End: u7, + IsStatement: bool, + }; +}; + +const ColumnNumberEntry = packed struct { + StartColumn: u16, + EndColumn: u16, +}; + + pub const Pdb = struct { in_file: os.File, allocator: *mem.Allocator, @@ -537,16 +583,82 @@ pub const Pdb = struct { return error.InvalidDebugInfo; } else return error.MissingDebugInfo; - std.debug.warn("found in {s}: {}\n", ([*]u8)((*[1]u8)(&proc_sym.Name)), proc_sym); + std.debug.warn("found in {s}: {}\n", @ptrCast([*]u8, proc_sym) + @sizeOf(ProcSym), proc_sym); if (mod.mod_info.C11ByteSize != 0) return error.InvalidDebugInfo; - if (mod.mod_info.C13ByteSize != 0) { - std.debug.warn("read C13 line info\n"); + if (mod.mod_info.C13ByteSize == 0) { + return error.MissingDebugInfo; + } + + const line_info = try self.allocator.alloc(u8, mod.mod_info.C13ByteSize); + std.debug.warn("read C13 line info {} bytes\n", line_info.len); + try modi.stream.readNoEof(line_info); + + var line_index: usize = 0; + while (line_index != line_info.len) { + std.debug.warn("unknown bytes: {x2} {x2} {x2} {x2} {x2} {x2} {x2} {x2}\n", + line_info[line_index+0], + line_info[line_index+1], + line_info[line_index+2], + line_info[line_index+3], + line_info[line_index+4], + line_info[line_index+5], + line_info[line_index+6], + line_info[line_index+7], + ); + line_index += 8; + + const line_hdr = @ptrCast(*LineFragmentHeader, &line_info[line_index]); + if (line_hdr.RelocSegment == 0) return error.MissingDebugInfo; + std.debug.warn("{}\n", line_hdr); + line_index += @sizeOf(LineFragmentHeader); + + const block_hdr = @ptrCast(*LineBlockFragmentHeader, &line_info[line_index]); + std.debug.warn("{}\n", block_hdr); + line_index += @sizeOf(LineBlockFragmentHeader); + + const has_column = line_hdr.Flags.LF_HaveColumns; + std.debug.warn("has column: {}\n", has_column); + + const frag_vaddr_start = coff_section.header.virtual_address + line_hdr.RelocOffset; + const frag_vaddr_end = frag_vaddr_start + line_hdr.CodeSize; + if (address >= frag_vaddr_start and address < frag_vaddr_end) { + std.debug.warn("found line listing\n"); + var line_i: usize = 0; + const start_line_index = line_index; + while (line_i < block_hdr.NumLines) : (line_i += 1) { + const line_num_entry = @ptrCast(*LineNumberEntry, &line_info[line_index]); + line_index += @sizeOf(LineNumberEntry); + const flags = @ptrCast(*LineNumberEntry.Flags, &line_num_entry.Flags); + std.debug.warn("{} {}\n", line_num_entry, flags); + const vaddr_start = frag_vaddr_start + line_num_entry.Offset; + const vaddr_end = if (flags.End == 0) frag_vaddr_end else vaddr_start + flags.End; + std.debug.warn("test {x} <= {x} < {x}\n", vaddr_start, address, vaddr_end); + if (address >= vaddr_start and address < vaddr_end) { + std.debug.warn("{} line {}\n", block_hdr.NameIndex, flags.Start); + if (has_column) { + line_index = start_line_index + @sizeOf(LineNumberEntry) * block_hdr.NumLines; + line_index += @sizeOf(ColumnNumberEntry) * line_i; + const col_num_entry = @ptrCast(*ColumnNumberEntry, &line_info[line_index]); + std.debug.warn("col {}\n", col_num_entry.StartColumn); + } + return; + } + } + return error.MissingDebugInfo; + } else { + line_index += @sizeOf(LineNumberEntry) * block_hdr.NumLines; + if (has_column) + line_index += @sizeOf(ColumnNumberEntry) * block_hdr.NumLines; + } + + if (line_index > mod.mod_info.C13ByteSize) + return error.InvalidDebugInfo; } - // TODO: locate corresponding source line information + std.debug.warn("end line info\n"); } }; -- cgit v1.2.3 From 832caefc2a1b20deb513d43306d6723670ba9c8f Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Sun, 2 Sep 2018 18:35:32 -0400 Subject: fix regressions --- doc/docgen.zig | 4 ++-- example/guess_number/main.zig | 2 +- src-self-hosted/errmsg.zig | 2 +- src-self-hosted/main.zig | 12 ++++++------ src-self-hosted/test.zig | 4 ++-- std/debug/index.zig | 14 +++++++------- std/elf.zig | 4 ++-- std/event/tcp.zig | 6 +++--- std/io.zig | 6 +++--- std/io_test.zig | 4 ++-- std/os/child_process.zig | 4 ++-- std/os/index.zig | 1 + std/special/build_runner.zig | 4 ++-- std/zig/parser_test.zig | 2 +- test/compare_output.zig | 30 +++++++++++++++--------------- test/tests.zig | 12 ++++++------ 16 files changed, 56 insertions(+), 55 deletions(-) (limited to 'std/io.zig') diff --git a/doc/docgen.zig b/doc/docgen.zig index 3145c4483e..c1158dc03f 100644 --- a/doc/docgen.zig +++ b/doc/docgen.zig @@ -40,11 +40,11 @@ pub fn main() !void { var out_file = try os.File.openWrite(out_file_name); defer out_file.close(); - var file_in_stream = io.FileInStream.init(&in_file); + var file_in_stream = io.FileInStream.init(in_file); const input_file_bytes = try file_in_stream.stream.readAllAlloc(allocator, max_doc_file_size); - var file_out_stream = io.FileOutStream.init(&out_file); + var file_out_stream = io.FileOutStream.init(out_file); var buffered_out_stream = io.BufferedOutStream(io.FileOutStream.Error).init(&file_out_stream.stream); var tokenizer = Tokenizer.init(in_file_name, input_file_bytes); diff --git a/example/guess_number/main.zig b/example/guess_number/main.zig index bed132b25c..062f93e7f7 100644 --- a/example/guess_number/main.zig +++ b/example/guess_number/main.zig @@ -6,7 +6,7 @@ const os = std.os; pub fn main() !void { var stdout_file = try io.getStdOut(); - var stdout_file_stream = io.FileOutStream.init(&stdout_file); + var stdout_file_stream = io.FileOutStream.init(stdout_file); const stdout = &stdout_file_stream.stream; try stdout.print("Welcome to the Guess Number Game in Zig.\n"); diff --git a/src-self-hosted/errmsg.zig b/src-self-hosted/errmsg.zig index 028c2e2174..6cf29b9441 100644 --- a/src-self-hosted/errmsg.zig +++ b/src-self-hosted/errmsg.zig @@ -272,7 +272,7 @@ pub const Msg = struct { try stream.write("\n"); } - pub fn printToFile(msg: *const Msg, file: *os.File, color: Color) !void { + pub fn printToFile(msg: *const Msg, file: os.File, color: Color) !void { const color_on = switch (color) { Color.Auto => file.isTty(), Color.On => true, diff --git a/src-self-hosted/main.zig b/src-self-hosted/main.zig index 64c55a24e8..6a450030ca 100644 --- a/src-self-hosted/main.zig +++ b/src-self-hosted/main.zig @@ -55,11 +55,11 @@ pub fn main() !void { const allocator = std.heap.c_allocator; var stdout_file = try std.io.getStdOut(); - var stdout_out_stream = std.io.FileOutStream.init(&stdout_file); + var stdout_out_stream = std.io.FileOutStream.init(stdout_file); stdout = &stdout_out_stream.stream; stderr_file = try std.io.getStdErr(); - var stderr_out_stream = std.io.FileOutStream.init(&stderr_file); + var stderr_out_stream = std.io.FileOutStream.init(stderr_file); stderr = &stderr_out_stream.stream; const args = try os.argsAlloc(allocator); @@ -491,7 +491,7 @@ async fn processBuildEvents(comp: *Compilation, color: errmsg.Color) void { stderr.print("Build {} compile errors:\n", count) catch os.exit(1); for (msgs) |msg| { defer msg.destroy(); - msg.printToFile(&stderr_file, color) catch os.exit(1); + msg.printToFile(stderr_file, color) catch os.exit(1); } }, } @@ -619,7 +619,7 @@ fn cmdFmt(allocator: *Allocator, args: []const []const u8) !void { } var stdin_file = try io.getStdIn(); - var stdin = io.FileInStream.init(&stdin_file); + var stdin = io.FileInStream.init(stdin_file); const source_code = try stdin.stream.readAllAlloc(allocator, max_src_size); defer allocator.free(source_code); @@ -635,7 +635,7 @@ fn cmdFmt(allocator: *Allocator, args: []const []const u8) !void { const msg = try errmsg.Msg.createFromParseError(allocator, parse_error, &tree, ""); defer msg.destroy(); - try msg.printToFile(&stderr_file, color); + try msg.printToFile(stderr_file, color); } if (tree.errors.len != 0) { os.exit(1); @@ -772,7 +772,7 @@ async fn fmtPath(fmt: *Fmt, file_path_ref: []const u8) FmtError!void { const msg = try errmsg.Msg.createFromParseError(fmt.loop.allocator, parse_error, &tree, file_path); defer fmt.loop.allocator.destroy(msg); - try msg.printToFile(&stderr_file, fmt.color); + try msg.printToFile(stderr_file, fmt.color); } if (tree.errors.len != 0) { fmt.any_error = true; diff --git a/src-self-hosted/test.zig b/src-self-hosted/test.zig index d4a45e7a04..4f377d4247 100644 --- a/src-self-hosted/test.zig +++ b/src-self-hosted/test.zig @@ -185,7 +185,7 @@ pub const TestContext = struct { try stderr.write("build incorrectly failed:\n"); for (msgs) |msg| { defer msg.destroy(); - try msg.printToFile(&stderr, errmsg.Color.Auto); + try msg.printToFile(stderr, errmsg.Color.Auto); } }, } @@ -234,7 +234,7 @@ pub const TestContext = struct { var stderr = try std.io.getStdErr(); for (msgs) |msg| { defer msg.destroy(); - try msg.printToFile(&stderr, errmsg.Color.Auto); + try msg.printToFile(stderr, errmsg.Color.Auto); } std.debug.warn("============\n"); return error.TestFailed; diff --git a/std/debug/index.zig b/std/debug/index.zig index 2930819b3a..8db7c75d2c 100644 --- a/std/debug/index.zig +++ b/std/debug/index.zig @@ -862,7 +862,7 @@ fn openSelfDebugInfoLinux(allocator: *mem.Allocator) !DebugInfo { di.self_exe_file = try os.openSelfExe(); errdefer di.self_exe_file.close(); - try di.elf.openFile(allocator, &di.self_exe_file); + try di.elf.openFile(allocator, di.self_exe_file); errdefer di.elf.close(); di.debug_info = (try di.elf.findSection(".debug_info")) orelse return error.MissingDebugInfo; @@ -1067,7 +1067,7 @@ pub const DebugInfo = switch (builtin.os) { } pub fn readString(self: *DebugInfo) ![]u8 { - var in_file_stream = io.FileInStream.init(&self.self_exe_file); + var in_file_stream = io.FileInStream.init(self.self_exe_file); const in_stream = &in_file_stream.stream; return readStringRaw(self.allocator(), in_stream); } @@ -1403,7 +1403,7 @@ fn parseFormValue(allocator: *mem.Allocator, in_stream: var, form_id: u64, is_64 } fn parseAbbrevTable(st: *DebugInfo) !AbbrevTable { - const in_file = &st.self_exe_file; + const in_file = st.self_exe_file; var in_file_stream = io.FileInStream.init(in_file); const in_stream = &in_file_stream.stream; var result = AbbrevTable.init(st.allocator()); @@ -1454,7 +1454,7 @@ fn getAbbrevTableEntry(abbrev_table: *const AbbrevTable, abbrev_code: u64) ?*con } fn parseDie(st: *DebugInfo, abbrev_table: *const AbbrevTable, is_64: bool) !Die { - const in_file = &st.self_exe_file; + const in_file = st.self_exe_file; var in_file_stream = io.FileInStream.init(in_file); const in_stream = &in_file_stream.stream; const abbrev_code = try readULeb128(in_stream); @@ -1676,7 +1676,7 @@ fn getLineNumberInfoMacOs(di: *DebugInfo, symbol: MachoSymbol, target_address: u fn getLineNumberInfoLinux(di: *DebugInfo, compile_unit: *const CompileUnit, target_address: usize) !LineInfo { const compile_unit_cwd = try compile_unit.die.getAttrString(di, DW.AT_comp_dir); - const in_file = &di.self_exe_file; + const in_file = di.self_exe_file; const debug_line_end = di.debug_line.offset + di.debug_line.size; var this_offset = di.debug_line.offset; var this_index: usize = 0; @@ -1856,7 +1856,7 @@ fn scanAllCompileUnits(st: *DebugInfo) !void { var this_unit_offset = st.debug_info.offset; var cu_index: usize = 0; - var in_file_stream = io.FileInStream.init(&st.self_exe_file); + var in_file_stream = io.FileInStream.init(st.self_exe_file); const in_stream = &in_file_stream.stream; while (this_unit_offset < debug_info_end) { @@ -1922,7 +1922,7 @@ fn scanAllCompileUnits(st: *DebugInfo) !void { } fn findCompileUnit(st: *DebugInfo, target_address: u64) !*const CompileUnit { - var in_file_stream = io.FileInStream.init(&st.self_exe_file); + var in_file_stream = io.FileInStream.init(st.self_exe_file); const in_stream = &in_file_stream.stream; for (st.compile_unit_list.toSlice()) |*compile_unit| { if (compile_unit.pc_range) |range| { diff --git a/std/elf.zig b/std/elf.zig index 3d81555319..a3a72dc728 100644 --- a/std/elf.zig +++ b/std/elf.zig @@ -353,7 +353,7 @@ pub const SectionHeader = struct { }; pub const Elf = struct { - in_file: *os.File, + in_file: os.File, auto_close_stream: bool, is_64: bool, endian: builtin.Endian, @@ -376,7 +376,7 @@ pub const Elf = struct { } /// Call close when done. - pub fn openFile(elf: *Elf, allocator: *mem.Allocator, file: *os.File) !void { + pub fn openFile(elf: *Elf, allocator: *mem.Allocator, file: os.File) !void { elf.allocator = allocator; elf.in_file = file; elf.auto_close_stream = false; diff --git a/std/event/tcp.zig b/std/event/tcp.zig index d8b97659a9..491acab39d 100644 --- a/std/event/tcp.zig +++ b/std/event/tcp.zig @@ -145,11 +145,11 @@ test "listen on a port, send bytes, receive bytes" { cancel @handle(); } } - async fn errorableHandler(self: *Self, _addr: *const std.net.Address, _socket: *const std.os.File) !void { + async fn errorableHandler(self: *Self, _addr: *const std.net.Address, _socket: std.os.File) !void { const addr = _addr.*; // TODO https://github.com/ziglang/zig/issues/733 - var socket = _socket.*; // TODO https://github.com/ziglang/zig/issues/733 + var socket = _socket; // TODO https://github.com/ziglang/zig/issues/733 - var adapter = std.io.FileOutStream.init(&socket); + var adapter = std.io.FileOutStream.init(socket); var stream = &adapter.stream; try stream.print("hello from server\n"); } diff --git a/std/io.zig b/std/io.zig index a1a77271e1..2b31bc0548 100644 --- a/std/io.zig +++ b/std/io.zig @@ -280,7 +280,7 @@ pub fn readFileAllocAligned(allocator: *mem.Allocator, path: []const u8, comptim const buf = try allocator.alignedAlloc(u8, A, size); errdefer allocator.free(buf); - var adapter = FileInStream.init(&file); + var adapter = FileInStream.init(file); try adapter.stream.readNoEof(buf[0..size]); return buf; } @@ -592,7 +592,7 @@ pub const BufferedAtomicFile = struct { self.atomic_file = try os.AtomicFile.init(allocator, dest_path, os.File.default_mode); errdefer self.atomic_file.deinit(); - self.file_stream = FileOutStream.init(&self.atomic_file.file); + self.file_stream = FileOutStream.init(self.atomic_file.file); self.buffered_stream = BufferedOutStream(FileOutStream.Error).init(&self.file_stream.stream); return self; } @@ -622,7 +622,7 @@ test "import io tests" { pub fn readLine(buf: []u8) !usize { var stdin = getStdIn() catch return error.StdInUnavailable; - var adapter = FileInStream.init(&stdin); + var adapter = FileInStream.init(stdin); var stream = &adapter.stream; var index: usize = 0; while (true) { diff --git a/std/io_test.zig b/std/io_test.zig index 7a44032673..7403c96994 100644 --- a/std/io_test.zig +++ b/std/io_test.zig @@ -19,7 +19,7 @@ test "write a file, read it, then delete it" { var file = try os.File.openWrite(tmp_file_name); defer file.close(); - var file_out_stream = io.FileOutStream.init(&file); + var file_out_stream = io.FileOutStream.init(file); var buf_stream = io.BufferedOutStream(io.FileOutStream.Error).init(&file_out_stream.stream); const st = &buf_stream.stream; try st.print("begin"); @@ -35,7 +35,7 @@ test "write a file, read it, then delete it" { const expected_file_size = "begin".len + data.len + "end".len; assert(file_size == expected_file_size); - var file_in_stream = io.FileInStream.init(&file); + var file_in_stream = io.FileInStream.init(file); var buf_stream = io.BufferedInStream(io.FileInStream.Error).init(&file_in_stream.stream); const st = &buf_stream.stream; const contents = try st.readAllAlloc(allocator, 2 * 1024); diff --git a/std/os/child_process.zig b/std/os/child_process.zig index b79a8de16f..decd8d04fa 100644 --- a/std/os/child_process.zig +++ b/std/os/child_process.zig @@ -209,8 +209,8 @@ pub const ChildProcess = struct { defer Buffer.deinit(&stdout); defer Buffer.deinit(&stderr); - var stdout_file_in_stream = io.FileInStream.init(&child.stdout.?); - var stderr_file_in_stream = io.FileInStream.init(&child.stderr.?); + var stdout_file_in_stream = io.FileInStream.init(child.stdout.?); + var stderr_file_in_stream = io.FileInStream.init(child.stderr.?); try stdout_file_in_stream.stream.readAllBuffer(&stdout, max_output_size); try stderr_file_in_stream.stream.readAllBuffer(&stderr, max_output_size); diff --git a/std/os/index.zig b/std/os/index.zig index 03337b63bc..9b49a05067 100644 --- a/std/os/index.zig +++ b/std/os/index.zig @@ -2149,6 +2149,7 @@ pub fn selfExePath(out_buffer: *[MAX_PATH_BYTES]u8) ![]u8 { switch (builtin.os) { Os.linux => return readLink(out_buffer, "/proc/self/exe"), Os.windows => { + var utf16le_buf: [windows_util.PATH_MAX_WIDE]u16 = undefined; const utf16le_slice = try selfExePathW(&utf16le_buf); // Trust that Windows gives us valid UTF-16LE. const end_index = std.unicode.utf16leToUtf8(out_buffer, utf16le_slice) catch unreachable; diff --git a/std/special/build_runner.zig b/std/special/build_runner.zig index 982c60aed8..8cf237f634 100644 --- a/std/special/build_runner.zig +++ b/std/special/build_runner.zig @@ -49,14 +49,14 @@ pub fn main() !void { var stderr_file = io.getStdErr(); var stderr_file_stream: io.FileOutStream = undefined; - var stderr_stream = if (stderr_file) |*f| x: { + var stderr_stream = if (stderr_file) |f| x: { stderr_file_stream = io.FileOutStream.init(f); break :x &stderr_file_stream.stream; } else |err| err; var stdout_file = io.getStdOut(); var stdout_file_stream: io.FileOutStream = undefined; - var stdout_stream = if (stdout_file) |*f| x: { + var stdout_stream = if (stdout_file) |f| x: { stdout_file_stream = io.FileOutStream.init(f); break :x &stdout_file_stream.stream; } else |err| err; diff --git a/std/zig/parser_test.zig b/std/zig/parser_test.zig index 6ea25e54f1..7f3ce7bd8a 100644 --- a/std/zig/parser_test.zig +++ b/std/zig/parser_test.zig @@ -1865,7 +1865,7 @@ var fixed_buffer_mem: [100 * 1024]u8 = undefined; fn testParse(source: []const u8, allocator: *mem.Allocator, anything_changed: *bool) ![]u8 { var stderr_file = try io.getStdErr(); - var stderr = &io.FileOutStream.init(&stderr_file).stream; + var stderr = &io.FileOutStream.init(stderr_file).stream; var tree = try std.zig.parse(allocator, source); defer tree.deinit(); diff --git a/test/compare_output.zig b/test/compare_output.zig index a18a78b419..bcd9d15b9c 100644 --- a/test/compare_output.zig +++ b/test/compare_output.zig @@ -19,7 +19,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { \\ \\pub fn main() void { \\ privateFunction(); - \\ const stdout = &(FileOutStream.init(&(getStdOut() catch unreachable)).stream); + \\ const stdout = &FileOutStream.init(getStdOut() catch unreachable).stream; \\ stdout.print("OK 2\n") catch unreachable; \\} \\ @@ -34,7 +34,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { \\// purposefully conflicting function with main.zig \\// but it's private so it should be OK \\fn privateFunction() void { - \\ const stdout = &(FileOutStream.init(&(getStdOut() catch unreachable)).stream); + \\ const stdout = &FileOutStream.init(getStdOut() catch unreachable).stream; \\ stdout.print("OK 1\n") catch unreachable; \\} \\ @@ -60,7 +60,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { tc.addSourceFile("foo.zig", \\use @import("std").io; \\pub fn foo_function() void { - \\ const stdout = &(FileOutStream.init(&(getStdOut() catch unreachable)).stream); + \\ const stdout = &FileOutStream.init(getStdOut() catch unreachable).stream; \\ stdout.print("OK\n") catch unreachable; \\} ); @@ -71,7 +71,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { \\ \\pub fn bar_function() void { \\ if (foo_function()) { - \\ const stdout = &(FileOutStream.init(&(getStdOut() catch unreachable)).stream); + \\ const stdout = &FileOutStream.init(getStdOut() catch unreachable).stream; \\ stdout.print("OK\n") catch unreachable; \\ } \\} @@ -103,7 +103,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { \\pub const a_text = "OK\n"; \\ \\pub fn ok() void { - \\ const stdout = &(io.FileOutStream.init(&(io.getStdOut() catch unreachable)).stream); + \\ const stdout = &io.FileOutStream.init(io.getStdOut() catch unreachable).stream; \\ stdout.print(b_text) catch unreachable; \\} ); @@ -121,7 +121,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { \\const io = @import("std").io; \\ \\pub fn main() void { - \\ const stdout = &(io.FileOutStream.init(&(io.getStdOut() catch unreachable)).stream); + \\ const stdout = &io.FileOutStream.init(io.getStdOut() catch unreachable).stream; \\ stdout.print("Hello, world!\n{d4} {x3} {c}\n", u32(12), u16(0x12), u8('a')) catch unreachable; \\} , "Hello, world!\n0012 012 a\n"); @@ -274,7 +274,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { \\ var x_local : i32 = print_ok(x); \\} \\fn print_ok(val: @typeOf(x)) @typeOf(foo) { - \\ const stdout = &(io.FileOutStream.init(&(io.getStdOut() catch unreachable)).stream); + \\ const stdout = &io.FileOutStream.init(io.getStdOut() catch unreachable).stream; \\ stdout.print("OK\n") catch unreachable; \\ return 0; \\} @@ -356,7 +356,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { \\pub fn main() void { \\ const bar = Bar {.field2 = 13,}; \\ const foo = Foo {.field1 = bar,}; - \\ const stdout = &(io.FileOutStream.init(&(io.getStdOut() catch unreachable)).stream); + \\ const stdout = &io.FileOutStream.init(io.getStdOut() catch unreachable).stream; \\ if (!foo.method()) { \\ stdout.print("BAD\n") catch unreachable; \\ } @@ -370,7 +370,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { cases.add("defer with only fallthrough", \\const io = @import("std").io; \\pub fn main() void { - \\ const stdout = &(io.FileOutStream.init(&(io.getStdOut() catch unreachable)).stream); + \\ const stdout = &io.FileOutStream.init(io.getStdOut() catch unreachable).stream; \\ stdout.print("before\n") catch unreachable; \\ defer stdout.print("defer1\n") catch unreachable; \\ defer stdout.print("defer2\n") catch unreachable; @@ -383,7 +383,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { \\const io = @import("std").io; \\const os = @import("std").os; \\pub fn main() void { - \\ const stdout = &(io.FileOutStream.init(&(io.getStdOut() catch unreachable)).stream); + \\ const stdout = &io.FileOutStream.init(io.getStdOut() catch unreachable).stream; \\ stdout.print("before\n") catch unreachable; \\ defer stdout.print("defer1\n") catch unreachable; \\ defer stdout.print("defer2\n") catch unreachable; @@ -400,7 +400,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { \\ do_test() catch return; \\} \\fn do_test() !void { - \\ const stdout = &(io.FileOutStream.init(&(io.getStdOut() catch unreachable)).stream); + \\ const stdout = &io.FileOutStream.init(io.getStdOut() catch unreachable).stream; \\ stdout.print("before\n") catch unreachable; \\ defer stdout.print("defer1\n") catch unreachable; \\ errdefer stdout.print("deferErr\n") catch unreachable; @@ -419,7 +419,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { \\ do_test() catch return; \\} \\fn do_test() !void { - \\ const stdout = &(io.FileOutStream.init(&(io.getStdOut() catch unreachable)).stream); + \\ const stdout = &io.FileOutStream.init(io.getStdOut() catch unreachable).stream; \\ stdout.print("before\n") catch unreachable; \\ defer stdout.print("defer1\n") catch unreachable; \\ errdefer stdout.print("deferErr\n") catch unreachable; @@ -436,7 +436,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { \\const io = @import("std").io; \\ \\pub fn main() void { - \\ const stdout = &(io.FileOutStream.init(&(io.getStdOut() catch unreachable)).stream); + \\ const stdout = &io.FileOutStream.init(io.getStdOut() catch unreachable).stream; \\ stdout.print(foo_txt) catch unreachable; \\} , "1234\nabcd\n"); @@ -456,7 +456,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { \\pub fn main() !void { \\ var args_it = os.args(); \\ var stdout_file = try io.getStdOut(); - \\ var stdout_adapter = io.FileOutStream.init(&stdout_file); + \\ var stdout_adapter = io.FileOutStream.init(stdout_file); \\ const stdout = &stdout_adapter.stream; \\ var index: usize = 0; \\ _ = args_it.skip(); @@ -497,7 +497,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { \\pub fn main() !void { \\ var args_it = os.args(); \\ var stdout_file = try io.getStdOut(); - \\ var stdout_adapter = io.FileOutStream.init(&stdout_file); + \\ var stdout_adapter = io.FileOutStream.init(stdout_file); \\ const stdout = &stdout_adapter.stream; \\ var index: usize = 0; \\ _ = args_it.skip(); diff --git a/test/tests.zig b/test/tests.zig index aa5eed17ee..a0e1792079 100644 --- a/test/tests.zig +++ b/test/tests.zig @@ -263,8 +263,8 @@ pub const CompareOutputContext = struct { var stdout = Buffer.initNull(b.allocator); var stderr = Buffer.initNull(b.allocator); - var stdout_file_in_stream = io.FileInStream.init(&child.stdout.?); - var stderr_file_in_stream = io.FileInStream.init(&child.stderr.?); + var stdout_file_in_stream = io.FileInStream.init(child.stdout.?); + var stderr_file_in_stream = io.FileInStream.init(child.stderr.?); stdout_file_in_stream.stream.readAllBuffer(&stdout, max_stdout_size) catch unreachable; stderr_file_in_stream.stream.readAllBuffer(&stderr, max_stdout_size) catch unreachable; @@ -578,8 +578,8 @@ pub const CompileErrorContext = struct { var stdout_buf = Buffer.initNull(b.allocator); var stderr_buf = Buffer.initNull(b.allocator); - var stdout_file_in_stream = io.FileInStream.init(&child.stdout.?); - var stderr_file_in_stream = io.FileInStream.init(&child.stderr.?); + var stdout_file_in_stream = io.FileInStream.init(child.stdout.?); + var stderr_file_in_stream = io.FileInStream.init(child.stderr.?); stdout_file_in_stream.stream.readAllBuffer(&stdout_buf, max_stdout_size) catch unreachable; stderr_file_in_stream.stream.readAllBuffer(&stderr_buf, max_stdout_size) catch unreachable; @@ -842,8 +842,8 @@ pub const TranslateCContext = struct { var stdout_buf = Buffer.initNull(b.allocator); var stderr_buf = Buffer.initNull(b.allocator); - var stdout_file_in_stream = io.FileInStream.init(&child.stdout.?); - var stderr_file_in_stream = io.FileInStream.init(&child.stderr.?); + var stdout_file_in_stream = io.FileInStream.init(child.stdout.?); + var stderr_file_in_stream = io.FileInStream.init(child.stderr.?); stdout_file_in_stream.stream.readAllBuffer(&stdout_buf, max_stdout_size) catch unreachable; stderr_file_in_stream.stream.readAllBuffer(&stderr_buf, max_stdout_size) catch unreachable; -- cgit v1.2.3