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:
agra
2026-06-15 09:01:04 +03:00
parent 3354446412
commit 5c8af6eb73
22 changed files with 205 additions and 205 deletions

View File

@@ -610,10 +610,10 @@ pub fn lowerCall(self: *Lowering, c_in: *const ast.Call) Ref {
// NewObject. Falls through to existing paths when no match.
if (fa.object.data == .identifier) {
const alias = fa.object.data.identifier.name;
if (self.program_index.foreign_class_map.get(alias)) |fcd| {
if (self.program_index.runtime_class_map.get(alias)) |fcd| {
for (fcd.members) |m| switch (m) {
.method => |md| if (md.is_static and std.mem.eql(u8, md.name, fa.field)) {
return self.lowerForeignStaticCall(fcd, md, args.items, c.callee.span);
return self.lowerRuntimeStaticCall(fcd, md, args.items, c.callee.span);
},
else => {},
};
@@ -896,9 +896,9 @@ pub fn lowerCall(self: *Lowering, c_in: *const ast.Call) Ref {
// (or its parallel forms). Routes to the JNI dispatch
// shape, descriptor derived from the sx signature.
const struct_name = self.getStructTypeName(obj_ty);
if (struct_name) |sname_for_foreign| {
if (self.program_index.foreign_class_map.get(sname_for_foreign)) |fcd| {
return self.lowerForeignMethodCall(fcd, fa.field, obj, args.items, c.callee.span);
if (struct_name) |sname_for_runtime| {
if (self.program_index.runtime_class_map.get(sname_for_runtime)) |fcd| {
return self.lowerRuntimeMethodCall(fcd, fa.field, obj, args.items, c.callee.span);
}
}
@@ -2237,17 +2237,17 @@ 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.):
// resolve the method from `foreign_class_map` walking `#extends`.
// 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
// enclosing fn's return type — which silently truncates `xx ptr`
// casts inside e.g. a `BOOL`-returning method body.
if (self.program_index.foreign_class_map.get(sname)) |fcd| {
if (self.findForeignMethodInChain(fcd, fa.field)) |found| {
if (self.program_index.runtime_class_map.get(sname)) |fcd| {
if (self.findRuntimeMethodInChain(fcd, fa.field)) |found| {
const md = found.method;
const saved_fc = self.current_foreign_class;
defer self.current_foreign_class = saved_fc;
self.current_foreign_class = found.fcd;
const saved_fc = self.current_runtime_class;
defer self.current_runtime_class = saved_fc;
self.current_runtime_class = found.fcd;
const user_param_start: usize = if (md.is_static) 0 else 1;
if (md.params.len > user_param_start) {
var types_list = std.ArrayList(TypeId).empty;