| ... | ... | @@ -1841,30 +1841,21 @@ pub const DeclGen = struct { |
| 1841 | 1841 | dg.module.markDeclAlive(decl); |
| 1842 | 1842 | |
| 1843 | 1843 | if (dg.module.decl_exports.get(decl_index)) |exports| { |
| 1844 | | return writer.writeAll(exports.items[export_index].options.name); |
| 1844 | try writer.writeAll(exports.items[export_index].options.name); |
| 1845 | 1845 | } else if (decl.isExtern()) { |
| 1846 | | return writer.writeAll(mem.sliceTo(decl.name, 0)); |
| 1847 | | } else if (dg.module.test_functions.get(decl_index)) |_| { |
| 1848 | | const gpa = dg.gpa; |
| 1849 | | const name = try decl.getFullyQualifiedName(dg.module); |
| 1850 | | defer gpa.free(name); |
| 1851 | | return writer.print("{}_{d}", .{ fmtIdent(name), @enumToInt(decl_index) }); |
| 1846 | try writer.writeAll(mem.sliceTo(decl.name, 0)); |
| 1852 | 1847 | } else { |
| 1853 | | const gpa = dg.gpa; |
| 1854 | | const name = try decl.getFullyQualifiedName(dg.module); |
| 1855 | | defer gpa.free(name); |
| 1856 | | |
| 1857 | | // MSVC has a limit of 4095 character token length limit, and fmtIdent can (worst case), expand |
| 1858 | | // to 3x the length of its input |
| 1859 | | if (name.len > 1365) { |
| 1860 | | var hash = ident_hasher_init; |
| 1861 | | hash.update(name); |
| 1862 | | const ident_hash = hash.finalInt(); |
| 1863 | | try writer.writeAll("zig_D_"); |
| 1864 | | return std.fmt.formatIntValue(ident_hash, "x", .{}, writer); |
| 1865 | | } else { |
| 1866 | | return writer.print("{}", .{fmtIdent(name)}); |
| 1867 | | } |
| 1848 | // MSVC has a limit of 4095 character token length limit, and fmtIdent can (worst case), |
| 1849 | // expand to 3x the length of its input, but let's cut it off at a much shorter limit. |
| 1850 | var name: [100]u8 = undefined; |
| 1851 | var name_stream = std.io.fixedBufferStream(&name); |
| 1852 | decl.renderFullyQualifiedName(dg.module, name_stream.writer()) catch |err| switch (err) { |
| 1853 | error.NoSpaceLeft => {}, |
| 1854 | }; |
| 1855 | try writer.print("{}__{d}", .{ |
| 1856 | fmtIdent(name_stream.getWritten()), |
| 1857 | @enumToInt(decl_index), |
| 1858 | }); |
| 1868 | 1859 | } |
| 1869 | 1860 | } |
| 1870 | 1861 | |