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

@@ -371,7 +371,7 @@ pub const ResolvedModule = struct {
/// symbol, not split into a duplicate `__stdinp.1`.
fn isPerSourceDecl(decl: *const Node) bool {
return switch (decl.data) {
.struct_decl, .enum_decl, .union_decl, .error_set_decl, .protocol_decl, .foreign_class_decl => true,
.struct_decl, .enum_decl, .union_decl, .error_set_decl, .protocol_decl, .runtime_class_decl => true,
.const_decl => |cd| cd.value.data != .fn_decl,
else => false,
};
@@ -463,7 +463,7 @@ pub const RawDeclRef = union(enum) {
union_decl: *const ast.UnionDecl,
error_set_decl: *const ast.ErrorSetDecl,
protocol_decl: *const ast.ProtocolDecl,
foreign_class_decl: *const ast.RuntimeClassDecl,
runtime_class_decl: *const ast.RuntimeClassDecl,
namespace_decl: *const ast.NamespaceDecl,
};
@@ -513,7 +513,7 @@ pub fn rawDeclRefOf(decl: *const Node) ?RawDeclRef {
.union_decl => |*d| .{ .union_decl = d },
.error_set_decl => |*d| .{ .error_set_decl = d },
.protocol_decl => |*d| .{ .protocol_decl = d },
.foreign_class_decl => |*d| .{ .foreign_class_decl = d },
.runtime_class_decl => |*d| .{ .runtime_class_decl = d },
.namespace_decl => |*d| .{ .namespace_decl = d },
else => null,
};
@@ -592,7 +592,7 @@ pub const DeclKind = enum {
@"union",
error_set,
protocol,
foreign_class,
runtime_class,
namespace,
};
@@ -606,7 +606,7 @@ fn declKindOf(ref: RawDeclRef) DeclKind {
.union_decl => .@"union",
.error_set_decl => .error_set,
.protocol_decl => .protocol,
.foreign_class_decl => .foreign_class,
.runtime_class_decl => .runtime_class,
.namespace_decl => .namespace,
};
}
@@ -815,9 +815,9 @@ fn stampFnBodySource(decl: *Node, file_path: []const u8) void {
// An sx-defined `#objc_class` / `#jni_class`: its IMP trampolines are
// emitted at lowering time (possibly from another module's context), so
// record the defining path AND stamp each method body (E4).
.foreign_class_decl => {
decl.data.foreign_class_decl.source_file = file_path;
stampForeignClassMethodSources(decl.data.foreign_class_decl, file_path);
.runtime_class_decl => {
decl.data.runtime_class_decl.source_file = file_path;
stampRuntimeClassMethodSources(decl.data.runtime_class_decl, file_path);
},
.const_decl => |cd| switch (cd.value.data) {
.fn_decl => |fd| fd.body.source_file = file_path,
@@ -827,9 +827,9 @@ fn stampFnBodySource(decl: *Node, file_path: []const u8) void {
// bodies need the defining path stamped just like a top-level fn.
.struct_decl => |sd| stampStructMethodSources(sd, file_path),
.protocol_decl => cd.value.data.protocol_decl.source_file = file_path,
.foreign_class_decl => {
cd.value.data.foreign_class_decl.source_file = file_path;
stampForeignClassMethodSources(cd.value.data.foreign_class_decl, file_path);
.runtime_class_decl => {
cd.value.data.runtime_class_decl.source_file = file_path;
stampRuntimeClassMethodSources(cd.value.data.runtime_class_decl, file_path);
},
else => {},
},
@@ -853,7 +853,7 @@ fn stampStructMethodSources(sd: ast.StructDecl, file_path: []const u8) void {
/// Stamp the defining module path onto every bodied method of an sx-defined
/// foreign class, so the method's sx body lowers in the class's own module.
fn stampForeignClassMethodSources(fcd: ast.RuntimeClassDecl, file_path: []const u8) void {
fn stampRuntimeClassMethodSources(fcd: ast.RuntimeClassDecl, file_path: []const u8) void {
for (fcd.members) |m| {
if (m == .method) {
if (m.method.body) |b| b.source_file = file_path;