refactor(ffi-linkage): Phase 9.2d — rename foreign_path → runtime_path (coupled .sx↔.zig↔hook)

The JNI/runtime-class path (Decision 5, Runtime* family). Coordinated across the
hook boundary so the BuildOptions accessor + its registered hook string stay in sync:
- src/: RuntimeClassDecl.foreign_path→runtime_path, splitForeignPath→splitRuntimePath,
  foreignPathToJavaName→runtimePathToJavaName, jni_main_foreign_paths→
  jni_main_runtime_paths, hookJniMainForeignPathAt→hookJniMainRuntimePathAt, and the
  hook string 'BuildOptions.jni_main_foreign_path_at'→'…runtime_path_at'.
- library/: build.sx accessor jni_main_foreign_path_at→jni_main_runtime_path_at +
  bundle.sx call sites + the  local var → runtime_path + a comment.
- specs.md: the accessor name + <foreign_path_with_dots> doc refs.
- Regenerated 37 .ir snapshots: every program importing build declares the renamed
  @BuildOptions.jni_main_runtime_path_at hook stub — symbol-name change only (verified
  the .ir diff is ONLY this rename; reverted orthogonal empty-file normalization).
Suite green (646 corpus / 444 unit, 0 failed).
This commit is contained in:
agra
2026-06-15 09:20:30 +03:00
parent a15a868391
commit 8cca3b9dde
53 changed files with 130 additions and 130 deletions

View File

@@ -297,11 +297,11 @@ pub fn lowerRuntimeMethodCall(
defer registry.deinit();
var it = self.program_index.runtime_class_map.iterator();
while (it.next()) |entry| {
registry.put(entry.key_ptr.*, entry.value_ptr.*.foreign_path) catch {};
registry.put(entry.key_ptr.*, entry.value_ptr.*.runtime_path) catch {};
}
const desc_str = jni_descriptor.deriveMethod(self.alloc, .{
.enclosing_path = fcd.foreign_path,
.enclosing_path = fcd.runtime_path,
.classes = &registry,
}, method) catch |err| {
if (self.diagnostics) |d| {
@@ -496,7 +496,7 @@ pub fn lowerObjcStaticCall(
// Load the class object from its module-scoped cached slot.
// `objc_getClass(<name>)` runs once at module-init via the
// constructor emit_llvm synthesizes (see `emitObjcClassInit`).
const class_slot_gid = self.internObjcClassObject(fcd.foreign_path);
const class_slot_gid = self.internObjcClassObject(fcd.runtime_path);
const class_slot_ptr = self.builder.emit(.{ .global_addr = class_slot_gid }, self.module.types.ptrTo(vptr_ty));
const class_obj = self.builder.emit(.{ .load = .{ .operand = class_slot_ptr } }, vptr_ty);
@@ -602,7 +602,7 @@ pub fn lowerRuntimeStaticCall(
defer registry.deinit();
var it = self.program_index.runtime_class_map.iterator();
while (it.next()) |entry| {
registry.put(entry.key_ptr.*, entry.value_ptr.*.foreign_path) catch {};
registry.put(entry.key_ptr.*, entry.value_ptr.*.runtime_path) catch {};
}
// For `new`, the JNI descriptor's return position is `V` (the
@@ -620,7 +620,7 @@ pub fn lowerRuntimeStaticCall(
};
const descriptor = jni_descriptor.deriveMethod(self.alloc, .{
.enclosing_path = fcd.foreign_path,
.enclosing_path = fcd.runtime_path,
.classes = &registry,
}, m_for_desc) catch |err| {
if (self.diagnostics) |d| d.addFmt(.err, span, "JNI descriptor derivation failed for '{s}.new': {s}", .{ fcd.name, @errorName(err) });
@@ -655,7 +655,7 @@ pub fn lowerRuntimeStaticCall(
.args = args_owned,
.is_static = false,
.is_constructor = true,
.parent_class_path = self.alloc.dupe(u8, fcd.foreign_path) catch fcd.foreign_path,
.parent_class_path = self.alloc.dupe(u8, fcd.runtime_path) catch fcd.runtime_path,
.cache_key = null,
} }, ret_ty);
}
@@ -684,13 +684,13 @@ pub fn lowerSuperCall(
return Ref.none;
};
// Resolve parent foreign_path from the fcd's `#extends`. Default to
// Resolve parent runtime_path from the fcd's `#extends`. Default to
// android.app.Activity to match the jni_java_emit default.
var parent_path: []const u8 = "android/app/Activity";
for (fcd.members) |m| switch (m) {
.extends => |alias| {
if (self.program_index.runtime_class_map.get(alias)) |parent_fcd| {
parent_path = parent_fcd.foreign_path;
parent_path = parent_fcd.runtime_path;
} else {
parent_path = alias;
}
@@ -735,7 +735,7 @@ pub fn lowerSuperCall(
defer registry.deinit();
var it = self.program_index.runtime_class_map.iterator();
while (it.next()) |entry| {
registry.put(entry.key_ptr.*, entry.value_ptr.*.foreign_path) catch {};
registry.put(entry.key_ptr.*, entry.value_ptr.*.runtime_path) catch {};
}
descriptor = jni_descriptor.deriveMethod(self.alloc, .{
.enclosing_path = parent_path,
@@ -822,14 +822,14 @@ pub fn registerRuntimeClassDecl(self: *Lowering, fcd: *const ast.RuntimeClassDec
/// `#objc_class` to the actual Obj-C runtime class name. Falls
/// back to "NSObject" when no `#extends` is declared.
/// Aliases that resolve to foreign Obj-C classes use the
/// foreign_path; aliases for OTHER sx-defined classes use the
/// runtime_path; aliases for OTHER sx-defined classes use the
/// alias name directly (which equals the Obj-C class name for
/// sx-defined classes).
pub fn resolveObjcParentName(self: *Lowering, fcd: *const ast.RuntimeClassDecl) []const u8 {
for (fcd.members) |m| switch (m) {
.extends => |alias| {
if (self.program_index.runtime_class_map.get(alias)) |parent_fcd| {
if (parent_fcd.is_extern) return parent_fcd.foreign_path;
if (parent_fcd.is_extern) return parent_fcd.runtime_path;
// Sx-defined parent — its alias IS its Obj-C name.
return parent_fcd.name;
}
@@ -1039,8 +1039,8 @@ pub fn synthesizeJniMainStubs(self: *Lowering) void {
if (!fcd.is_main) 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;
if (seen.contains(fcd.runtime_path)) continue;
seen.put(fcd.runtime_path, {}) catch continue;
for (fcd.members) |m| switch (m) {
.method => |md| {
@@ -1054,7 +1054,7 @@ pub fn synthesizeJniMainStubs(self: *Lowering) void {
}
pub fn synthesizeJniMainStub(self: *Lowering, fcd: *const ast.RuntimeClassDecl, md: ast.RuntimeMethodDecl) void {
const mangled = jni_descriptor.jniMangleNativeName(self.alloc, fcd.foreign_path, md.name) catch return;
const mangled = jni_descriptor.jniMangleNativeName(self.alloc, fcd.runtime_path, md.name) catch return;
const name_id = self.module.types.internString(mangled);
const ptr_void = self.module.types.ptrTo(.void);