refactor(ffi-linkage): Phase 9.2b-fix — use is_extern (not new is_reference) for the runtime-class ref flag
Per user feedback: don't introduce new terminology. The RuntimeClassDecl reference-vs-define flag (set by the postfix 'extern' modifier, == old prefix '#foreign #objc_class') is named is_extern, matching the keyword that drives it and the existing is_extern on VarDecl/IR. Renamed is_reference→is_extern, is_reference_eff→is_extern_eff; updated the field comment. Snapshot-neutral; green.
This commit is contained in:
@@ -207,7 +207,7 @@ pub fn checkRequiredEntryPoints(self: *Lowering) void {
|
||||
var it = self.program_index.runtime_class_map.iterator();
|
||||
while (it.next()) |entry| {
|
||||
const fcd = entry.value_ptr.*;
|
||||
if (fcd.is_main and !fcd.is_reference and fcd.runtime == .jni_class) return;
|
||||
if (fcd.is_main and !fcd.is_extern and fcd.runtime == .jni_class) return;
|
||||
}
|
||||
|
||||
if (self.diagnostics) |diags| {
|
||||
|
||||
@@ -270,7 +270,7 @@ pub fn lowerRuntimeMethodCall(
|
||||
if (fcd.runtime == .objc_class or fcd.runtime == .objc_protocol) {
|
||||
return self.lowerObjcMethodCall(fcd, method, target, method_args, span);
|
||||
}
|
||||
if (!fcd.is_reference) {
|
||||
if (!fcd.is_extern) {
|
||||
if (self.diagnostics) |d| {
|
||||
d.addFmt(.err, span, "sx-defined classes on non-Obj-C runtimes can't yet be dispatched into (class '{s}', runtime '{s}')", .{ fcd.name, @tagName(fcd.runtime) });
|
||||
}
|
||||
@@ -505,7 +505,7 @@ pub fn lowerObjcStaticCall(
|
||||
// instead of going through `objc_msgSend` (which would land in the
|
||||
// +alloc IMP and use `__sx_default_context.allocator`). This honors
|
||||
// a surrounding `push Context.{ allocator = ... }`.
|
||||
if (!fcd.is_reference and
|
||||
if (!fcd.is_extern and
|
||||
fcd.runtime == .objc_class and
|
||||
method_args.len == 0 and
|
||||
std.mem.eql(u8, method.name, "alloc"))
|
||||
@@ -794,7 +794,7 @@ pub fn lowerSuperCall(
|
||||
/// substituted to `*<ClassName>State` during body lowering (M1.2 A.2b).
|
||||
pub fn registerRuntimeClassDecl(self: *Lowering, fcd: *const ast.RuntimeClassDecl) void {
|
||||
self.program_index.runtime_class_map.put(fcd.name, fcd) catch {};
|
||||
if (!fcd.is_reference and fcd.runtime == .objc_class) {
|
||||
if (!fcd.is_extern and fcd.runtime == .objc_class) {
|
||||
if (self.module.lookupObjcDefinedClass(fcd.name) == null) {
|
||||
self.module.appendObjcDefinedClass(fcd.name, fcd);
|
||||
// M2.3 — resolve the `#extends` alias to the actual
|
||||
@@ -829,7 +829,7 @@ pub fn resolveObjcParentName(self: *Lowering, fcd: *const ast.RuntimeClassDecl)
|
||||
for (fcd.members) |m| switch (m) {
|
||||
.extends => |alias| {
|
||||
if (self.program_index.runtime_class_map.get(alias)) |parent_fcd| {
|
||||
if (parent_fcd.is_reference) return parent_fcd.foreign_path;
|
||||
if (parent_fcd.is_extern) return parent_fcd.foreign_path;
|
||||
// Sx-defined parent — its alias IS its Obj-C name.
|
||||
return parent_fcd.name;
|
||||
}
|
||||
@@ -1037,7 +1037,7 @@ pub fn synthesizeJniMainStubs(self: *Lowering) void {
|
||||
while (it.next()) |entry| {
|
||||
const fcd = entry.value_ptr.*;
|
||||
if (!fcd.is_main) continue;
|
||||
if (fcd.is_reference) continue;
|
||||
if (fcd.is_extern) continue;
|
||||
if (fcd.runtime != .jni_class) continue;
|
||||
if (seen.contains(fcd.foreign_path)) continue;
|
||||
seen.put(fcd.foreign_path, {}) catch continue;
|
||||
|
||||
@@ -139,7 +139,7 @@ pub fn lookupObjcDefinedStateFieldOnPointer(self: *Lowering, obj_expr: *const as
|
||||
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).
|
||||
if (fcd.is_reference or fcd.runtime != .objc_class) return null;
|
||||
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.
|
||||
for (fcd.members) |m| switch (m) {
|
||||
|
||||
Reference in New Issue
Block a user