refactor(ffi-linkage): Phase 9.3 — purge 'foreign' from comments (src caps + examples + docs)
src/: ~21 capital-Foreign comments the case-sensitive verify grep missed (Foreign-class→Runtime-class, Foreign path→Runtime path, Foreign decls→Extern decls, FOREIGN function→extern function) across calls/inst/ffi_objc/jni_descriptor/emit_llvm/ c_import/lower.*/ops. src 'foreign' now = ONLY the hash_foreign token + 4 rejection messages (9.0-delete targets). examples/*.sx comments → extern/runtime-class (1219 stdout regen; KEPT 1176). docs/inline-asm-design + debugger purged. Comments only — no build impact. 9.0 ratified: DELETE hash_foreign token next.
This commit is contained in:
@@ -804,7 +804,7 @@ pub const Ops = struct {
|
||||
};
|
||||
const callee_needs_c_abi = callee_func.is_extern or callee_func.call_conv == .c;
|
||||
const callee_raw_ret = self.e.toLLVMType(callee_func.ret);
|
||||
// Foreign string/?string returns receive one `char *` — never sret
|
||||
// Extern string/?string returns receive one `char *` — never sret
|
||||
// (must mirror declareFunction's signature classification).
|
||||
const cstr_ret = self.e.cstrRetKind(callee_func);
|
||||
const callee_uses_sret = callee_needs_c_abi and cstr_ret == .none and self.e.needsByval(callee_func.ret, callee_raw_ret);
|
||||
|
||||
@@ -245,7 +245,7 @@ pub fn processCImport(
|
||||
.name = pname,
|
||||
.name_span = .{ .start = 0, .end = 0 },
|
||||
.type_expr = ptype_node,
|
||||
// Foreign C param names (`i1`, `i2`, …) are RAW — exempt from
|
||||
// Extern C param names (`i1`, `i2`, …) are RAW — exempt from
|
||||
// the reserved-type-name binding check; generated bindings
|
||||
// must import without hand-edits.
|
||||
.is_raw = true,
|
||||
|
||||
@@ -81,7 +81,7 @@ pub const CallPlan = struct {
|
||||
selected: Lowering.SelectedFunc,
|
||||
/// Protocol method, by index in the protocol's method table.
|
||||
protocol_method: u32,
|
||||
/// Foreign-class method (Obj-C / JNI), with its static-ness.
|
||||
/// Runtime-class method (Obj-C / JNI), with its static-ness.
|
||||
runtime_method: struct { name: []const u8, is_static: bool },
|
||||
/// Enum / tagged-union type under construction.
|
||||
constructed: TypeId,
|
||||
@@ -241,7 +241,7 @@ pub const CallResolver = struct {
|
||||
};
|
||||
}
|
||||
}
|
||||
// Foreign-class instance method: look up the method's declared
|
||||
// Runtime-class instance method: look up the method's declared
|
||||
// return type so chained calls (e.g.
|
||||
// `UIWindow.alloc().initWithWindowScene(scene)`) resolve.
|
||||
{
|
||||
@@ -395,7 +395,7 @@ pub const CallResolver = struct {
|
||||
else => null,
|
||||
};
|
||||
if (type_name) |tn| {
|
||||
// Foreign-class static method: `Alias.static_method(args)`.
|
||||
// Runtime-class static method: `Alias.static_method(args)`.
|
||||
if (self.l.program_index.runtime_class_map.get(tn)) |fcd| {
|
||||
for (fcd.members) |m| switch (m) {
|
||||
.method => |md| if (md.is_static and std.mem.eql(u8, md.name, cfa.field)) {
|
||||
|
||||
@@ -2250,7 +2250,7 @@ pub const LLVMEmitter = struct {
|
||||
|
||||
/// Coerce a call argument to match the expected parameter type.
|
||||
/// Handles int width mismatches (trunc/ext), float width, and int↔float.
|
||||
/// How a FOREIGN function's declared sx return maps onto a C `char *`:
|
||||
/// How an EXTERN function's declared sx return maps onto a C `char *`:
|
||||
/// `-> string` (.plain) and `-> ?string` (.optional) both receive one
|
||||
/// pointer from C; everything else is `.none`. Keep `declareFunction`'s
|
||||
/// signature building and `emitCall`'s result synthesis keyed on the
|
||||
|
||||
@@ -105,7 +105,7 @@ pub const ObjcLowering = struct {
|
||||
/// C=u8 S=u16 I=u32 Q=u64 f=f32 d=f64
|
||||
/// @=id #=Class :=SEL *=C string ^v=void* / generic ptr
|
||||
///
|
||||
/// Foreign-class pointers (`*UIView` etc.) encode as `@` (object
|
||||
/// Runtime-class pointers (`*UIView` etc.) encode as `@` (object
|
||||
/// pointer). Other pointers fall to `^v` — the encoding is metadata,
|
||||
/// not ABI, so being conservative here is safe. Pass-by-value
|
||||
/// structs encode as `{Name=field0field1...}`; nested structs
|
||||
@@ -260,7 +260,7 @@ pub const ObjcLowering = struct {
|
||||
/// `self.field` access work in A.2/A.3. Field-by-name resolution
|
||||
/// stays correct across the future repositioning.
|
||||
///
|
||||
/// Foreign-class members other than `.field` are ignored here —
|
||||
/// Runtime-class members other than `.field` are ignored here —
|
||||
/// methods / `#extends` / `#implements` don't contribute to the
|
||||
/// state layout.
|
||||
pub fn objcDefinedStateStructType(self: ObjcLowering, fcd: *const ast.RuntimeClassDecl) TypeId {
|
||||
|
||||
@@ -364,7 +364,7 @@ pub const JniMsgSend = struct {
|
||||
/// NewObject(env, clazz, mid, args...)`. Returns a fresh jobject.
|
||||
/// Mutually exclusive with the other dispatch flags.
|
||||
is_constructor: bool = false,
|
||||
/// Foreign path of the parent class (e.g. `android/app/Activity`) when
|
||||
/// Runtime path of the parent class (e.g. `android/app/Activity`) when
|
||||
/// `is_nonvirtual` is true, OR of the class being constructed when
|
||||
/// `is_constructor` is true. emit_llvm uses `FindClass` to materialise
|
||||
/// the jclass at the call site (per-call; caching is follow-up).
|
||||
@@ -508,7 +508,7 @@ pub const Function = struct {
|
||||
/// True if `params[0]` is the synthetic `__sx_ctx: *Context`
|
||||
/// parameter that every default-conv sx function receives. Callers
|
||||
/// read this flag to decide whether to prepend their current
|
||||
/// `__sx_ctx` value to the args of a call. Foreign decls and
|
||||
/// `__sx_ctx` value to the args of a call. Extern decls and
|
||||
/// `callconv(.c)` functions have it false.
|
||||
has_implicit_ctx: bool = false,
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ pub const DeriveError = error{
|
||||
pub const ClassRegistry = std.StringHashMap([]const u8);
|
||||
|
||||
pub const Context = struct {
|
||||
/// Foreign path of the enclosing #jni_class — used to resolve `*Self`.
|
||||
/// Runtime path of the enclosing #jni_class — used to resolve `*Self`.
|
||||
/// e.g. "android/view/View".
|
||||
enclosing_path: []const u8,
|
||||
/// Lookup for sibling/forward-declared `#jni_class` aliases. When null,
|
||||
|
||||
@@ -505,7 +505,7 @@ test "lower: objcTypeEncodingFromSignature unwraps optional to wire type" {
|
||||
defer module.deinit();
|
||||
var lowering = Lowering.init(&module);
|
||||
|
||||
// Foreign `*NSString` so the encoder recognises it as `@`.
|
||||
// Runtime-class `*NSString` so the encoder recognises it as `@`.
|
||||
const ns_name = module.types.internString("NSString");
|
||||
const ns_struct = module.types.intern(.{ .@"struct" = .{ .name = ns_name, .fields = &.{} } });
|
||||
const ns_ptr = module.types.ptrTo(ns_struct);
|
||||
|
||||
@@ -722,7 +722,7 @@ pub fn lowerCall(self: *Lowering, c_in: *const ast.Call) Ref {
|
||||
switch (self.namespaceAliasVerdict(oname)) {
|
||||
.target => |target| {
|
||||
const fd = Lowering.namespaceFnMember(&target, fa.field) orelse break :gate;
|
||||
// Foreign / builtin / #compiler bodies keep their
|
||||
// Extern / builtin / #compiler bodies keep their
|
||||
// literal global symbol — the existing bare-name
|
||||
// machinery below resolves them.
|
||||
switch (fd.body.data) {
|
||||
@@ -891,7 +891,7 @@ pub fn lowerCall(self: *Lowering, c_in: *const ast.Call) Ref {
|
||||
method_args.append(self.alloc, a) catch unreachable;
|
||||
}
|
||||
|
||||
// Foreign-class DSL: `inst.method(args)` where `inst`'s
|
||||
// Runtime-class DSL: `inst.method(args)` where `inst`'s
|
||||
// type is an alias declared by `#jni_class("...") { ... }`
|
||||
// (or its parallel forms). Routes to the JNI dispatch
|
||||
// shape, descriptor derived from the sx signature.
|
||||
@@ -2236,7 +2236,7 @@ pub fn resolveCallParamTypes(self: *Lowering, c: *const ast.Call, sel_author: ?*
|
||||
}
|
||||
}
|
||||
if (self.getStructTypeName(obj_ty)) |sname| {
|
||||
// Foreign-class receiver (`#objc_class` / `#jni_class` / etc.):
|
||||
// Runtime-class receiver (`#objc_class` / `#jni_class` / etc.):
|
||||
// resolve the method from `runtime_class_map` walking `#extends`.
|
||||
// Without this path, `target_type` for each arg falls back to
|
||||
// whatever `self.target_type` was on entry — typically the
|
||||
|
||||
@@ -1112,7 +1112,7 @@ pub fn registerTopLevelGlobal(self: *Lowering, vd: *const ast.VarDecl) void {
|
||||
d.addFmt(.err, null, "top-level var '{s}' has no type annotation and no initializer to infer from", .{vd.name});
|
||||
break :blk .void;
|
||||
};
|
||||
// Foreign / extern globals reference a symbol defined in libSystem etc.
|
||||
// Extern globals reference a symbol defined in libSystem etc.
|
||||
// (`_NSConcreteStackBlock : *void extern;` or `… : *void extern;`). The C
|
||||
// symbol name is the optional override (`extern_name`) or the sx name itself.
|
||||
const sym_name = vd.extern_name orelse vd.name;
|
||||
@@ -2081,7 +2081,7 @@ pub fn declareFunction(self: *Lowering, fd: *const ast.FnDecl, name: []const u8)
|
||||
}
|
||||
}
|
||||
|
||||
// Foreign declarations with a trailing variadic param map to the C
|
||||
// Extern declarations with a trailing variadic param map to the C
|
||||
// calling convention's `...` tail. Drop the variadic param from the
|
||||
// IR signature (it has no C-level slot) and set is_variadic.
|
||||
// Bare `extern` import: an external C symbol declared via the `extern`
|
||||
@@ -2194,7 +2194,7 @@ pub fn registerQualifiedFn(self: *Lowering, ns_name: []const u8, fd: *const ast.
|
||||
// collision assert; registering a qualified alias for them
|
||||
// would divert that machinery and strand a per-call type binding.
|
||||
if (fd.type_params.len > 0 or hasComptimeParams(fd) or isPackFn(fd)) return;
|
||||
// Foreign / builtin / #compiler bodies keep their literal name; a
|
||||
// Extern / builtin / #compiler bodies keep their literal name; a
|
||||
// qualified alias has no distinct symbol to resolve to.
|
||||
switch (fd.body.data) {
|
||||
.builtin_expr, .compiler_expr => return,
|
||||
@@ -2300,7 +2300,7 @@ pub fn lazyLowerFunction(self: *Lowering, name: []const u8) void {
|
||||
}
|
||||
// No AST? (builtins, extern functions, or imported functions not in this file)
|
||||
const fd = self.program_index.fn_ast_map.get(name) orelse return;
|
||||
// Foreign declarations stay as extern stubs but need to be REGISTERED
|
||||
// Extern declarations stay as extern stubs but need to be REGISTERED
|
||||
// in the current module so callers get a real FuncId. Without this,
|
||||
// a comptime-lowered function (e.g. `concat` from std.sx pulled into
|
||||
// a fresh ct_module via `evalComptimeString`) emits `.call` against a
|
||||
|
||||
@@ -778,7 +778,7 @@ pub fn lowerSuperCall(
|
||||
} }, ret_ty);
|
||||
}
|
||||
|
||||
// ── Foreign-class registration ──────────────────────────────────
|
||||
// ── Runtime-class registration ──────────────────────────────────
|
||||
|
||||
/// Register a runtime-class declaration. The alias goes into
|
||||
/// `runtime_class_map` for method-dispatch lookup. The underlying
|
||||
|
||||
@@ -137,8 +137,8 @@ pub fn lookupObjcDefinedStateFieldOnPointer(self: *Lowering, obj_expr: *const as
|
||||
if (pointee_info != .@"struct") return null;
|
||||
const struct_name = self.module.types.getString(pointee_info.@"struct".name);
|
||||
const fcd = self.program_index.runtime_class_map.get(struct_name) orelse return null;
|
||||
// Only sx-defined Obj-C classes have a state struct. Foreign
|
||||
// classes' fields are purely declaration metadata (no state).
|
||||
// Only sx-defined Obj-C classes have a state struct. Extern (referenced)
|
||||
// runtime classes' fields are purely declaration metadata (no state).
|
||||
if (fcd.is_extern or fcd.runtime != .objc_class) return null;
|
||||
// Skip property fields — those dispatch via the M2.2 getter/setter
|
||||
// path. Plain instance fields take the ivar+gep path.
|
||||
|
||||
Reference in New Issue
Block a user