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:
@@ -360,7 +360,7 @@ test "plan: foreign-class instance vs static dispatch" {
|
||||
.{ .method = .{ .name = "stringWithUTF8String", .params = &.{}, .param_names = &.{}, .return_type = typeExpr(alloc, "i64"), .is_static = true } },
|
||||
};
|
||||
var fcd = ast.RuntimeClassDecl{ .name = "NSString", .foreign_path = "NSString", .runtime = .objc_class, .members = &members };
|
||||
l.program_index.foreign_class_map.put("NSString", &fcd) catch unreachable;
|
||||
l.program_index.runtime_class_map.put("NSString", &fcd) catch unreachable;
|
||||
_ = module.types.intern(.{ .@"struct" = .{ .name = module.types.internString("NSString"), .fields = &.{} } });
|
||||
|
||||
// Instance: `cast(NSString, _).length` — receiver prepended.
|
||||
@@ -368,9 +368,9 @@ test "plan: foreign-class instance vs static dispatch" {
|
||||
const recv = callNode(alloc, ident(alloc, "cast"), &[_]*Node{ typeExpr(alloc, "NSString"), intLit(alloc, 0) });
|
||||
const call = callNode(alloc, fieldAccess(alloc, recv, "length"), &.{});
|
||||
const p = cr.plan(&call.data.call);
|
||||
try std.testing.expectEqual(CallPlan.Kind.foreign_instance, p.kind);
|
||||
try std.testing.expectEqualStrings("length", p.target.foreign_method.name);
|
||||
try std.testing.expect(!p.target.foreign_method.is_static);
|
||||
try std.testing.expectEqual(CallPlan.Kind.runtime_instance, p.kind);
|
||||
try std.testing.expectEqualStrings("length", p.target.runtime_method.name);
|
||||
try std.testing.expect(!p.target.runtime_method.is_static);
|
||||
try std.testing.expectEqual(TypeId.i64, p.return_type);
|
||||
try std.testing.expect(p.prepends_receiver);
|
||||
}
|
||||
@@ -378,9 +378,9 @@ test "plan: foreign-class instance vs static dispatch" {
|
||||
{
|
||||
const call = callNode(alloc, fieldAccess(alloc, ident(alloc, "NSString"), "stringWithUTF8String"), &.{});
|
||||
const p = cr.plan(&call.data.call);
|
||||
try std.testing.expectEqual(CallPlan.Kind.foreign_static, p.kind);
|
||||
try std.testing.expectEqualStrings("stringWithUTF8String", p.target.foreign_method.name);
|
||||
try std.testing.expect(p.target.foreign_method.is_static);
|
||||
try std.testing.expectEqual(CallPlan.Kind.runtime_static, p.kind);
|
||||
try std.testing.expectEqualStrings("stringWithUTF8String", p.target.runtime_method.name);
|
||||
try std.testing.expect(p.target.runtime_method.is_static);
|
||||
try std.testing.expect(!p.prepends_receiver);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user