| author | |
| committer | |
| log | 53a36eacfa145244902e9230243c76892d141b03 |
| tree | 6d750e53c9b86537f9ddfdeda7a24ee54356a7e9 |
| parent | d1a4bdb1f375b6aa737f1c02c346899336465e00 |
9 files changed, 96 insertions(+), 87 deletions(-)
src/Compilation.zig+7-7| ... | ... | @@ -1770,7 +1770,7 @@ pub fn update(self: *Compilation) !void { |
| 1770 | 1770 | assert(decl.deletion_flag); |
| 1771 | 1771 | assert(decl.dependants.count() == 0); |
| 1772 | 1772 | const is_anon = if (decl.zir_decl_index == 0) blk: { |
| 1773 | break :blk decl.namespace.anon_decls.swapRemove(decl); | |
| 1773 | break :blk decl.src_namespace.anon_decls.swapRemove(decl); | |
| 1774 | 1774 | } else false; |
| 1775 | 1775 | |
| 1776 | 1776 | try module.clearDecl(decl, null); |
| ... | ... | @@ -1889,13 +1889,13 @@ pub fn totalErrorCount(self: *Compilation) usize { |
| 1889 | 1889 | // the previous parse success, including compile errors, but we cannot |
| 1890 | 1890 | // emit them until the file succeeds parsing. |
| 1891 | 1891 | for (module.failed_decls.keys()) |key| { |
| 1892 | if (key.namespace.file_scope.okToReportErrors()) { | |
| 1892 | if (key.getFileScope().okToReportErrors()) { | |
| 1893 | 1893 | total += 1; |
| 1894 | 1894 | } |
| 1895 | 1895 | } |
| 1896 | 1896 | if (module.emit_h) |emit_h| { |
| 1897 | 1897 | for (emit_h.failed_decls.keys()) |key| { |
| 1898 | if (key.namespace.file_scope.okToReportErrors()) { | |
| 1898 | if (key.getFileScope().okToReportErrors()) { | |
| 1899 | 1899 | total += 1; |
| 1900 | 1900 | } |
| 1901 | 1901 | } |
| ... | ... | @@ -1968,7 +1968,7 @@ pub fn getAllErrorsAlloc(self: *Compilation) !AllErrors { |
| 1968 | 1968 | while (it.next()) |entry| { |
| 1969 | 1969 | // Skip errors for Decls within files that had a parse failure. |
| 1970 | 1970 | // We'll try again once parsing succeeds. |
| 1971 | if (entry.key_ptr.*.namespace.file_scope.okToReportErrors()) { | |
| 1971 | if (entry.key_ptr.*.getFileScope().okToReportErrors()) { | |
| 1972 | 1972 | try AllErrors.add(module, &arena, &errors, entry.value_ptr.*.*); |
| 1973 | 1973 | } |
| 1974 | 1974 | } |
| ... | ... | @@ -1978,7 +1978,7 @@ pub fn getAllErrorsAlloc(self: *Compilation) !AllErrors { |
| 1978 | 1978 | while (it.next()) |entry| { |
| 1979 | 1979 | // Skip errors for Decls within files that had a parse failure. |
| 1980 | 1980 | // We'll try again once parsing succeeds. |
| 1981 | if (entry.key_ptr.*.namespace.file_scope.okToReportErrors()) { | |
| 1981 | if (entry.key_ptr.*.getFileScope().okToReportErrors()) { | |
| 1982 | 1982 | try AllErrors.add(module, &arena, &errors, entry.value_ptr.*.*); |
| 1983 | 1983 | } |
| 1984 | 1984 | } |
| ... | ... | @@ -2169,12 +2169,12 @@ pub fn performAllTheWork(self: *Compilation) error{ TimerUnsupported, OutOfMemor |
| 2169 | 2169 | defer air.deinit(gpa); |
| 2170 | 2170 | |
| 2171 | 2171 | log.debug("analyze liveness of {s}", .{decl.name}); |
| 2172 | var liveness = try Liveness.analyze(gpa, air, decl.namespace.file_scope.zir); | |
| 2172 | var liveness = try Liveness.analyze(gpa, air, decl.getFileScope().zir); | |
| 2173 | 2173 | defer liveness.deinit(gpa); |
| 2174 | 2174 | |
| 2175 | 2175 | if (builtin.mode == .Debug and self.verbose_air) { |
| 2176 | 2176 | std.debug.print("# Begin Function AIR: {s}:\n", .{decl.name}); |
| 2177 | @import("print_air.zig").dump(gpa, air, decl.namespace.file_scope.zir, liveness); | |
| 2177 | @import("print_air.zig").dump(gpa, air, decl.getFileScope().zir, liveness); | |
| 2178 | 2178 | std.debug.print("# End Function AIR: {s}\n\n", .{decl.name}); |
| 2179 | 2179 | } |
| 2180 | 2180 |
src/Module.zig+55-49| ... | ... | @@ -264,7 +264,7 @@ pub const Export = struct { |
| 264 | 264 | |
| 265 | 265 | pub fn getSrcLoc(exp: Export) SrcLoc { |
| 266 | 266 | return .{ |
| 267 | .file_scope = exp.src_decl.namespace.file_scope, | |
| 267 | .file_scope = exp.src_decl.getFileScope(), | |
| 268 | 268 | .parent_decl_node = exp.src_decl.src_node, |
| 269 | 269 | .lazy = exp.src, |
| 270 | 270 | }; |
| ... | ... | @@ -350,7 +350,7 @@ pub const Decl = struct { |
| 350 | 350 | /// Reference to externally owned memory. |
| 351 | 351 | /// In the case of the Decl corresponding to a file, this is |
| 352 | 352 | /// the namespace of the struct, since there is no parent. |
| 353 | namespace: *Scope.Namespace, | |
| 353 | src_namespace: *Scope.Namespace, | |
| 354 | 354 | |
| 355 | 355 | /// The scope which lexically contains this decl. A decl must depend |
| 356 | 356 | /// on its lexical parent, in order to ensure that this pointer is valid. |
| ... | ... | @@ -516,7 +516,7 @@ pub const Decl = struct { |
| 516 | 516 | /// This name is relative to the containing namespace of the decl. |
| 517 | 517 | /// The memory is owned by the containing File ZIR. |
| 518 | 518 | pub fn getName(decl: Decl) ?[:0]const u8 { |
| 519 | const zir = decl.namespace.file_scope.zir; | |
| 519 | const zir = decl.getFileScope().zir; | |
| 520 | 520 | return decl.getNameZir(zir); |
| 521 | 521 | } |
| 522 | 522 | |
| ... | ... | @@ -528,7 +528,7 @@ pub const Decl = struct { |
| 528 | 528 | } |
| 529 | 529 | |
| 530 | 530 | pub fn contentsHash(decl: Decl) std.zig.SrcHash { |
| 531 | const zir = decl.namespace.file_scope.zir; | |
| 531 | const zir = decl.getFileScope().zir; | |
| 532 | 532 | return decl.contentsHashZir(zir); |
| 533 | 533 | } |
| 534 | 534 | |
| ... | ... | @@ -541,21 +541,21 @@ pub const Decl = struct { |
| 541 | 541 | |
| 542 | 542 | pub fn zirBlockIndex(decl: *const Decl) Zir.Inst.Index { |
| 543 | 543 | assert(decl.zir_decl_index != 0); |
| 544 | const zir = decl.namespace.file_scope.zir; | |
| 544 | const zir = decl.getFileScope().zir; | |
| 545 | 545 | return zir.extra[decl.zir_decl_index + 6]; |
| 546 | 546 | } |
| 547 | 547 | |
| 548 | 548 | pub fn zirAlignRef(decl: Decl) Zir.Inst.Ref { |
| 549 | 549 | if (!decl.has_align) return .none; |
| 550 | 550 | assert(decl.zir_decl_index != 0); |
| 551 | const zir = decl.namespace.file_scope.zir; | |
| 551 | const zir = decl.getFileScope().zir; | |
| 552 | 552 | return @intToEnum(Zir.Inst.Ref, zir.extra[decl.zir_decl_index + 7]); |
| 553 | 553 | } |
| 554 | 554 | |
| 555 | 555 | pub fn zirLinksectionRef(decl: Decl) Zir.Inst.Ref { |
| 556 | 556 | if (!decl.has_linksection_or_addrspace) return .none; |
| 557 | 557 | assert(decl.zir_decl_index != 0); |
| 558 | const zir = decl.namespace.file_scope.zir; | |
| 558 | const zir = decl.getFileScope().zir; | |
| 559 | 559 | const extra_index = decl.zir_decl_index + 7 + @boolToInt(decl.has_align); |
| 560 | 560 | return @intToEnum(Zir.Inst.Ref, zir.extra[extra_index]); |
| 561 | 561 | } |
| ... | ... | @@ -563,16 +563,16 @@ pub const Decl = struct { |
| 563 | 563 | pub fn zirAddrspaceRef(decl: Decl) Zir.Inst.Ref { |
| 564 | 564 | if (!decl.has_linksection_or_addrspace) return .none; |
| 565 | 565 | assert(decl.zir_decl_index != 0); |
| 566 | const zir = decl.namespace.file_scope.zir; | |
| 566 | const zir = decl.getFileScope().zir; | |
| 567 | 567 | const extra_index = decl.zir_decl_index + 7 + @boolToInt(decl.has_align) + 1; |
| 568 | 568 | return @intToEnum(Zir.Inst.Ref, zir.extra[extra_index]); |
| 569 | 569 | } |
| 570 | 570 | |
| 571 | 571 | /// Returns true if and only if the Decl is the top level struct associated with a File. |
| 572 | 572 | pub fn isRoot(decl: *const Decl) bool { |
| 573 | if (decl.namespace.parent != null) | |
| 573 | if (decl.src_namespace.parent != null) | |
| 574 | 574 | return false; |
| 575 | return decl == decl.namespace.ty.getOwnerDecl(); | |
| 575 | return decl == decl.src_namespace.getDecl(); | |
| 576 | 576 | } |
| 577 | 577 | |
| 578 | 578 | pub fn relativeToLine(decl: Decl, offset: u32) u32 { |
| ... | ... | @@ -608,29 +608,21 @@ pub const Decl = struct { |
| 608 | 608 | } |
| 609 | 609 | |
| 610 | 610 | pub fn srcToken(decl: Decl) Ast.TokenIndex { |
| 611 | const tree = &decl.namespace.file_scope.tree; | |
| 611 | const tree = &decl.getFileScope().tree; | |
| 612 | 612 | return tree.firstToken(decl.src_node); |
| 613 | 613 | } |
| 614 | 614 | |
| 615 | 615 | pub fn srcByteOffset(decl: Decl) u32 { |
| 616 | const tree = &decl.namespace.file_scope.tree; | |
| 616 | const tree = &decl.getFileScope().tree; | |
| 617 | 617 | return tree.tokens.items(.start)[decl.srcToken()]; |
| 618 | 618 | } |
| 619 | 619 | |
| 620 | 620 | pub fn renderFullyQualifiedName(decl: *const Decl, writer: anytype) @TypeOf(writer).Error!void { |
| 621 | // Namespace decls (struct/enum/union/opaque) use their own namespace, | |
| 622 | // which means the decl name and the namespace name are the same. | |
| 623 | // In that case we want to omit the decl name, unless this is the root decl. | |
| 624 | const unqualified_name = if (decl.namespace.getDecl() != decl or decl.namespace.parent == null) mem.spanZ(decl.name) else ""; | |
| 625 | return try decl.namespace.renderFullyQualifiedName(unqualified_name, writer); | |
| 621 | return try decl.src_namespace.renderFullyQualifiedName(mem.spanZ(decl.name), writer); | |
| 626 | 622 | } |
| 627 | 623 | |
| 628 | 624 | pub fn renderFullyQualifiedDebugName(decl: *const Decl, writer: anytype) @TypeOf(writer).Error!void { |
| 629 | // Namespace decls (struct/enum/union/opaque) use their own namespace, | |
| 630 | // which means the decl name and the namespace name are the same. | |
| 631 | // In that case we want to omit the decl name, unless this is the root decl. | |
| 632 | const unqualified_name = if (decl.namespace.getDecl() != decl or decl.namespace.parent == null) mem.spanZ(decl.name) else ""; | |
| 633 | return try decl.namespace.renderFullyQualifiedDebugName(unqualified_name, writer); | |
| 625 | return try decl.src_namespace.renderFullyQualifiedDebugName(mem.spanZ(decl.name), writer); | |
| 634 | 626 | } |
| 635 | 627 | |
| 636 | 628 | pub fn getFullyQualifiedName(decl: *const Decl, gpa: *Allocator) ![:0]u8 { |
| ... | ... | @@ -742,7 +734,7 @@ pub const Decl = struct { |
| 742 | 734 | } |
| 743 | 735 | |
| 744 | 736 | pub fn getFileScope(decl: Decl) *Scope.File { |
| 745 | return decl.namespace.file_scope; | |
| 737 | return decl.src_namespace.file_scope; | |
| 746 | 738 | } |
| 747 | 739 | |
| 748 | 740 | pub fn getEmitH(decl: *Decl, module: *Module) *EmitH { |
| ... | ... | @@ -1118,8 +1110,8 @@ pub const Scope = struct { |
| 1118 | 1110 | /// Asserts the scope has a parent which is a Namespace and returns it. |
| 1119 | 1111 | pub fn namespace(scope: *Scope) *Namespace { |
| 1120 | 1112 | switch (scope.tag) { |
| 1121 | .block => return scope.cast(Block).?.src_decl.namespace, | |
| 1122 | .file => return scope.cast(File).?.root_decl.?.namespace, | |
| 1113 | .block => return scope.cast(Block).?.namespace, | |
| 1114 | .file => return scope.cast(File).?.root_decl.?.src_namespace, | |
| 1123 | 1115 | .namespace => return scope.cast(Namespace).?, |
| 1124 | 1116 | } |
| 1125 | 1117 | } |
| ... | ... | @@ -1134,14 +1126,14 @@ pub const Scope = struct { |
| 1134 | 1126 | } |
| 1135 | 1127 | } |
| 1136 | 1128 | |
| 1137 | /// When called from inside a Block Scope, chases the src_decl, not the owner_decl. | |
| 1129 | /// When called from inside a Block Scope, chases the namespace, not the owner_decl. | |
| 1138 | 1130 | pub fn getFileScope(base: *Scope) *Scope.File { |
| 1139 | 1131 | var cur = base; |
| 1140 | 1132 | while (true) { |
| 1141 | 1133 | cur = switch (cur.tag) { |
| 1142 | 1134 | .namespace => return @fieldParentPtr(Namespace, "base", cur).file_scope, |
| 1143 | 1135 | .file => return @fieldParentPtr(File, "base", cur), |
| 1144 | .block => return @fieldParentPtr(Block, "base", cur).src_decl.namespace.file_scope, | |
| 1136 | .block => return @fieldParentPtr(Block, "base", cur).namespace.file_scope, | |
| 1145 | 1137 | }; |
| 1146 | 1138 | } |
| 1147 | 1139 | } |
| ... | ... | @@ -1475,6 +1467,10 @@ pub const Scope = struct { |
| 1475 | 1467 | /// This can vary during inline or comptime function calls. See `Sema.owner_decl` |
| 1476 | 1468 | /// for the one that will be the same for all Block instances. |
| 1477 | 1469 | src_decl: *Decl, |
| 1470 | /// The namespace to use for lookups from this source block | |
| 1471 | /// When analyzing fields, this is different from src_decl.src_namepsace. | |
| 1472 | namespace: *Namespace, | |
| 1473 | /// The AIR instructions generated for this block. | |
| 1478 | 1474 | instructions: ArrayListUnmanaged(Air.Inst.Index), |
| 1479 | 1475 | // `param` instructions are collected here to be used by the `func` instruction. |
| 1480 | 1476 | params: std.ArrayListUnmanaged(Param) = .{}, |
| ... | ... | @@ -1541,6 +1537,7 @@ pub const Scope = struct { |
| 1541 | 1537 | .parent = parent, |
| 1542 | 1538 | .sema = parent.sema, |
| 1543 | 1539 | .src_decl = parent.src_decl, |
| 1540 | .namespace = parent.namespace, | |
| 1544 | 1541 | .instructions = .{}, |
| 1545 | 1542 | .wip_capture_scope = parent.wip_capture_scope, |
| 1546 | 1543 | .label = null, |
| ... | ... | @@ -1564,7 +1561,7 @@ pub const Scope = struct { |
| 1564 | 1561 | } |
| 1565 | 1562 | |
| 1566 | 1563 | pub fn getFileScope(block: *Block) *Scope.File { |
| 1567 | return block.src_decl.namespace.file_scope; | |
| 1564 | return block.namespace.file_scope; | |
| 1568 | 1565 | } |
| 1569 | 1566 | |
| 1570 | 1567 | pub fn addTy( |
| ... | ... | @@ -3327,6 +3324,7 @@ pub fn semaFile(mod: *Module, file: *Scope.File) SemaError!void { |
| 3327 | 3324 | .parent = null, |
| 3328 | 3325 | .sema = &sema, |
| 3329 | 3326 | .src_decl = new_decl, |
| 3327 | .namespace = &struct_obj.namespace, | |
| 3330 | 3328 | .wip_capture_scope = wip_captures.scope, |
| 3331 | 3329 | .instructions = .{}, |
| 3332 | 3330 | .inlining = null, |
| ... | ... | @@ -3355,12 +3353,12 @@ fn semaDecl(mod: *Module, decl: *Decl) !bool { |
| 3355 | 3353 | const tracy = trace(@src()); |
| 3356 | 3354 | defer tracy.end(); |
| 3357 | 3355 | |
| 3358 | if (decl.namespace.file_scope.status != .success_zir) { | |
| 3356 | if (decl.getFileScope().status != .success_zir) { | |
| 3359 | 3357 | return error.AnalysisFail; |
| 3360 | 3358 | } |
| 3361 | 3359 | |
| 3362 | 3360 | const gpa = mod.gpa; |
| 3363 | const zir = decl.namespace.file_scope.zir; | |
| 3361 | const zir = decl.getFileScope().zir; | |
| 3364 | 3362 | const zir_datas = zir.instructions.items(.data); |
| 3365 | 3363 | |
| 3366 | 3364 | decl.analysis = .in_progress; |
| ... | ... | @@ -3406,6 +3404,7 @@ fn semaDecl(mod: *Module, decl: *Decl) !bool { |
| 3406 | 3404 | .parent = null, |
| 3407 | 3405 | .sema = &sema, |
| 3408 | 3406 | .src_decl = decl, |
| 3407 | .namespace = decl.src_namespace, | |
| 3409 | 3408 | .wip_capture_scope = wip_captures.scope, |
| 3410 | 3409 | .instructions = .{}, |
| 3411 | 3410 | .inlining = null, |
| ... | ... | @@ -4042,8 +4041,8 @@ pub fn deleteUnusedDecl(mod: *Module, decl: *Decl) void { |
| 4042 | 4041 | }, |
| 4043 | 4042 | } |
| 4044 | 4043 | |
| 4045 | const owner_namespace = if (decl.namespace.getDecl() == decl and decl.namespace.parent != null) decl.namespace.parent.? else decl.namespace; | |
| 4046 | assert(owner_namespace.anon_decls.swapRemove(decl)); | |
| 4044 | assert(!decl.isRoot()); | |
| 4045 | assert(decl.src_namespace.anon_decls.swapRemove(decl)); | |
| 4047 | 4046 | |
| 4048 | 4047 | const dependants = decl.dependants.keys(); |
| 4049 | 4048 | for (dependants) |dep| { |
| ... | ... | @@ -4059,8 +4058,8 @@ pub fn deleteUnusedDecl(mod: *Module, decl: *Decl) void { |
| 4059 | 4058 | pub fn abortAnonDecl(mod: *Module, decl: *Decl) void { |
| 4060 | 4059 | log.debug("abortAnonDecl {*} ({s})", .{ decl, decl.name }); |
| 4061 | 4060 | |
| 4062 | const owner_namespace = if (decl.namespace.getDecl() == decl and decl.namespace.parent != null) decl.namespace.parent.? else decl.namespace; | |
| 4063 | assert(owner_namespace.anon_decls.swapRemove(decl)); | |
| 4061 | assert(!decl.isRoot()); | |
| 4062 | assert(decl.src_namespace.anon_decls.swapRemove(decl)); | |
| 4064 | 4063 | |
| 4065 | 4064 | const dependants = decl.dependants.keys(); |
| 4066 | 4065 | for (dependants) |dep| { |
| ... | ... | @@ -4128,7 +4127,7 @@ pub fn analyzeFnBody(mod: *Module, decl: *Decl, func: *Fn, arena: *Allocator) Se |
| 4128 | 4127 | .gpa = gpa, |
| 4129 | 4128 | .arena = arena, |
| 4130 | 4129 | .perm_arena = &decl_arena.allocator, |
| 4131 | .code = decl.namespace.file_scope.zir, | |
| 4130 | .code = decl.getFileScope().zir, | |
| 4132 | 4131 | .owner_decl = decl, |
| 4133 | 4132 | .func = func, |
| 4134 | 4133 | .fn_ret_ty = func.owner_decl.ty.fnReturnType(), |
| ... | ... | @@ -4148,6 +4147,7 @@ pub fn analyzeFnBody(mod: *Module, decl: *Decl, func: *Fn, arena: *Allocator) Se |
| 4148 | 4147 | .parent = null, |
| 4149 | 4148 | .sema = &sema, |
| 4150 | 4149 | .src_decl = decl, |
| 4150 | .namespace = decl.src_namespace, | |
| 4151 | 4151 | .wip_capture_scope = wip_captures.scope, |
| 4152 | 4152 | .instructions = .{}, |
| 4153 | 4153 | .inlining = null, |
| ... | ... | @@ -4279,7 +4279,7 @@ pub fn allocateNewDecl(mod: *Module, name: [:0]const u8, namespace: *Scope.Names |
| 4279 | 4279 | |
| 4280 | 4280 | new_decl.* = .{ |
| 4281 | 4281 | .name = name, |
| 4282 | .namespace = namespace, | |
| 4282 | .src_namespace = namespace, | |
| 4283 | 4283 | .src_node = src_node, |
| 4284 | 4284 | .src_line = undefined, |
| 4285 | 4285 | .has_tv = false, |
| ... | ... | @@ -4426,32 +4426,38 @@ pub fn createAnonymousDeclNamed( |
| 4426 | 4426 | typed_value: TypedValue, |
| 4427 | 4427 | name: [:0]u8, |
| 4428 | 4428 | ) !*Decl { |
| 4429 | return mod.createAnonymousDeclFromDeclNamed(scope.srcDecl().?, scope.srcScope(), typed_value, name); | |
| 4429 | return mod.createAnonymousDeclFromDeclNamed(scope.srcDecl().?, scope.namespace(), scope.srcScope(), typed_value, name); | |
| 4430 | 4430 | } |
| 4431 | 4431 | |
| 4432 | 4432 | pub fn createAnonymousDecl(mod: *Module, scope: *Scope, typed_value: TypedValue) !*Decl { |
| 4433 | return mod.createAnonymousDeclFromDecl(scope.srcDecl().?, scope.srcScope(), typed_value); | |
| 4433 | return mod.createAnonymousDeclFromDecl(scope.srcDecl().?, scope.namespace(), scope.srcScope(), typed_value); | |
| 4434 | 4434 | } |
| 4435 | 4435 | |
| 4436 | pub fn createAnonymousDeclFromDecl(mod: *Module, src_decl: *Decl, src_scope: ?*CaptureScope, tv: TypedValue) !*Decl { | |
| 4436 | pub fn createAnonymousDeclFromDecl( | |
| 4437 | mod: *Module, | |
| 4438 | src_decl: *Decl, | |
| 4439 | namespace: *Scope.Namespace, | |
| 4440 | src_scope: ?*CaptureScope, | |
| 4441 | tv: TypedValue, | |
| 4442 | ) !*Decl { | |
| 4437 | 4443 | const name_index = mod.getNextAnonNameIndex(); |
| 4438 | 4444 | const name = try std.fmt.allocPrintZ(mod.gpa, "{s}__anon_{d}", .{ |
| 4439 | 4445 | src_decl.name, name_index, |
| 4440 | 4446 | }); |
| 4441 | return mod.createAnonymousDeclFromDeclNamed(src_decl, src_scope, tv, name); | |
| 4447 | return mod.createAnonymousDeclFromDeclNamed(src_decl, namespace, src_scope, tv, name); | |
| 4442 | 4448 | } |
| 4443 | 4449 | |
| 4444 | 4450 | /// Takes ownership of `name` even if it returns an error. |
| 4445 | 4451 | pub fn createAnonymousDeclFromDeclNamed( |
| 4446 | 4452 | mod: *Module, |
| 4447 | 4453 | src_decl: *Decl, |
| 4454 | namespace: *Scope.Namespace, | |
| 4448 | 4455 | src_scope: ?*CaptureScope, |
| 4449 | 4456 | typed_value: TypedValue, |
| 4450 | 4457 | name: [:0]u8, |
| 4451 | 4458 | ) !*Decl { |
| 4452 | 4459 | errdefer mod.gpa.free(name); |
| 4453 | 4460 | |
| 4454 | const namespace = src_decl.namespace; | |
| 4455 | 4461 | try namespace.anon_decls.ensureUnusedCapacity(mod.gpa, 1); |
| 4456 | 4462 | |
| 4457 | 4463 | const new_decl = try mod.allocateNewDecl(name, namespace, src_decl.src_node, src_scope); |
| ... | ... | @@ -4705,10 +4711,10 @@ pub const SwitchProngSrc = union(enum) { |
| 4705 | 4711 | range_expand: RangeExpand, |
| 4706 | 4712 | ) LazySrcLoc { |
| 4707 | 4713 | @setCold(true); |
| 4708 | const tree = decl.namespace.file_scope.getTree(gpa) catch |err| { | |
| 4714 | const tree = decl.getFileScope().getTree(gpa) catch |err| { | |
| 4709 | 4715 | // In this case we emit a warning + a less precise source location. |
| 4710 | 4716 | log.warn("unable to load {s}: {s}", .{ |
| 4711 | decl.namespace.file_scope.sub_file_path, @errorName(err), | |
| 4717 | decl.getFileScope().sub_file_path, @errorName(err), | |
| 4712 | 4718 | }); |
| 4713 | 4719 | return LazySrcLoc{ .node_offset = 0 }; |
| 4714 | 4720 | }; |
| ... | ... | @@ -4817,10 +4823,10 @@ pub const PeerTypeCandidateSrc = union(enum) { |
| 4817 | 4823 | else => {}, |
| 4818 | 4824 | } |
| 4819 | 4825 | |
| 4820 | const tree = decl.namespace.file_scope.getTree(gpa) catch |err| { | |
| 4826 | const tree = decl.getFileScope().getTree(gpa) catch |err| { | |
| 4821 | 4827 | // In this case we emit a warning + a less precise source location. |
| 4822 | 4828 | log.warn("unable to load {s}: {s}", .{ |
| 4823 | decl.namespace.file_scope.sub_file_path, @errorName(err), | |
| 4829 | decl.getFileScope().sub_file_path, @errorName(err), | |
| 4824 | 4830 | }); |
| 4825 | 4831 | return LazySrcLoc{ .node_offset = 0 }; |
| 4826 | 4832 | }; |
| ... | ... | @@ -4863,7 +4869,7 @@ pub fn processOutdatedAndDeletedDecls(mod: *Module) !void { |
| 4863 | 4869 | |
| 4864 | 4870 | // Remove from the namespace it resides in, preserving declaration order. |
| 4865 | 4871 | assert(decl.zir_decl_index != 0); |
| 4866 | _ = decl.namespace.decls.orderedRemove(mem.spanZ(decl.name)); | |
| 4872 | _ = decl.src_namespace.decls.orderedRemove(mem.spanZ(decl.name)); | |
| 4867 | 4873 | |
| 4868 | 4874 | try mod.clearDecl(decl, &outdated_decls); |
| 4869 | 4875 | decl.destroy(mod); |
| ... | ... | @@ -4929,7 +4935,7 @@ pub fn populateTestFunctions(mod: *Module) !void { |
| 4929 | 4935 | const gpa = mod.gpa; |
| 4930 | 4936 | const builtin_pkg = mod.main_pkg.table.get("builtin").?; |
| 4931 | 4937 | const builtin_file = (mod.importPkg(builtin_pkg) catch unreachable).file; |
| 4932 | const builtin_namespace = builtin_file.root_decl.?.namespace; | |
| 4938 | const builtin_namespace = builtin_file.root_decl.?.src_namespace; | |
| 4933 | 4939 | const decl = builtin_namespace.decls.get("test_functions").?; |
| 4934 | 4940 | var buf: Type.SlicePtrFieldTypeBuffer = undefined; |
| 4935 | 4941 | const tmp_test_fn_ty = decl.ty.slicePtrFieldType(&buf).elemType(); |
| ... | ... | @@ -4942,7 +4948,7 @@ pub fn populateTestFunctions(mod: *Module) !void { |
| 4942 | 4948 | const arena = &new_decl_arena.allocator; |
| 4943 | 4949 | |
| 4944 | 4950 | const test_fn_vals = try arena.alloc(Value, mod.test_functions.count()); |
| 4945 | const array_decl = try mod.createAnonymousDeclFromDecl(decl, null, .{ | |
| 4951 | const array_decl = try mod.createAnonymousDeclFromDecl(decl, decl.src_namespace, null, .{ | |
| 4946 | 4952 | .ty = try Type.Tag.array.create(arena, .{ |
| 4947 | 4953 | .len = test_fn_vals.len, |
| 4948 | 4954 | .elem_type = try tmp_test_fn_ty.copy(arena), |
| ... | ... | @@ -4955,7 +4961,7 @@ pub fn populateTestFunctions(mod: *Module) !void { |
| 4955 | 4961 | var name_decl_arena = std.heap.ArenaAllocator.init(gpa); |
| 4956 | 4962 | errdefer name_decl_arena.deinit(); |
| 4957 | 4963 | const bytes = try name_decl_arena.allocator.dupe(u8, test_name_slice); |
| 4958 | const test_name_decl = try mod.createAnonymousDeclFromDecl(array_decl, null, .{ | |
| 4964 | const test_name_decl = try mod.createAnonymousDeclFromDecl(array_decl, array_decl.src_namespace, null, .{ | |
| 4959 | 4965 | .ty = try Type.Tag.array_u8.create(&name_decl_arena.allocator, bytes.len), |
| 4960 | 4966 | .val = try Value.Tag.bytes.create(&name_decl_arena.allocator, bytes), |
| 4961 | 4967 | }); |
src/Sema.zig+23-20| ... | ... | @@ -1042,8 +1042,6 @@ pub fn analyzeStructDecl( |
| 1042 | 1042 | } else 0; |
| 1043 | 1043 | |
| 1044 | 1044 | _ = try sema.mod.scanNamespace(&struct_obj.namespace, extra_index, decls_len, new_decl); |
| 1045 | ||
| 1046 | new_decl.namespace = &struct_obj.namespace; | |
| 1047 | 1045 | } |
| 1048 | 1046 | |
| 1049 | 1047 | fn zirStructDecl( |
| ... | ... | @@ -1080,7 +1078,7 @@ fn zirStructDecl( |
| 1080 | 1078 | .status = .none, |
| 1081 | 1079 | .known_has_bits = undefined, |
| 1082 | 1080 | .namespace = .{ |
| 1083 | .parent = block.src_decl.namespace, | |
| 1081 | .parent = block.namespace, | |
| 1084 | 1082 | .ty = struct_ty, |
| 1085 | 1083 | .file_scope = block.getFileScope(), |
| 1086 | 1084 | }, |
| ... | ... | @@ -1188,7 +1186,7 @@ fn zirEnumDecl( |
| 1188 | 1186 | .values = .{}, |
| 1189 | 1187 | .node_offset = src.node_offset, |
| 1190 | 1188 | .namespace = .{ |
| 1191 | .parent = block.src_decl.namespace, | |
| 1189 | .parent = block.namespace, | |
| 1192 | 1190 | .ty = enum_ty, |
| 1193 | 1191 | .file_scope = block.getFileScope(), |
| 1194 | 1192 | }, |
| ... | ... | @@ -1199,8 +1197,6 @@ fn zirEnumDecl( |
| 1199 | 1197 | |
| 1200 | 1198 | extra_index = try mod.scanNamespace(&enum_obj.namespace, extra_index, decls_len, new_decl); |
| 1201 | 1199 | |
| 1202 | new_decl.namespace = &enum_obj.namespace; | |
| 1203 | ||
| 1204 | 1200 | const body = sema.code.extra[extra_index..][0..body_len]; |
| 1205 | 1201 | if (fields_len == 0) { |
| 1206 | 1202 | assert(body.len == 0); |
| ... | ... | @@ -1238,6 +1234,7 @@ fn zirEnumDecl( |
| 1238 | 1234 | .parent = null, |
| 1239 | 1235 | .sema = sema, |
| 1240 | 1236 | .src_decl = new_decl, |
| 1237 | .namespace = &enum_obj.namespace, | |
| 1241 | 1238 | .wip_capture_scope = wip_captures.scope, |
| 1242 | 1239 | .instructions = .{}, |
| 1243 | 1240 | .inlining = null, |
| ... | ... | @@ -1377,7 +1374,7 @@ fn zirUnionDecl( |
| 1377 | 1374 | .layout = small.layout, |
| 1378 | 1375 | .status = .none, |
| 1379 | 1376 | .namespace = .{ |
| 1380 | .parent = block.src_decl.namespace, | |
| 1377 | .parent = block.namespace, | |
| 1381 | 1378 | .ty = union_ty, |
| 1382 | 1379 | .file_scope = block.getFileScope(), |
| 1383 | 1380 | }, |
| ... | ... | @@ -1388,8 +1385,6 @@ fn zirUnionDecl( |
| 1388 | 1385 | |
| 1389 | 1386 | _ = try sema.mod.scanNamespace(&union_obj.namespace, extra_index, decls_len, new_decl); |
| 1390 | 1387 | |
| 1391 | new_decl.namespace = &union_obj.namespace; | |
| 1392 | ||
| 1393 | 1388 | try new_decl.finalizeNewArena(&new_decl_arena); |
| 1394 | 1389 | return sema.analyzeDeclVal(block, src, new_decl); |
| 1395 | 1390 | } |
| ... | ... | @@ -2283,6 +2278,7 @@ fn zirCImport(sema: *Sema, parent_block: *Scope.Block, inst: Zir.Inst.Index) Com |
| 2283 | 2278 | .parent = parent_block, |
| 2284 | 2279 | .sema = sema, |
| 2285 | 2280 | .src_decl = parent_block.src_decl, |
| 2281 | .namespace = parent_block.namespace, | |
| 2286 | 2282 | .wip_capture_scope = parent_block.wip_capture_scope, |
| 2287 | 2283 | .instructions = .{}, |
| 2288 | 2284 | .inlining = parent_block.inlining, |
| ... | ... | @@ -2383,6 +2379,7 @@ fn zirBlock( |
| 2383 | 2379 | .parent = parent_block, |
| 2384 | 2380 | .sema = sema, |
| 2385 | 2381 | .src_decl = parent_block.src_decl, |
| 2382 | .namespace = parent_block.namespace, | |
| 2386 | 2383 | .wip_capture_scope = parent_block.wip_capture_scope, |
| 2387 | 2384 | .instructions = .{}, |
| 2388 | 2385 | .label = &label, |
| ... | ... | @@ -2684,7 +2681,7 @@ fn zirDeclVal(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileErr |
| 2684 | 2681 | } |
| 2685 | 2682 | |
| 2686 | 2683 | fn lookupIdentifier(sema: *Sema, block: *Scope.Block, src: LazySrcLoc, name: []const u8) !*Decl { |
| 2687 | var namespace = block.src_decl.namespace; | |
| 2684 | var namespace = block.namespace; | |
| 2688 | 2685 | while (true) { |
| 2689 | 2686 | if (try sema.lookupInNamespace(block, src, namespace, name, false)) |decl| { |
| 2690 | 2687 | return decl; |
| ... | ... | @@ -2713,7 +2710,7 @@ fn lookupInNamespace( |
| 2713 | 2710 | } |
| 2714 | 2711 | |
| 2715 | 2712 | if (observe_usingnamespace and namespace.usingnamespace_set.count() != 0) { |
| 2716 | const src_file = block.src_decl.namespace.file_scope; | |
| 2713 | const src_file = block.namespace.file_scope; | |
| 2717 | 2714 | |
| 2718 | 2715 | const gpa = sema.gpa; |
| 2719 | 2716 | var checked_namespaces: std.AutoArrayHashMapUnmanaged(*Scope.Namespace, void) = .{}; |
| ... | ... | @@ -2731,7 +2728,7 @@ fn lookupInNamespace( |
| 2731 | 2728 | if (check_ns.decls.get(ident_name)) |decl| { |
| 2732 | 2729 | // Skip decls which are not marked pub, which are in a different |
| 2733 | 2730 | // file than the `a.b`/`@hasDecl` syntax. |
| 2734 | if (decl.is_pub or src_file == decl.namespace.file_scope) { | |
| 2731 | if (decl.is_pub or src_file == decl.getFileScope()) { | |
| 2735 | 2732 | try candidates.append(gpa, decl); |
| 2736 | 2733 | } |
| 2737 | 2734 | } |
| ... | ... | @@ -2739,7 +2736,7 @@ fn lookupInNamespace( |
| 2739 | 2736 | while (it.next()) |entry| { |
| 2740 | 2737 | const sub_usingnamespace_decl = entry.key_ptr.*; |
| 2741 | 2738 | const sub_is_pub = entry.value_ptr.*; |
| 2742 | if (!sub_is_pub and src_file != sub_usingnamespace_decl.namespace.file_scope) { | |
| 2739 | if (!sub_is_pub and src_file != sub_usingnamespace_decl.getFileScope()) { | |
| 2743 | 2740 | // Skip usingnamespace decls which are not marked pub, which are in |
| 2744 | 2741 | // a different file than the `a.b`/`@hasDecl` syntax. |
| 2745 | 2742 | continue; |
| ... | ... | @@ -2992,7 +2989,7 @@ fn analyzeCall( |
| 2992 | 2989 | // In order to save a bit of stack space, directly modify Sema rather |
| 2993 | 2990 | // than create a child one. |
| 2994 | 2991 | const parent_zir = sema.code; |
| 2995 | sema.code = module_fn.owner_decl.namespace.file_scope.zir; | |
| 2992 | sema.code = module_fn.owner_decl.getFileScope().zir; | |
| 2996 | 2993 | defer sema.code = parent_zir; |
| 2997 | 2994 | |
| 2998 | 2995 | const parent_inst_map = sema.inst_map; |
| ... | ... | @@ -3013,6 +3010,7 @@ fn analyzeCall( |
| 3013 | 3010 | .parent = null, |
| 3014 | 3011 | .sema = sema, |
| 3015 | 3012 | .src_decl = module_fn.owner_decl, |
| 3013 | .namespace = module_fn.owner_decl.src_namespace, | |
| 3016 | 3014 | .wip_capture_scope = wip_captures.scope, |
| 3017 | 3015 | .instructions = .{}, |
| 3018 | 3016 | .label = null, |
| ... | ... | @@ -3182,7 +3180,7 @@ fn analyzeCall( |
| 3182 | 3180 | // Check the Module's generic function map with an adapted context, so that we |
| 3183 | 3181 | // can match against `uncasted_args` rather than doing the work below to create a |
| 3184 | 3182 | // generic Scope only to junk it if it matches an existing instantiation. |
| 3185 | const namespace = module_fn.owner_decl.namespace; | |
| 3183 | const namespace = module_fn.owner_decl.src_namespace; | |
| 3186 | 3184 | const fn_zir = namespace.file_scope.zir; |
| 3187 | 3185 | const fn_info = fn_zir.getFnInfo(module_fn.zir_body_inst); |
| 3188 | 3186 | const zir_tags = fn_zir.instructions.items(.tag); |
| ... | ... | @@ -3314,6 +3312,7 @@ fn analyzeCall( |
| 3314 | 3312 | .parent = null, |
| 3315 | 3313 | .sema = &child_sema, |
| 3316 | 3314 | .src_decl = new_decl, |
| 3315 | .namespace = namespace, | |
| 3317 | 3316 | .wip_capture_scope = wip_captures.scope, |
| 3318 | 3317 | .instructions = .{}, |
| 3319 | 3318 | .inlining = null, |
| ... | ... | @@ -5338,6 +5337,7 @@ fn analyzeSwitch( |
| 5338 | 5337 | .parent = block, |
| 5339 | 5338 | .sema = sema, |
| 5340 | 5339 | .src_decl = block.src_decl, |
| 5340 | .namespace = block.namespace, | |
| 5341 | 5341 | .wip_capture_scope = block.wip_capture_scope, |
| 5342 | 5342 | .instructions = .{}, |
| 5343 | 5343 | .label = &label, |
| ... | ... | @@ -5861,7 +5861,7 @@ fn zirHasDecl(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileErr |
| 5861 | 5861 | .{container_type}, |
| 5862 | 5862 | ); |
| 5863 | 5863 | if (try sema.lookupInNamespace(block, src, namespace, decl_name, true)) |decl| { |
| 5864 | if (decl.is_pub or decl.namespace.file_scope == block.base.namespace().file_scope) { | |
| 5864 | if (decl.is_pub or decl.getFileScope() == block.base.namespace().file_scope) { | |
| 5865 | 5865 | return Air.Inst.Ref.bool_true; |
| 5866 | 5866 | } |
| 5867 | 5867 | } |
| ... | ... | @@ -9603,8 +9603,9 @@ fn addSafetyCheck( |
| 9603 | 9603 | var fail_block: Scope.Block = .{ |
| 9604 | 9604 | .parent = parent_block, |
| 9605 | 9605 | .sema = sema, |
| 9606 | .wip_capture_scope = parent_block.wip_capture_scope, | |
| 9607 | 9606 | .src_decl = parent_block.src_decl, |
| 9607 | .namespace = parent_block.namespace, | |
| 9608 | .wip_capture_scope = parent_block.wip_capture_scope, | |
| 9608 | 9609 | .instructions = .{}, |
| 9609 | 9610 | .inlining = parent_block.inlining, |
| 9610 | 9611 | .is_comptime = parent_block.is_comptime, |
| ... | ... | @@ -10259,7 +10260,7 @@ fn namespaceLookup( |
| 10259 | 10260 | const mod = sema.mod; |
| 10260 | 10261 | const gpa = sema.gpa; |
| 10261 | 10262 | if (try sema.lookupInNamespace(block, src, namespace, decl_name, true)) |decl| { |
| 10262 | if (!decl.is_pub and decl.namespace.file_scope != block.getFileScope()) { | |
| 10263 | if (!decl.is_pub and decl.getFileScope() != block.getFileScope()) { | |
| 10263 | 10264 | const msg = msg: { |
| 10264 | 10265 | const msg = try mod.errMsg(&block.base, src, "'{s}' is not marked 'pub'", .{ |
| 10265 | 10266 | decl_name, |
| ... | ... | @@ -11911,6 +11912,7 @@ fn semaStructFields( |
| 11911 | 11912 | .parent = null, |
| 11912 | 11913 | .sema = &sema, |
| 11913 | 11914 | .src_decl = decl, |
| 11915 | .namespace = &struct_obj.namespace, | |
| 11914 | 11916 | .wip_capture_scope = wip_captures.scope, |
| 11915 | 11917 | .instructions = .{}, |
| 11916 | 11918 | .inlining = null, |
| ... | ... | @@ -12080,6 +12082,7 @@ fn semaUnionFields( |
| 12080 | 12082 | .parent = null, |
| 12081 | 12083 | .sema = &sema, |
| 12082 | 12084 | .src_decl = decl, |
| 12085 | .namespace = &union_obj.namespace, | |
| 12083 | 12086 | .wip_capture_scope = wip_captures.scope, |
| 12084 | 12087 | .instructions = .{}, |
| 12085 | 12088 | .inlining = null, |
| ... | ... | @@ -12290,7 +12293,7 @@ fn getBuiltin( |
| 12290 | 12293 | const opt_builtin_inst = try sema.namespaceLookupRef( |
| 12291 | 12294 | block, |
| 12292 | 12295 | src, |
| 12293 | std_file.root_decl.?.namespace, | |
| 12296 | std_file.root_decl.?.src_namespace, | |
| 12294 | 12297 | "builtin", |
| 12295 | 12298 | ); |
| 12296 | 12299 | const builtin_inst = try sema.analyzeLoad(block, src, opt_builtin_inst.?, src); |
| ... | ... | @@ -12484,7 +12487,7 @@ fn typeHasOnePossibleValue( |
| 12484 | 12487 | } |
| 12485 | 12488 | |
| 12486 | 12489 | fn getAstTree(sema: *Sema, block: *Scope.Block) CompileError!*const std.zig.Ast { |
| 12487 | return block.src_decl.namespace.file_scope.getTree(sema.gpa) catch |err| { | |
| 12490 | return block.namespace.file_scope.getTree(sema.gpa) catch |err| { | |
| 12488 | 12491 | log.err("unable to load AST to report compile error: {s}", .{@errorName(err)}); |
| 12489 | 12492 | return error.AnalysisFail; |
| 12490 | 12493 | }; |
src/codegen.zig+2-2| ... | ... | @@ -2584,7 +2584,7 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type { |
| 2584 | 2584 | |
| 2585 | 2585 | fn genArgDbgInfo(self: *Self, inst: Air.Inst.Index, mcv: MCValue) !void { |
| 2586 | 2586 | const ty_str = self.air.instructions.items(.data)[inst].ty_str; |
| 2587 | const zir = &self.mod_fn.owner_decl.namespace.file_scope.zir; | |
| 2587 | const zir = &self.mod_fn.owner_decl.getFileScope().zir; | |
| 2588 | 2588 | const name = zir.nullTerminatedString(ty_str.str); |
| 2589 | 2589 | const name_with_null = name.ptr[0 .. name.len + 1]; |
| 2590 | 2590 | const ty = self.air.getRefType(ty_str.ty); |
| ... | ... | @@ -3834,7 +3834,7 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type { |
| 3834 | 3834 | fn airAsm(self: *Self, inst: Air.Inst.Index) !void { |
| 3835 | 3835 | const air_datas = self.air.instructions.items(.data); |
| 3836 | 3836 | const air_extra = self.air.extraData(Air.Asm, air_datas[inst].ty_pl.payload); |
| 3837 | const zir = self.mod_fn.owner_decl.namespace.file_scope.zir; | |
| 3837 | const zir = self.mod_fn.owner_decl.getFileScope().zir; | |
| 3838 | 3838 | const extended = zir.instructions.items(.data)[air_extra.data.zir_index].extended; |
| 3839 | 3839 | const zir_extra = zir.extraData(Zir.Inst.Asm, extended.operand); |
| 3840 | 3840 | const asm_source = zir.nullTerminatedString(zir_extra.data.asm_source); |
src/codegen/c.zig+1-1| ... | ... | @@ -1696,7 +1696,7 @@ fn airSwitchBr(f: *Function, inst: Air.Inst.Index) !CValue { |
| 1696 | 1696 | fn airAsm(f: *Function, inst: Air.Inst.Index) !CValue { |
| 1697 | 1697 | const air_datas = f.air.instructions.items(.data); |
| 1698 | 1698 | const air_extra = f.air.extraData(Air.Asm, air_datas[inst].ty_pl.payload); |
| 1699 | const zir = f.object.dg.decl.namespace.file_scope.zir; | |
| 1699 | const zir = f.object.dg.decl.getFileScope().zir; | |
| 1700 | 1700 | const extended = zir.instructions.items(.data)[air_extra.data.zir_index].extended; |
| 1701 | 1701 | const zir_extra = zir.extraData(Zir.Inst.Asm, extended.operand); |
| 1702 | 1702 | const asm_source = zir.nullTerminatedString(zir_extra.data.asm_source); |
src/codegen/llvm.zig+1-1| ... | ... | @@ -1819,7 +1819,7 @@ pub const FuncGen = struct { |
| 1819 | 1819 | |
| 1820 | 1820 | const ty_pl = self.air.instructions.items(.data)[inst].ty_pl; |
| 1821 | 1821 | const air_asm = self.air.extraData(Air.Asm, ty_pl.payload); |
| 1822 | const zir = self.dg.decl.namespace.file_scope.zir; | |
| 1822 | const zir = self.dg.decl.getFileScope().zir; | |
| 1823 | 1823 | const extended = zir.instructions.items(.data)[air_asm.data.zir_index].extended; |
| 1824 | 1824 | const zir_extra = zir.extraData(Zir.Inst.Asm, extended.operand); |
| 1825 | 1825 | const asm_source = zir.nullTerminatedString(zir_extra.data.asm_source); |
src/codegen/spirv.zig+1-1| ... | ... | @@ -139,7 +139,7 @@ pub const SPIRVModule = struct { |
| 139 | 139 | } |
| 140 | 140 | |
| 141 | 141 | fn resolveSourceFileName(self: *SPIRVModule, decl: *Decl) !ResultId { |
| 142 | const path = decl.namespace.file_scope.sub_file_path; | |
| 142 | const path = decl.getFileScope().sub_file_path; | |
| 143 | 143 | const result = try self.file_names.getOrPut(path); |
| 144 | 144 | if (!result.found_existing) { |
| 145 | 145 | result.value_ptr.* = self.allocResultId(); |
src/crash_report.zig+3-3| ... | ... | @@ -97,7 +97,7 @@ fn dumpStatusReport() !void { |
| 97 | 97 | allocator, |
| 98 | 98 | anal.body, |
| 99 | 99 | anal.body_index, |
| 100 | block.src_decl.getFileScope(), | |
| 100 | block.namespace.file_scope, | |
| 101 | 101 | block.src_decl.src_node, |
| 102 | 102 | 6, // indent |
| 103 | 103 | stderr, |
| ... | ... | @@ -106,7 +106,7 @@ fn dumpStatusReport() !void { |
| 106 | 106 | else => |e| return e, |
| 107 | 107 | }; |
| 108 | 108 | try stderr.writeAll(" For full context, use the command\n zig ast-check -t "); |
| 109 | try writeFilePath(block.src_decl.getFileScope(), stderr); | |
| 109 | try writeFilePath(block.namespace.file_scope, stderr); | |
| 110 | 110 | try stderr.writeAll("\n\n"); |
| 111 | 111 | |
| 112 | 112 | var parent = anal.parent; |
| ... | ... | @@ -118,7 +118,7 @@ fn dumpStatusReport() !void { |
| 118 | 118 | print_zir.renderSingleInstruction( |
| 119 | 119 | allocator, |
| 120 | 120 | curr.body[curr.body_index], |
| 121 | curr.block.src_decl.getFileScope(), | |
| 121 | curr.block.namespace.file_scope, | |
| 122 | 122 | curr.block.src_decl.src_node, |
| 123 | 123 | 6, // indent |
| 124 | 124 | stderr, |
src/link/Plan9.zig+3-3| ... | ... | @@ -163,11 +163,11 @@ pub fn createEmpty(gpa: *Allocator, options: link.Options) !*Plan9 { |
| 163 | 163 | |
| 164 | 164 | fn putFn(self: *Plan9, decl: *Module.Decl, out: FnDeclOutput) !void { |
| 165 | 165 | const gpa = self.base.allocator; |
| 166 | const fn_map_res = try self.fn_decl_table.getOrPut(gpa, decl.namespace.file_scope); | |
| 166 | const fn_map_res = try self.fn_decl_table.getOrPut(gpa, decl.getFileScope()); | |
| 167 | 167 | if (fn_map_res.found_existing) { |
| 168 | 168 | try fn_map_res.value_ptr.functions.put(gpa, decl, out); |
| 169 | 169 | } else { |
| 170 | const file = decl.namespace.file_scope; | |
| 170 | const file = decl.getFileScope(); | |
| 171 | 171 | const arena = &self.path_arena.allocator; |
| 172 | 172 | // each file gets a symbol |
| 173 | 173 | fn_map_res.value_ptr.* = .{ |
| ... | ... | @@ -548,7 +548,7 @@ pub fn freeDecl(self: *Plan9, decl: *Module.Decl) void { |
| 548 | 548 | const is_fn = (decl.val.tag() == .function); |
| 549 | 549 | if (is_fn) { |
| 550 | 550 | var symidx_and_submap = |
| 551 | self.fn_decl_table.get(decl.namespace.file_scope).?; | |
| 551 | self.fn_decl_table.get(decl.getFileScope()).?; | |
| 552 | 552 | var submap = symidx_and_submap.functions; |
| 553 | 553 | _ = submap.swapRemove(decl); |
| 554 | 554 | if (submap.count() == 0) { |