aboutsummaryrefslogtreecommitdiff
path: root/src/codegen/c.zig
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2024-12-04 23:22:09 -0800
committerAndrew Kelley <andrew@ziglang.org>2025-01-15 15:11:35 -0800
commit943dac3e8558712096d55a30897057d75444178c (patch)
tree71642efb143c8811cd59c407479dfacbc9723942 /src/codegen/c.zig
parent9bf715de74a7d5badeae932afb594b7c6b33afa3 (diff)
downloadzig-943dac3e8558712096d55a30897057d75444178c.tar.gz
zig-943dac3e8558712096d55a30897057d75444178c.zip
compiler: add type safety for export indices
Diffstat (limited to 'src/codegen/c.zig')
-rw-r--r--src/codegen/c.zig8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/codegen/c.zig b/src/codegen/c.zig
index 5ce1ecc21c..6fee1beb89 100644
--- a/src/codegen/c.zig
+++ b/src/codegen/c.zig
@@ -3052,12 +3052,12 @@ pub fn genDeclValue(
try w.writeAll(";\n");
}
-pub fn genExports(dg: *DeclGen, exported: Zcu.Exported, export_indices: []const u32) !void {
+pub fn genExports(dg: *DeclGen, exported: Zcu.Exported, export_indices: []const Zcu.Export.Index) !void {
const zcu = dg.pt.zcu;
const ip = &zcu.intern_pool;
const fwd = dg.fwdDeclWriter();
- const main_name = zcu.all_exports.items[export_indices[0]].opts.name;
+ const main_name = export_indices[0].ptr(zcu).opts.name;
try fwd.writeAll("#define ");
switch (exported) {
.nav => |nav| try dg.renderNavName(fwd, nav),
@@ -3069,7 +3069,7 @@ pub fn genExports(dg: *DeclGen, exported: Zcu.Exported, export_indices: []const
const exported_val = exported.getValue(zcu);
if (ip.isFunctionType(exported_val.typeOf(zcu).toIntern())) return for (export_indices) |export_index| {
- const @"export" = &zcu.all_exports.items[export_index];
+ const @"export" = export_index.ptr(zcu);
try fwd.writeAll("zig_extern ");
if (@"export".opts.linkage == .weak) try fwd.writeAll("zig_weak_linkage_fn ");
try dg.renderFunctionSignature(
@@ -3091,7 +3091,7 @@ pub fn genExports(dg: *DeclGen, exported: Zcu.Exported, export_indices: []const
else => true,
};
for (export_indices) |export_index| {
- const @"export" = &zcu.all_exports.items[export_index];
+ const @"export" = export_index.ptr(zcu);
try fwd.writeAll("zig_extern ");
if (@"export".opts.linkage == .weak) try fwd.writeAll("zig_weak_linkage ");
const extern_name = @"export".opts.name.toSlice(ip);