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

@@ -359,12 +359,12 @@ pub const Compilation = struct {
return module;
}
/// Walk `lowering.program_index.foreign_class_map` and render Java sources for every
/// 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.
fn collectJniMainEmissions(self: *Compilation, lowering: *ir.Lowering) !void {
// `foreign_class_map` registers each decl under bare + qualified names —
// `runtime_class_map` registers each decl under bare + qualified names —
// dedupe by foreign_path so a single decl emits one .java.
var seen = std.StringHashMap(void).init(self.allocator);
defer seen.deinit();
@@ -373,7 +373,7 @@ pub const Compilation = struct {
// and `#extends Alias` resolution.
var registry = std.StringHashMap([]const u8).init(self.allocator);
defer registry.deinit();
var it_reg = lowering.program_index.foreign_class_map.iterator();
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);
}
@@ -384,11 +384,11 @@ pub const Compilation = struct {
// .so loading via another class.
const lib_name = libNameFromOutputPath(self.target_config.output_path);
var it = lowering.program_index.foreign_class_map.iterator();
var it = lowering.program_index.runtime_class_map.iterator();
while (it.next()) |entry| {
const fcd = entry.value_ptr.*;
if (!fcd.is_main) continue;
if (fcd.is_foreign) continue;
if (fcd.is_reference) continue;
if (fcd.runtime != .jni_class) continue;
if (seen.contains(fcd.foreign_path)) continue;
try seen.put(fcd.foreign_path, {});