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

@@ -362,10 +362,10 @@ pub const Compilation = struct {
/// Walk `lowering.program_index.runtime_class_map` and render Java sources for every
/// `#jni_main #jni_class("...")` declaration. Renders happen here so the
/// AST + class-registry snapshot stay confined to the lowering pass; the
/// downstream APK pipeline only needs `{foreign_path, java_source}` pairs.
/// downstream APK pipeline only needs `{runtime_path, java_source}` pairs.
fn collectJniMainEmissions(self: *Compilation, lowering: *ir.Lowering) !void {
// `runtime_class_map` registers each decl under bare + qualified names —
// dedupe by foreign_path so a single decl emits one .java.
// dedupe by runtime_path so a single decl emits one .java.
var seen = std.StringHashMap(void).init(self.allocator);
defer seen.deinit();
@@ -375,7 +375,7 @@ pub const Compilation = struct {
defer registry.deinit();
var it_reg = lowering.program_index.runtime_class_map.iterator();
while (it_reg.next()) |entry| {
try registry.put(entry.key_ptr.*, entry.value_ptr.*.foreign_path);
try registry.put(entry.key_ptr.*, entry.value_ptr.*.runtime_path);
}
// Derive the `System.loadLibrary` argument from the `-o` basename
@@ -390,15 +390,15 @@ pub const Compilation = struct {
if (!fcd.is_main) continue;
if (fcd.is_extern) continue;
if (fcd.runtime != .jni_class) continue;
if (seen.contains(fcd.foreign_path)) continue;
try seen.put(fcd.foreign_path, {});
if (seen.contains(fcd.runtime_path)) continue;
try seen.put(fcd.runtime_path, {});
const java_source = try ir.jni_java_emit.emitJavaSource(self.allocator, fcd, .{
.classes = &registry,
.lib_name = lib_name,
});
try self.lowering_jni_main_decls.append(self.allocator, .{
.foreign_path = try self.allocator.dupe(u8, fcd.foreign_path),
.runtime_path = try self.allocator.dupe(u8, fcd.runtime_path),
.java_source = java_source,
});
}