| ... | ... | @@ -37,7 +37,7 @@ decl_exports: std.AutoHashMap(*Decl, []*Export), |
| 37 | 37 | /// This table owns the Export memory. |
| 38 | 38 | export_owners: std.AutoHashMap(*Decl, []*Export), |
| 39 | 39 | /// Maps fully qualified namespaced names to the Decl struct for them. |
| 40 | | decl_table: std.AutoHashMap(Scope.NameHash, *Decl), |
| 40 | decl_table: DeclTable, |
| 41 | 41 | |
| 42 | 42 | optimize_mode: std.builtin.Mode, |
| 43 | 43 | link_error_flags: link.ElfFile.ErrorFlags = .{}, |
| ... | ... | @@ -66,6 +66,8 @@ generation: u32 = 0, |
| 66 | 66 | /// contains Decls that need to be deleted if they end up having no references to them. |
| 67 | 67 | deletion_set: std.ArrayListUnmanaged(*Decl) = .{}, |
| 68 | 68 | |
| 69 | const DeclTable = std.HashMap(Scope.NameHash, *Decl, Scope.name_hash_hash, Scope.name_hash_eql); |
| 70 | |
| 69 | 71 | const WorkItem = union(enum) { |
| 70 | 72 | /// Write the machine code for a Decl to the output file. |
| 71 | 73 | codegen_decl: *Decl, |
| ... | ... | @@ -417,6 +419,14 @@ pub const Scope = struct { |
| 417 | 419 | } |
| 418 | 420 | } |
| 419 | 421 | |
| 422 | fn name_hash_hash(x: NameHash) u32 { |
| 423 | return @truncate(u32, @bitCast(u128, x)); |
| 424 | } |
| 425 | |
| 426 | fn name_hash_eql(a: NameHash, b: NameHash) bool { |
| 427 | return @bitCast(u128, a) == @bitCast(u128, b); |
| 428 | } |
| 429 | |
| 420 | 430 | pub const Tag = enum { |
| 421 | 431 | /// .zir source code. |
| 422 | 432 | zir_module, |
| ... | ... | @@ -711,7 +721,7 @@ pub fn init(gpa: *Allocator, options: InitOptions) !Module { |
| 711 | 721 | .bin_file_path = options.bin_file_path, |
| 712 | 722 | .bin_file = bin_file, |
| 713 | 723 | .optimize_mode = options.optimize_mode, |
| 714 | | .decl_table = std.AutoHashMap(Scope.NameHash, *Decl).init(gpa), |
| 724 | .decl_table = DeclTable.init(gpa), |
| 715 | 725 | .decl_exports = std.AutoHashMap(*Decl, []*Export).init(gpa), |
| 716 | 726 | .export_owners = std.AutoHashMap(*Decl, []*Export).init(gpa), |
| 717 | 727 | .failed_decls = std.AutoHashMap(*Decl, *ErrorMsg).init(gpa), |