| ... | ... | @@ -173,6 +173,8 @@ pub const Decl = struct { |
| 173 | 173 | value_arena: ?*std.heap.ArenaAllocator.State = null, |
| 174 | 174 | /// The direct parent namespace of the Decl. |
| 175 | 175 | /// Reference to externally owned memory. |
| 176 | /// In the case of the Decl corresponding to a file, this is |
| 177 | /// the namespace of the struct, since there is no parent. |
| 176 | 178 | namespace: *Scope.Namespace, |
| 177 | 179 | |
| 178 | 180 | /// An integer that can be checked against the corresponding incrementing |
| ... | ... | @@ -279,7 +281,7 @@ pub const Decl = struct { |
| 279 | 281 | |
| 280 | 282 | pub fn destroy(decl: *Decl, module: *Module) void { |
| 281 | 283 | const gpa = module.gpa; |
| 282 | | log.debug("destroy Decl {s}", .{decl.name}); |
| 284 | log.debug("destroy Decl {*} ({s})", .{ decl, decl.name }); |
| 283 | 285 | decl.clearName(gpa); |
| 284 | 286 | if (decl.has_tv) { |
| 285 | 287 | if (decl.val.castTag(.function)) |payload| { |
| ... | ... | @@ -469,6 +471,7 @@ pub const EmitH = struct { |
| 469 | 471 | |
| 470 | 472 | /// Represents the data that an explicit error set syntax provides. |
| 471 | 473 | pub const ErrorSet = struct { |
| 474 | /// The Decl that corresponds to the error set itself. |
| 472 | 475 | owner_decl: *Decl, |
| 473 | 476 | /// Offset from Decl node index, points to the error set AST node. |
| 474 | 477 | node_offset: i32, |
| ... | ... | @@ -488,6 +491,7 @@ pub const ErrorSet = struct { |
| 488 | 491 | |
| 489 | 492 | /// Represents the data that a struct declaration provides. |
| 490 | 493 | pub const Struct = struct { |
| 494 | /// The Decl that corresponds to the struct itself. |
| 491 | 495 | owner_decl: *Decl, |
| 492 | 496 | /// Set of field names in declaration order. |
| 493 | 497 | fields: std.StringArrayHashMapUnmanaged(Field), |
| ... | ... | @@ -537,6 +541,7 @@ pub const Struct = struct { |
| 537 | 541 | /// is inferred to be the smallest power of two unsigned int that fits |
| 538 | 542 | /// the number of fields. |
| 539 | 543 | pub const EnumSimple = struct { |
| 544 | /// The Decl that corresponds to the enum itself. |
| 540 | 545 | owner_decl: *Decl, |
| 541 | 546 | /// Set of field names in declaration order. |
| 542 | 547 | fields: std.StringArrayHashMapUnmanaged(void), |
| ... | ... | @@ -555,6 +560,7 @@ pub const EnumSimple = struct { |
| 555 | 560 | /// Represents the data that an enum declaration provides, when there is |
| 556 | 561 | /// at least one tag value explicitly specified, or at least one declaration. |
| 557 | 562 | pub const EnumFull = struct { |
| 563 | /// The Decl that corresponds to the enum itself. |
| 558 | 564 | owner_decl: *Decl, |
| 559 | 565 | /// An integer type which is used for the numerical value of the enum. |
| 560 | 566 | /// Whether zig chooses this type or the user specifies it, it is stored here. |
| ... | ... | @@ -585,6 +591,7 @@ pub const EnumFull = struct { |
| 585 | 591 | /// Extern functions do not have this data structure; they are represented by |
| 586 | 592 | /// the `Decl` only, with a `Value` tag of `extern_fn`. |
| 587 | 593 | pub const Fn = struct { |
| 594 | /// The Decl that corresponds to the function itself. |
| 588 | 595 | owner_decl: *Decl, |
| 589 | 596 | /// undefined unless analysis state is `success`. |
| 590 | 597 | body: ir.Body, |
| ... | ... | @@ -736,6 +743,8 @@ pub const Scope = struct { |
| 736 | 743 | pub fn clearDecls(ns: *Namespace, mod: *Module) void { |
| 737 | 744 | const gpa = mod.gpa; |
| 738 | 745 | |
| 746 | log.debug("clearDecls {*}", .{ns}); |
| 747 | |
| 739 | 748 | var decls = ns.decls; |
| 740 | 749 | ns.decls = .{}; |
| 741 | 750 | |
| ... | ... | @@ -2919,12 +2928,12 @@ fn scanDecl(iter: *ScanDeclIter, decl_sub_index: usize, flags: u4) InnerError!vo |
| 2919 | 2928 | const test_name = zir.nullTerminatedString(decl_name_index + 1); |
| 2920 | 2929 | break :name try std.fmt.allocPrintZ(gpa, "test.{s}", .{test_name}); |
| 2921 | 2930 | }; |
| 2922 | | log.debug("scan decl {s} is_pub={}", .{ decl_name, is_pub }); |
| 2923 | 2931 | |
| 2924 | 2932 | // We create a Decl for it regardless of analysis status. |
| 2925 | 2933 | const gop = try namespace.decls.getOrPut(gpa, decl_name); |
| 2926 | 2934 | if (!gop.found_existing) { |
| 2927 | 2935 | const new_decl = try mod.allocateNewDecl(namespace, decl_node); |
| 2936 | log.debug("scan new decl {*} ({s}) into {*}", .{ new_decl, decl_name, namespace }); |
| 2928 | 2937 | new_decl.src_line = line; |
| 2929 | 2938 | new_decl.name = decl_name; |
| 2930 | 2939 | gop.entry.value = new_decl; |
| ... | ... | @@ -2947,6 +2956,7 @@ fn scanDecl(iter: *ScanDeclIter, decl_sub_index: usize, flags: u4) InnerError!vo |
| 2947 | 2956 | return; |
| 2948 | 2957 | } |
| 2949 | 2958 | const decl = gop.entry.value; |
| 2959 | log.debug("scan existing decl {*} ({s}) of {*}", .{ decl, decl_name, namespace }); |
| 2950 | 2960 | // Update the AST node of the decl; even if its contents are unchanged, it may |
| 2951 | 2961 | // have been re-ordered. |
| 2952 | 2962 | const prev_src_node = decl.src_node; |