| author | |
| committer | |
| log | 70c71935c7c9f20353dc2a50b497b752d70d3452 |
| tree | ef64682878421fcc88751fec7220aa855edd231e |
| parent | 11695745e5c6cbd158625d2c1682a09e2ee4c679 |
2 files changed, 10 insertions(+), 6 deletions(-)
src/Module.zig+8-4| ... | @@ -888,15 +888,19 @@ pub const Decl = struct { | ... | @@ -888,15 +888,19 @@ pub const Decl = struct { |
| 888 | assert(decl.dependencies.swapRemove(other)); | 888 | assert(decl.dependencies.swapRemove(other)); |
| 889 | } | 889 | } |
| 890 | 890 | ||
| 891 | pub fn isExtern(decl: Decl, mod: *Module) bool { | 891 | pub fn getExternDecl(decl: Decl, mod: *Module) OptionalIndex { |
| 892 | assert(decl.has_tv); | 892 | assert(decl.has_tv); |
| 893 | return switch (mod.intern_pool.indexToKey(decl.val.toIntern())) { | 893 | return switch (mod.intern_pool.indexToKey(decl.val.toIntern())) { |
| 894 | .variable => |variable| variable.is_extern, | 894 | .variable => |variable| if (variable.is_extern) variable.decl.toOptional() else .none, |
| 895 | .extern_func => true, | 895 | .extern_func => |extern_func| extern_func.decl.toOptional(), |
| 896 | else => false, | 896 | else => .none, |
| 897 | }; | 897 | }; |
| 898 | } | 898 | } |
| 899 | 899 | ||
| 900 | pub fn isExtern(decl: Decl, mod: *Module) bool { | ||
| 901 | return decl.getExternDecl(mod) != .none; | ||
| 902 | } | ||
| 903 | |||
| 900 | pub fn getAlignment(decl: Decl, mod: *Module) u32 { | 904 | pub fn getAlignment(decl: Decl, mod: *Module) u32 { |
| 901 | assert(decl.has_tv); | 905 | assert(decl.has_tv); |
| 902 | return @as(u32, @intCast(decl.alignment.toByteUnitsOptional() orelse decl.ty.abiAlignment(mod))); | 906 | return @as(u32, @intCast(decl.alignment.toByteUnitsOptional() orelse decl.ty.abiAlignment(mod))); |
src/codegen/c.zig+2-2| ... | @@ -1846,8 +1846,8 @@ pub const DeclGen = struct { | ... | @@ -1846,8 +1846,8 @@ pub const DeclGen = struct { |
| 1846 | 1846 | ||
| 1847 | if (mod.decl_exports.get(decl_index)) |exports| { | 1847 | if (mod.decl_exports.get(decl_index)) |exports| { |
| 1848 | try writer.print("{}", .{exports.items[export_index].opts.name.fmt(&mod.intern_pool)}); | 1848 | try writer.print("{}", .{exports.items[export_index].opts.name.fmt(&mod.intern_pool)}); |
| 1849 | } else if (decl.isExtern(mod)) { | 1849 | } else if (decl.getExternDecl(mod).unwrap()) |extern_decl_index| { |
| 1850 | try writer.print("{}", .{decl.name.fmt(&mod.intern_pool)}); | 1850 | try writer.print("{}", .{mod.declPtr(extern_decl_index).name.fmt(&mod.intern_pool)}); |
| 1851 | } else { | 1851 | } else { |
| 1852 | // MSVC has a limit of 4095 character token length limit, and fmtIdent can (worst case), | 1852 | // MSVC has a limit of 4095 character token length limit, and fmtIdent can (worst case), |
| 1853 | // expand to 3x the length of its input, but let's cut it off at a much shorter limit. | 1853 | // expand to 3x the length of its input, but let's cut it off at a much shorter limit. |