| ... | ... | @@ -26,7 +26,6 @@ const trace = @import("tracy.zig").trace; |
| 26 | 26 | const AstGen = @import("AstGen.zig"); |
| 27 | 27 | const Sema = @import("Sema.zig"); |
| 28 | 28 | const target_util = @import("target.zig"); |
| 29 | | const Cache = @import("Cache.zig"); |
| 30 | 29 | |
| 31 | 30 | /// General-purpose allocator. Used for both temporary and long-term storage. |
| 32 | 31 | gpa: *Allocator, |
| ... | ... | @@ -706,8 +705,6 @@ pub const Scope = struct { |
| 706 | 705 | stat_inode: std.fs.File.INode, |
| 707 | 706 | /// Whether this is populated depends on `status`. |
| 708 | 707 | stat_mtime: i128, |
| 709 | | /// Whether this is populated depends on `status`. |
| 710 | | source_hash: Cache.BinDigest, |
| 711 | 708 | /// Whether this is populated or not depends on `status`. |
| 712 | 709 | tree: ast.Tree, |
| 713 | 710 | /// Package that this file is a part of, managed externally. |
| ... | ... | @@ -734,13 +731,6 @@ pub const Scope = struct { |
| 734 | 731 | } |
| 735 | 732 | } |
| 736 | 733 | |
| 737 | | pub fn updateTreeToNewSource(file: *File) void { |
| 738 | | assert(file.source_loaded); |
| 739 | | if (file.status == .loaded_success) { |
| 740 | | file.tree.source = file.source; |
| 741 | | } |
| 742 | | } |
| 743 | | |
| 744 | 734 | pub fn deinit(file: *File, gpa: *Allocator) void { |
| 745 | 735 | file.unload(gpa); |
| 746 | 736 | file.* = undefined; |
| ... | ... | @@ -781,14 +771,11 @@ pub const Scope = struct { |
| 781 | 771 | return error.FileTooBig; |
| 782 | 772 | |
| 783 | 773 | const source = try gpa.allocSentinel(u8, stat.size, 0); |
| 774 | errdefer gpa.free(source); |
| 784 | 775 | const amt = try f.readAll(source); |
| 785 | 776 | if (amt != stat.size) |
| 786 | 777 | return error.UnexpectedEndOfFile; |
| 787 | 778 | |
| 788 | | var hasher = Cache.hasher_init; |
| 789 | | hasher.update(source); |
| 790 | | hasher.final(&file.source_hash); |
| 791 | | |
| 792 | 779 | file.stat_size = stat.size; |
| 793 | 780 | file.stat_inode = stat.inode; |
| 794 | 781 | file.stat_mtime = stat.mtime; |
| ... | ... | @@ -3316,7 +3303,6 @@ pub fn importFile(mod: *Module, cur_pkg: *Package, import_string: []const u8) !* |
| 3316 | 3303 | new_file.* = .{ |
| 3317 | 3304 | .sub_file_path = resolved_path, |
| 3318 | 3305 | .source = undefined, |
| 3319 | | .source_hash = undefined, |
| 3320 | 3306 | .source_loaded = false, |
| 3321 | 3307 | .stat_size = undefined, |
| 3322 | 3308 | .stat_inode = undefined, |
| ... | ... | @@ -3343,12 +3329,13 @@ pub fn importFile(mod: *Module, cur_pkg: *Package, import_string: []const u8) !* |
| 3343 | 3329 | .parent_name_hash = parent_name_hash, |
| 3344 | 3330 | .ty = Type.initTag(.type), |
| 3345 | 3331 | }; |
| 3332 | |
| 3346 | 3333 | const top_decl = try mod.createNewDecl( |
| 3347 | 3334 | &tmp_namespace, |
| 3348 | 3335 | resolved_path, |
| 3349 | 3336 | 0, |
| 3350 | 3337 | parent_name_hash, |
| 3351 | | new_file.source_hash, |
| 3338 | std.zig.hashSrc(tree.source), |
| 3352 | 3339 | ); |
| 3353 | 3340 | defer { |
| 3354 | 3341 | mod.decl_table.removeAssertDiscard(parent_name_hash); |
| ... | ... | @@ -3421,6 +3408,7 @@ pub fn importFile(mod: *Module, cur_pkg: *Package, import_string: []const u8) !* |
| 3421 | 3408 | const struct_ty = try val.toType(&gen_scope_arena.allocator); |
| 3422 | 3409 | const struct_decl = struct_ty.getOwnerDecl(); |
| 3423 | 3410 | |
| 3411 | struct_decl.contents_hash = top_decl.contents_hash; |
| 3424 | 3412 | new_file.namespace = struct_ty.getNamespace().?; |
| 3425 | 3413 | new_file.namespace.parent = null; |
| 3426 | 3414 | new_file.namespace.parent_name_hash = tmp_namespace.parent_name_hash; |