refactor(ffi-linkage): Phase 9.3-src — purge 'foreign' from src/ comments + a user-facing diagnostic

Reword every 'foreign' comment to the extern/runtime-class vocabulary matching the
renamed identifiers (foreign call→extern call, foreign class→runtime class, foreign
path→runtime path, the #foreign-literal comment mentions → extern, etc.). Also fixes
two USER-FACING issues: the 'expected … #foreign … after type annotation' parse error
no longer advertises the removed keyword, and the Android 'no #jni_main' help
diagnostic now shows '#jni_class(…) extern' instead of the rejected '#foreign
#jni_class'. Removed the now-dead prefix-#foreign-vs-postfix conflict branch in
parseRuntimeClassDecl (the caller rejects #foreign before it runs).

src/ now contains 'foreign' ONLY in the hash_foreign token machinery + its 4
rejection messages — the deprecation mechanism (kept per the 9.0 recommendation; the
message MUST name #foreign to guide migration). Snapshot-neutral; suite green
(646 corpus / 444 unit, 0 failed).
This commit is contained in:
agra
2026-06-15 09:35:00 +03:00
parent e99383fcb4
commit dc51c4b5bf
35 changed files with 172 additions and 180 deletions

View File

@@ -124,7 +124,7 @@ pub const CallingConvention = enum { default, c };
/// Linkage modifier written in the postfix slot after `callconv(...)`:
/// `name :: (sig) -> Ret [callconv(.x)] [extern | export] [;|{…}];`
/// `extern` = import (external linkage, C ABI, no sx ctx — `#foreign`'s role);
/// `extern` = import (external linkage, C ABI, no sx ctx — `extern`'s role);
/// `export` = define + expose (body + external linkage + C ABI + no ctx).
/// Both imply `callconv(.c)`. Variants carry a trailing `_` to dodge the Zig
/// keywords. `.none` = no linkage modifier (the ordinary sx-internal decl).
@@ -143,20 +143,20 @@ pub const FnDecl = struct {
/// Parsed in Phase 0.1; not consumed by the fn-decl path until Phase 1.
extern_export: ExternExportModifier = .none,
/// Optional library reference + symbol-name override for an `extern`/`export`
/// function, mirroring `#foreign LIB "csym"` (foreign_lib/foreign_name). Both
/// function, the optional library + symbol-name override. Both
/// optional: `extern` alone resolves the sx name against the default-linked
/// libs; `extern LIB` names the source library; `extern "csym"` renames the
/// symbol. Required for `extern` to be a behavior-equivalent superset of
/// `#foreign` (Gate A→B) — the migration of 466 `#foreign` uses across 6 libs
/// `extern` (Gate A→B) — the migration of 466 `extern` uses across 6 libs
/// must preserve each symbol's library. Parsed/consumed in Phase 1.2.
extern_lib: ?[]const u8 = null,
extern_name: ?[]const u8 = null,
/// Span of the function's name token, for the reserved-type-name decl
/// diagnostic. Synthesized decls (e.g. `#import c` foreign
/// diagnostic. Synthesized decls (e.g. `#import c` extern
/// functions, lowering-time objc/protocol method synthesis) leave it zero.
name_span: Span = .{ .start = 0, .end = 0 },
/// True when the function NAME was written as a backtick raw identifier
/// (`` `i2 :: … ``) or synthesized by a `#import c` foreign decl. A raw
/// (`` `i2 :: … ``) or synthesized by a `#import c` extern decl. A raw
/// name is exempt from the reserved-type-name binding check.
/// Every PARSER fn_decl is built through `parseFnDecl`, whose `name_is_raw`
/// is a REQUIRED parameter, so a parser site cannot drop it; the default
@@ -185,7 +185,7 @@ pub const Param = struct {
/// parameter, lowering substitutes this expression in its place.
default_expr: ?*Node = null,
/// True when the param name was written as a backtick raw identifier
/// (`` `i2 ``) or synthesized by a `#import c` foreign decl. A raw name is
/// (`` `i2 ``) or synthesized by a `#import c` extern decl. A raw name is
/// exempt from the reserved-type-name binding check.
is_raw: bool = false,
};
@@ -866,7 +866,7 @@ pub const RuntimeFieldDecl = struct {
name: []const u8,
field_type: *Node, // type_expr node
/// True iff the declaration carries a `#property[(...)]` directive
/// (M2.2). For foreign classes, that means synthesize getter/setter
/// (M2.2). For runtime classes, that means synthesize getter/setter
/// dispatch through `objc_msgSend`; for sx-defined classes it adds
/// runtime-introspectable property metadata + ARC-aware setter
/// emission (Month 4 wires the latter).