| author | |
| committer | |
| log | d84b386f6034278c8a9e8c3d2b0975ac541584aa |
| tree | 279ab79fca1601c226a509b3a3a6bbdf0fbf477c |
| parent | 7140bb64e1aa77f6b6de5c7e4f78d880346c0747 |
3 files changed, 23 insertions(+), 6 deletions(-)
src/Compilation.zig+6-6| ... | @@ -402,10 +402,10 @@ pub const AllErrors = struct { | ... | @@ -402,10 +402,10 @@ pub const AllErrors = struct { |
| 402 | const source = try module_note.src_loc.file_scope.getSource(module.gpa); | 402 | const source = try module_note.src_loc.file_scope.getSource(module.gpa); |
| 403 | const byte_offset = try module_note.src_loc.byteOffset(module.gpa); | 403 | const byte_offset = try module_note.src_loc.byteOffset(module.gpa); |
| 404 | const loc = std.zig.findLineColumn(source, byte_offset); | 404 | const loc = std.zig.findLineColumn(source, byte_offset); |
| 405 | const sub_file_path = module_note.src_loc.file_scope.sub_file_path; | 405 | const file_path = try module_note.src_loc.file_scope.fullPath(&arena.allocator); |
| 406 | note.* = .{ | 406 | note.* = .{ |
| 407 | .src = .{ | 407 | .src = .{ |
| 408 | .src_path = try arena.allocator.dupe(u8, sub_file_path), | 408 | .src_path = file_path, |
| 409 | .msg = try arena.allocator.dupe(u8, module_note.msg), | 409 | .msg = try arena.allocator.dupe(u8, module_note.msg), |
| 410 | .byte_offset = byte_offset, | 410 | .byte_offset = byte_offset, |
| 411 | .line = @intCast(u32, loc.line), | 411 | .line = @intCast(u32, loc.line), |
| ... | @@ -425,10 +425,10 @@ pub const AllErrors = struct { | ... | @@ -425,10 +425,10 @@ pub const AllErrors = struct { |
| 425 | const source = try module_err_msg.src_loc.file_scope.getSource(module.gpa); | 425 | const source = try module_err_msg.src_loc.file_scope.getSource(module.gpa); |
| 426 | const byte_offset = try module_err_msg.src_loc.byteOffset(module.gpa); | 426 | const byte_offset = try module_err_msg.src_loc.byteOffset(module.gpa); |
| 427 | const loc = std.zig.findLineColumn(source, byte_offset); | 427 | const loc = std.zig.findLineColumn(source, byte_offset); |
| 428 | const sub_file_path = module_err_msg.src_loc.file_scope.sub_file_path; | 428 | const file_path = try module_err_msg.src_loc.file_scope.fullPath(&arena.allocator); |
| 429 | try errors.append(.{ | 429 | try errors.append(.{ |
| 430 | .src = .{ | 430 | .src = .{ |
| 431 | .src_path = try arena.allocator.dupe(u8, sub_file_path), | 431 | .src_path = file_path, |
| 432 | .msg = try arena.allocator.dupe(u8, module_err_msg.msg), | 432 | .msg = try arena.allocator.dupe(u8, module_err_msg.msg), |
| 433 | .byte_offset = byte_offset, | 433 | .byte_offset = byte_offset, |
| 434 | .line = @intCast(u32, loc.line), | 434 | .line = @intCast(u32, loc.line), |
| ... | @@ -479,7 +479,7 @@ pub const AllErrors = struct { | ... | @@ -479,7 +479,7 @@ pub const AllErrors = struct { |
| 479 | 479 | ||
| 480 | note.* = .{ | 480 | note.* = .{ |
| 481 | .src = .{ | 481 | .src = .{ |
| 482 | .src_path = try arena.dupe(u8, file.sub_file_path), | 482 | .src_path = try file.fullPath(arena), |
| 483 | .msg = try arena.dupe(u8, msg), | 483 | .msg = try arena.dupe(u8, msg), |
| 484 | .byte_offset = byte_offset, | 484 | .byte_offset = byte_offset, |
| 485 | .line = @intCast(u32, loc.line), | 485 | .line = @intCast(u32, loc.line), |
| ... | @@ -505,7 +505,7 @@ pub const AllErrors = struct { | ... | @@ -505,7 +505,7 @@ pub const AllErrors = struct { |
| 505 | 505 | ||
| 506 | try errors.append(.{ | 506 | try errors.append(.{ |
| 507 | .src = .{ | 507 | .src = .{ |
| 508 | .src_path = try arena.dupe(u8, file.sub_file_path), | 508 | .src_path = try file.fullPath(arena), |
| 509 | .msg = try arena.dupe(u8, msg), | 509 | .msg = try arena.dupe(u8, msg), |
| 510 | .byte_offset = byte_offset, | 510 | .byte_offset = byte_offset, |
| 511 | .line = @intCast(u32, loc.line), | 511 | .line = @intCast(u32, loc.line), |
src/Module.zig+5| ... | @@ -1111,6 +1111,11 @@ pub const Scope = struct { | ... | @@ -1111,6 +1111,11 @@ pub const Scope = struct { |
| 1111 | return buf.toOwnedSliceSentinel(0); | 1111 | return buf.toOwnedSliceSentinel(0); |
| 1112 | } | 1112 | } |
| 1113 | 1113 | ||
| 1114 | /// Returns the full path to this file relative to its package. | ||
| 1115 | pub fn fullPath(file: File, ally: *Allocator) ![]u8 { | ||
| 1116 | return file.pkg.root_src_directory.join(ally, &[_][]const u8{file.sub_file_path}); | ||
| 1117 | } | ||
| 1118 | |||
| 1114 | pub fn dumpSrc(file: *File, src: LazySrcLoc) void { | 1119 | pub fn dumpSrc(file: *File, src: LazySrcLoc) void { |
| 1115 | const loc = std.zig.findLineColumn(file.source.bytes, src); | 1120 | const loc = std.zig.findLineColumn(file.source.bytes, src); |
| 1116 | std.debug.print("{s}:{d}:{d}\n", .{ file.sub_file_path, loc.line + 1, loc.column + 1 }); | 1121 | std.debug.print("{s}:{d}:{d}\n", .{ file.sub_file_path, loc.line + 1, loc.column + 1 }); |
src/main.zig+12| ... | @@ -3117,6 +3117,9 @@ pub fn cmdFmt(gpa: *Allocator, args: []const []const u8) !void { | ... | @@ -3117,6 +3117,9 @@ pub fn cmdFmt(gpa: *Allocator, args: []const []const u8) !void { |
| 3117 | .root_decl = null, | 3117 | .root_decl = null, |
| 3118 | }; | 3118 | }; |
| 3119 | 3119 | ||
| 3120 | file.pkg = try Package.create(gpa, null, file.sub_file_path); | ||
| 3121 | defer file.pkg.destroy(gpa); | ||
| 3122 | |||
| 3120 | file.zir = try AstGen.generate(gpa, file.tree); | 3123 | file.zir = try AstGen.generate(gpa, file.tree); |
| 3121 | file.zir_loaded = true; | 3124 | file.zir_loaded = true; |
| 3122 | defer file.zir.deinit(gpa); | 3125 | defer file.zir.deinit(gpa); |
| ... | @@ -3309,6 +3312,9 @@ fn fmtPathFile( | ... | @@ -3309,6 +3312,9 @@ fn fmtPathFile( |
| 3309 | .root_decl = null, | 3312 | .root_decl = null, |
| 3310 | }; | 3313 | }; |
| 3311 | 3314 | ||
| 3315 | file.pkg = try Package.create(fmt.gpa, null, file.sub_file_path); | ||
| 3316 | defer file.pkg.destroy(fmt.gpa); | ||
| 3317 | |||
| 3312 | if (stat.size > max_src_size) | 3318 | if (stat.size > max_src_size) |
| 3313 | return error.FileTooBig; | 3319 | return error.FileTooBig; |
| 3314 | 3320 | ||
| ... | @@ -3901,6 +3907,9 @@ pub fn cmdAstCheck( | ... | @@ -3901,6 +3907,9 @@ pub fn cmdAstCheck( |
| 3901 | file.stat_size = source.len; | 3907 | file.stat_size = source.len; |
| 3902 | } | 3908 | } |
| 3903 | 3909 | ||
| 3910 | file.pkg = try Package.create(gpa, null, file.sub_file_path); | ||
| 3911 | defer file.pkg.destroy(gpa); | ||
| 3912 | |||
| 3904 | file.tree = try std.zig.parse(gpa, file.source); | 3913 | file.tree = try std.zig.parse(gpa, file.source); |
| 3905 | file.tree_loaded = true; | 3914 | file.tree_loaded = true; |
| 3906 | defer file.tree.deinit(gpa); | 3915 | defer file.tree.deinit(gpa); |
| ... | @@ -4017,6 +4026,9 @@ pub fn cmdChangelist( | ... | @@ -4017,6 +4026,9 @@ pub fn cmdChangelist( |
| 4017 | .root_decl = null, | 4026 | .root_decl = null, |
| 4018 | }; | 4027 | }; |
| 4019 | 4028 | ||
| 4029 | file.pkg = try Package.create(gpa, null, file.sub_file_path); | ||
| 4030 | defer file.pkg.destroy(gpa); | ||
| 4031 | |||
| 4020 | const source = try arena.allocSentinel(u8, @intCast(usize, stat.size), 0); | 4032 | const source = try arena.allocSentinel(u8, @intCast(usize, stat.size), 0); |
| 4021 | const amt = try f.readAll(source); | 4033 | const amt = try f.readAll(source); |
| 4022 | if (amt != stat.size) | 4034 | if (amt != stat.size) |