refactor(ffi-linkage): Phase 9.2c — rename extern-ref validators → Extern (linkage)

checkForeignRefs→checkExternRefs, validateForeignRefs→validateExternRefs,
collectForeignRefTargets→collectExternRefTargets — these police 'extern LIB' library
references (linkage axis), so Extern not Runtime. Snapshot-neutral; suite green.
This commit is contained in:
agra
2026-06-15 09:03:35 +03:00
parent 5c8af6eb73
commit d27be42a93
2 changed files with 8 additions and 8 deletions

View File

@@ -311,7 +311,7 @@ pub fn processCImport(
// ── #foreign ref validation ───────────────────────────────────────────
fn collectForeignRefTargets(valid: *std.StringHashMap(void), decls: []const *Node) !void {
fn collectExternRefTargets(valid: *std.StringHashMap(void), decls: []const *Node) !void {
for (decls) |d| {
switch (d.data) {
.library_decl => |ld| try valid.put(ld.name, {}),
@@ -324,14 +324,14 @@ fn collectForeignRefTargets(valid: *std.StringHashMap(void), decls: []const *Nod
break;
}
}
try collectForeignRefTargets(valid, ns.decls);
try collectExternRefTargets(valid, ns.decls);
},
else => {},
}
}
}
fn checkForeignRefs(valid: *const std.StringHashMap(void), decls: []const *Node, diags: *@import("errors.zig").DiagnosticList) void {
fn checkExternRefs(valid: *const std.StringHashMap(void), decls: []const *Node, diags: *@import("errors.zig").DiagnosticList) void {
for (decls) |d| {
switch (d.data) {
.fn_decl => |fd| {
@@ -343,7 +343,7 @@ fn checkForeignRefs(valid: *const std.StringHashMap(void), decls: []const *Node,
diags.addFmt(.err, d.span, "extern library '{s}' is not declared; expected a #library constant or a named '#import c' unit", .{ref});
}
},
.namespace_decl => |ns| checkForeignRefs(valid, ns.decls, diags),
.namespace_decl => |ns| checkExternRefs(valid, ns.decls, diags),
else => {},
}
}
@@ -355,12 +355,12 @@ fn checkForeignRefs(valid: *const std.StringHashMap(void), decls: []const *Node,
/// namespaced into one tree, so existence is checked program-wide.
/// Decls synthesized from `#include` headers carry no ref and are
/// exempt.
pub fn validateForeignRefs(allocator: std.mem.Allocator, root: *const Node, diags: *@import("errors.zig").DiagnosticList) !void {
pub fn validateExternRefs(allocator: std.mem.Allocator, root: *const Node, diags: *@import("errors.zig").DiagnosticList) !void {
if (root.data != .root) return;
var valid = std.StringHashMap(void).init(allocator);
defer valid.deinit();
try collectForeignRefTargets(&valid, root.data.root.decls);
checkForeignRefs(&valid, root.data.root.decls, diags);
try collectExternRefTargets(&valid, root.data.root.decls);
checkExternRefs(&valid, root.data.root.decls, diags);
}
/// A cached entry must at least LOOK like an object file (Mach-O,

View File

@@ -302,7 +302,7 @@ pub const Compilation = struct {
// Every `#foreign <ref>` must name a #library constant or a named
// `#import c` unit — a typo'd ref otherwise resolves silently
// through whatever image happens to carry the symbol.
try c_import.validateForeignRefs(self.allocator, root, &self.diagnostics);
try c_import.validateExternRefs(self.allocator, root, &self.diagnostics);
if (self.diagnostics.hasErrors()) return error.CompileError;
var module = ir.Module.init(self.allocator);