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