| ... | @@ -2869,14 +2869,14 @@ fn createAnonymousDeclTypeNamed( | ... | @@ -2869,14 +2869,14 @@ fn createAnonymousDeclTypeNamed( |
| 2869 | anon_prefix: []const u8, | 2869 | anon_prefix: []const u8, |
| 2870 | inst: ?Zir.Inst.Index, | 2870 | inst: ?Zir.Inst.Index, |
| 2871 | ) !InternPool.DeclIndex { | 2871 | ) !InternPool.DeclIndex { |
| 2872 | const mod = sema.mod; | 2872 | const zcu = sema.mod; |
| 2873 | const ip = &mod.intern_pool; | 2873 | const ip = &zcu.intern_pool; |
| 2874 | const gpa = sema.gpa; | 2874 | const gpa = sema.gpa; |
| 2875 | const namespace = block.namespace; | 2875 | const namespace = block.namespace; |
| 2876 | const src_decl = mod.declPtr(block.src_decl); | 2876 | const src_decl = zcu.declPtr(block.src_decl); |
| 2877 | const src_node = src_decl.relativeToNodeIndex(src.node_offset.x); | 2877 | const src_node = src_decl.relativeToNodeIndex(src.node_offset.x); |
| 2878 | const new_decl_index = try mod.allocateNewDecl(namespace, src_node); | 2878 | const new_decl_index = try zcu.allocateNewDecl(namespace, src_node); |
| 2879 | errdefer mod.destroyDecl(new_decl_index); | 2879 | errdefer zcu.destroyDecl(new_decl_index); |
| 2880 | | 2880 | |
| 2881 | switch (name_strategy) { | 2881 | switch (name_strategy) { |
| 2882 | .anon => { | 2882 | .anon => { |
| ... | @@ -2887,15 +2887,15 @@ fn createAnonymousDeclTypeNamed( | ... | @@ -2887,15 +2887,15 @@ fn createAnonymousDeclTypeNamed( |
| 2887 | // This name is also used as the key in the parent namespace so it cannot be | 2887 | // This name is also used as the key in the parent namespace so it cannot be |
| 2888 | // renamed. | 2888 | // renamed. |
| 2889 | | 2889 | |
| 2890 | const name = mod.intern_pool.getOrPutStringFmt(gpa, "{}__{s}_{d}", .{ | 2890 | const name = ip.getOrPutStringFmt(gpa, "{}__{s}_{d}", .{ |
| 2891 | src_decl.name.fmt(&mod.intern_pool), anon_prefix, @intFromEnum(new_decl_index), | 2891 | src_decl.name.fmt(ip), anon_prefix, @intFromEnum(new_decl_index), |
| 2892 | }, .no_embedded_nulls) catch unreachable; | 2892 | }, .no_embedded_nulls) catch unreachable; |
| 2893 | try mod.initNewAnonDecl(new_decl_index, src_decl.src_line, val, name); | 2893 | try zcu.initNewAnonDecl(new_decl_index, src_decl.src_line, val, name); |
| 2894 | return new_decl_index; | 2894 | return new_decl_index; |
| 2895 | }, | 2895 | }, |
| 2896 | .parent => { | 2896 | .parent => { |
| 2897 | const name = mod.declPtr(block.src_decl).name; | 2897 | const name = zcu.declPtr(block.src_decl).name; |
| 2898 | try mod.initNewAnonDecl(new_decl_index, src_decl.src_line, val, name); | 2898 | try zcu.initNewAnonDecl(new_decl_index, src_decl.src_line, val, name); |
| 2899 | return new_decl_index; | 2899 | return new_decl_index; |
| 2900 | }, | 2900 | }, |
| 2901 | .func => { | 2901 | .func => { |
| ... | @@ -2906,7 +2906,7 @@ fn createAnonymousDeclTypeNamed( | ... | @@ -2906,7 +2906,7 @@ fn createAnonymousDeclTypeNamed( |
| 2906 | defer buf.deinit(); | 2906 | defer buf.deinit(); |
| 2907 | | 2907 | |
| 2908 | const writer = buf.writer(); | 2908 | const writer = buf.writer(); |
| 2909 | try writer.print("{}(", .{mod.declPtr(block.src_decl).name.fmt(&mod.intern_pool)}); | 2909 | try writer.print("{}(", .{zcu.declPtr(block.src_decl).name.fmt(ip)}); |
| 2910 | | 2910 | |
| 2911 | var arg_i: usize = 0; | 2911 | var arg_i: usize = 0; |
| 2912 | for (fn_info.param_body) |zir_inst| switch (zir_tags[@intFromEnum(zir_inst)]) { | 2912 | for (fn_info.param_body) |zir_inst| switch (zir_tags[@intFromEnum(zir_inst)]) { |
| ... | @@ -2921,7 +2921,17 @@ fn createAnonymousDeclTypeNamed( | ... | @@ -2921,7 +2921,17 @@ fn createAnonymousDeclTypeNamed( |
| 2921 | return sema.createAnonymousDeclTypeNamed(block, src, val, .anon, anon_prefix, null); | 2921 | return sema.createAnonymousDeclTypeNamed(block, src, val, .anon, anon_prefix, null); |
| 2922 | | 2922 | |
| 2923 | if (arg_i != 0) try writer.writeByte(','); | 2923 | if (arg_i != 0) try writer.writeByte(','); |
| 2924 | try writer.print("{}", .{arg_val.fmtValue(sema.mod, sema)}); | 2924 | |
| | 2925 | // Limiting the depth here helps avoid type names getting too long, which |
| | 2926 | // in turn helps to avoid unreasonably long symbol names for namespaced |
| | 2927 | // symbols. Such names should ideally be human-readable, and additionally, |
| | 2928 | // some tooling may not support very long symbol names. |
| | 2929 | try writer.print("{}", .{Value.fmtValueFull(.{ |
| | 2930 | .val = arg_val, |
| | 2931 | .mod = zcu, |
| | 2932 | .opt_sema = sema, |
| | 2933 | .depth = 1, |
| | 2934 | })}); |
| 2925 | | 2935 | |
| 2926 | arg_i += 1; | 2936 | arg_i += 1; |
| 2927 | continue; | 2937 | continue; |
| ... | @@ -2930,8 +2940,8 @@ fn createAnonymousDeclTypeNamed( | ... | @@ -2930,8 +2940,8 @@ fn createAnonymousDeclTypeNamed( |
| 2930 | }; | 2940 | }; |
| 2931 | | 2941 | |
| 2932 | try writer.writeByte(')'); | 2942 | try writer.writeByte(')'); |
| 2933 | const name = try mod.intern_pool.getOrPutString(gpa, buf.items, .no_embedded_nulls); | 2943 | const name = try ip.getOrPutString(gpa, buf.items, .no_embedded_nulls); |
| 2934 | try mod.initNewAnonDecl(new_decl_index, src_decl.src_line, val, name); | 2944 | try zcu.initNewAnonDecl(new_decl_index, src_decl.src_line, val, name); |
| 2935 | return new_decl_index; | 2945 | return new_decl_index; |
| 2936 | }, | 2946 | }, |
| 2937 | .dbg_var => { | 2947 | .dbg_var => { |
| ... | @@ -2942,10 +2952,10 @@ fn createAnonymousDeclTypeNamed( | ... | @@ -2942,10 +2952,10 @@ fn createAnonymousDeclTypeNamed( |
| 2942 | .dbg_var_ptr, .dbg_var_val => { | 2952 | .dbg_var_ptr, .dbg_var_val => { |
| 2943 | if (zir_data[i].str_op.operand != ref) continue; | 2953 | if (zir_data[i].str_op.operand != ref) continue; |
| 2944 | | 2954 | |
| 2945 | const name = try mod.intern_pool.getOrPutStringFmt(gpa, "{}.{s}", .{ | 2955 | const name = try ip.getOrPutStringFmt(gpa, "{}.{s}", .{ |
| 2946 | src_decl.name.fmt(&mod.intern_pool), zir_data[i].str_op.getStr(sema.code), | 2956 | src_decl.name.fmt(ip), zir_data[i].str_op.getStr(sema.code), |
| 2947 | }, .no_embedded_nulls); | 2957 | }, .no_embedded_nulls); |
| 2948 | try mod.initNewAnonDecl(new_decl_index, src_decl.src_line, val, name); | 2958 | try zcu.initNewAnonDecl(new_decl_index, src_decl.src_line, val, name); |
| 2949 | return new_decl_index; | 2959 | return new_decl_index; |
| 2950 | }, | 2960 | }, |
| 2951 | else => {}, | 2961 | else => {}, |