refactor(ffi-linkage): Phase 9.2b — rename runtime-class fns + state → runtime_* / is_reference
The runtime-class object-model identifiers (Decision 5): parse/lower/find/resolve/ register/stamp fns Foreign→Runtime (parseRuntimeClassDecl, lowerRuntimeMethodCall, findRuntimeMethodInChain, resolveRuntimeMethodReturnType, registerRuntimeClassDecl, runtimeClassStructType, runtimeKindForOffset, …); state foreign_class_map→ runtime_class_map, current_foreign_class/_method→current_runtime_*, the foreign_class_decl union variant→runtime_class_decl, foreign_method/static/instance/ class→runtime_*; and the reference-vs-define flag is_foreign→is_reference (+ is_foreign_eff→is_reference_eff) now that it only lives on RuntimeClassDecl. Snapshot-neutral; suite green (646/444). Remaining 9.2: the foreign_path family (coupled .sx hooks: jni_main_foreign_path_at spans build.sx/bundle.sx/compiler_hooks.zig/specs.md) + the extern-ref validators (checkForeignRefs etc. → Extern, linkage not runtime) + bare 'foreign' comments.
This commit is contained in:
@@ -389,7 +389,7 @@ test "lower: objcDefinedStateStructType collects user-declared fields" {
|
||||
.foreign_path = "SxFoo",
|
||||
.runtime = .objc_class,
|
||||
.members = &members,
|
||||
.is_foreign = false,
|
||||
.is_reference = false,
|
||||
.is_main = false,
|
||||
};
|
||||
|
||||
@@ -421,7 +421,7 @@ test "lower: objcDefinedStateStructType handles empty field set" {
|
||||
.foreign_path = "SxEmpty",
|
||||
.runtime = .objc_class,
|
||||
.members = &.{},
|
||||
.is_foreign = false,
|
||||
.is_reference = false,
|
||||
.is_main = false,
|
||||
};
|
||||
|
||||
@@ -453,7 +453,7 @@ test "lower: objcDefinedStateStructType skips non-field members" {
|
||||
.foreign_path = "SxMixed",
|
||||
.runtime = .objc_class,
|
||||
.members = &members,
|
||||
.is_foreign = false,
|
||||
.is_reference = false,
|
||||
.is_main = false,
|
||||
};
|
||||
|
||||
@@ -481,10 +481,10 @@ test "lower: objcTypeEncodingFromSignature emits @ for Obj-C class pointers" {
|
||||
.foreign_path = "NSString",
|
||||
.runtime = .objc_class,
|
||||
.members = &.{},
|
||||
.is_foreign = true,
|
||||
.is_reference = true,
|
||||
.is_main = false,
|
||||
};
|
||||
try lowering.program_index.foreign_class_map.put("NSString", &ns_fcd);
|
||||
try lowering.program_index.runtime_class_map.put("NSString", &ns_fcd);
|
||||
|
||||
// Return *NSString, no args: "@@:"
|
||||
const e1 = try lowering.objc().objcTypeEncodingFromSignature(ns_ptr, &.{}, null);
|
||||
@@ -514,10 +514,10 @@ test "lower: objcTypeEncodingFromSignature unwraps optional to wire type" {
|
||||
.foreign_path = "NSString",
|
||||
.runtime = .objc_class,
|
||||
.members = &.{},
|
||||
.is_foreign = true,
|
||||
.is_reference = true,
|
||||
.is_main = false,
|
||||
};
|
||||
try lowering.program_index.foreign_class_map.put("NSString", &ns_fcd);
|
||||
try lowering.program_index.runtime_class_map.put("NSString", &ns_fcd);
|
||||
|
||||
// `?i64 -> ?*NSString` collapses to `q -> @` at the Obj-C boundary.
|
||||
const opt_i64 = module.types.optionalOf(.i64);
|
||||
@@ -683,10 +683,10 @@ test "lower: isObjcClassPointer recognises pointer-to-foreign-Obj-C-class" {
|
||||
.foreign_path = "NSString",
|
||||
.runtime = .objc_class,
|
||||
.members = &.{},
|
||||
.is_foreign = true,
|
||||
.is_reference = true,
|
||||
.is_main = false,
|
||||
};
|
||||
try lowering.program_index.foreign_class_map.put("NSString", &ns_fcd);
|
||||
try lowering.program_index.runtime_class_map.put("NSString", &ns_fcd);
|
||||
try std.testing.expect(lowering.objc().isObjcClassPointer(ns_ptr));
|
||||
|
||||
// *NSCopying where NSCopying is a registered Obj-C *protocol* → also true
|
||||
@@ -699,10 +699,10 @@ test "lower: isObjcClassPointer recognises pointer-to-foreign-Obj-C-class" {
|
||||
.foreign_path = "NSCopying",
|
||||
.runtime = .objc_protocol,
|
||||
.members = &.{},
|
||||
.is_foreign = true,
|
||||
.is_reference = true,
|
||||
.is_main = false,
|
||||
};
|
||||
try lowering.program_index.foreign_class_map.put("NSCopying", &proto_fcd);
|
||||
try lowering.program_index.runtime_class_map.put("NSCopying", &proto_fcd);
|
||||
try std.testing.expect(lowering.objc().isObjcClassPointer(proto_ptr));
|
||||
|
||||
// *Plain where Plain is a non-foreign struct → false.
|
||||
@@ -731,10 +731,10 @@ test "lower: objcPropertyKind defaults + explicit ARC modifiers" {
|
||||
.foreign_path = "NSString",
|
||||
.runtime = .objc_class,
|
||||
.members = &.{},
|
||||
.is_foreign = true,
|
||||
.is_reference = true,
|
||||
.is_main = false,
|
||||
};
|
||||
try lowering.program_index.foreign_class_map.put("NSString", &ns_fcd);
|
||||
try lowering.program_index.runtime_class_map.put("NSString", &ns_fcd);
|
||||
|
||||
// Primitive field, no modifiers → assign (the non-object default).
|
||||
const prim = ast.RuntimeFieldDecl{ .name = "count", .field_type = typeKeyword(alloc, "i32"), .is_property = true };
|
||||
@@ -756,10 +756,10 @@ test "lower: objcPropertyKind defaults + explicit ARC modifiers" {
|
||||
.foreign_path = "NSCoding",
|
||||
.runtime = .objc_protocol,
|
||||
.members = &.{},
|
||||
.is_foreign = true,
|
||||
.is_reference = true,
|
||||
.is_main = false,
|
||||
};
|
||||
try lowering.program_index.foreign_class_map.put("NSCoding", &proto_fcd);
|
||||
try lowering.program_index.runtime_class_map.put("NSCoding", &proto_fcd);
|
||||
const proto_ty = typeKeyword(alloc, "*NSCoding");
|
||||
defer alloc.destroy(proto_ty);
|
||||
const proto_default = ast.RuntimeFieldDecl{ .name = "coder", .field_type = proto_ty, .is_property = true };
|
||||
|
||||
Reference in New Issue
Block a user