refactor(ffi-linkage): Phase 9.2a — rename runtime-class TYPE names → Runtime* (Decision 5)
Mechanical, collision-free PascalCase renames (object-model axis, not linkage): ForeignClassDecl→RuntimeClassDecl, ForeignMethodDecl→RuntimeMethodDecl, ForeignClassMember→RuntimeClassMember, ForeignFieldDecl→RuntimeFieldDecl, ForeignRuntime→RuntimeKind, ForeignClassPrefix→RuntimeClassPrefix. Snapshot-neutral; suite green (646/444). Remaining 9.2: snake_case state (foreign_class_map, current_foreign_class, foreign_path [coupled to .sx hooks], the foreign_class_decl union variant) + the parse/lower/resolve fn names + ForeignClassDecl.is_foreign flag.
This commit is contained in:
@@ -56,8 +56,8 @@ pub fn lowerObjcDefinedClassMethods(self: *Lowering) void {
|
||||
/// If `obj_expr` is typed as a pointer to a foreign Obj-C class
|
||||
/// and that class (or any of its `#extends` ancestors) declares a
|
||||
/// `#property` field with the given name, return the
|
||||
/// `ForeignFieldDecl`. M2.2 + M2.3.
|
||||
pub fn lookupObjcPropertyOnPointer(self: *Lowering, obj_expr: *const ast.Node, field_name: []const u8) ?ast.ForeignFieldDecl {
|
||||
/// `RuntimeFieldDecl`. M2.2 + M2.3.
|
||||
pub fn lookupObjcPropertyOnPointer(self: *Lowering, obj_expr: *const ast.Node, field_name: []const u8) ?ast.RuntimeFieldDecl {
|
||||
const obj_ty = self.inferExprType(obj_expr);
|
||||
if (obj_ty.isBuiltin()) return null;
|
||||
const ptr_info = self.module.types.get(obj_ty);
|
||||
@@ -74,8 +74,8 @@ pub fn lookupObjcPropertyOnPointer(self: *Lowering, obj_expr: *const ast.Node, f
|
||||
/// Returns the owning fcd + the method decl, or null if no ancestor
|
||||
/// declares it. Depth-capped at 16 to break accidental cycles
|
||||
/// (real Obj-C class chains rarely exceed 6 levels).
|
||||
pub fn findForeignMethodInChain(self: *Lowering, fcd: *const ast.ForeignClassDecl, method_name: []const u8) ?struct { fcd: *const ast.ForeignClassDecl, method: ast.ForeignMethodDecl } {
|
||||
var current: *const ast.ForeignClassDecl = fcd;
|
||||
pub fn findForeignMethodInChain(self: *Lowering, fcd: *const ast.RuntimeClassDecl, method_name: []const u8) ?struct { fcd: *const ast.RuntimeClassDecl, method: ast.RuntimeMethodDecl } {
|
||||
var current: *const ast.RuntimeClassDecl = fcd;
|
||||
var depth: u32 = 0;
|
||||
while (depth < 16) : (depth += 1) {
|
||||
for (current.members) |m| switch (m) {
|
||||
@@ -97,8 +97,8 @@ pub fn findForeignMethodInChain(self: *Lowering, fcd: *const ast.ForeignClassDec
|
||||
|
||||
/// Walk the `#extends` chain looking for a `#property` field by
|
||||
/// name. M2.3 companion to findForeignMethodInChain.
|
||||
pub fn findForeignPropertyInChain(self: *Lowering, fcd: *const ast.ForeignClassDecl, field_name: []const u8) ?ast.ForeignFieldDecl {
|
||||
var current: *const ast.ForeignClassDecl = fcd;
|
||||
pub fn findForeignPropertyInChain(self: *Lowering, fcd: *const ast.RuntimeClassDecl, field_name: []const u8) ?ast.RuntimeFieldDecl {
|
||||
var current: *const ast.RuntimeClassDecl = fcd;
|
||||
var depth: u32 = 0;
|
||||
while (depth < 16) : (depth += 1) {
|
||||
for (current.members) |m| switch (m) {
|
||||
@@ -121,7 +121,7 @@ const ObjcDefinedStateField = struct {
|
||||
field_ty: TypeId,
|
||||
state_ty: TypeId,
|
||||
field_idx: u32,
|
||||
fcd: *const ast.ForeignClassDecl,
|
||||
fcd: *const ast.RuntimeClassDecl,
|
||||
};
|
||||
|
||||
/// State-field-access info: if obj_expr is *<sx-defined-class>
|
||||
@@ -190,7 +190,7 @@ pub fn lowerObjcDefinedStateFieldRead(
|
||||
|
||||
/// `state = object_getIvar(obj, load(__<Cls>_state_ivar))`. Shared
|
||||
/// helper for state-field read + write (M1.2 A.3).
|
||||
pub fn lowerObjcDefinedStateForObj(self: *Lowering, obj_ref: Ref, fcd: *const ast.ForeignClassDecl) ?Ref {
|
||||
pub fn lowerObjcDefinedStateForObj(self: *Lowering, obj_ref: Ref, fcd: *const ast.RuntimeClassDecl) ?Ref {
|
||||
const ptr_void = self.module.types.ptrTo(.void);
|
||||
const ivar_global_name = std.fmt.allocPrint(self.alloc, "__{s}_state_ivar", .{fcd.name}) catch return null;
|
||||
defer self.alloc.free(ivar_global_name);
|
||||
@@ -207,7 +207,7 @@ pub fn lowerObjcDefinedStateForObj(self: *Lowering, obj_ref: Ref, fcd: *const as
|
||||
/// Lower `obj.field` for an Obj-C `#property` field as
|
||||
/// `objc_msg_send(obj, sel_<fieldName>)`. M2.2 — getter side.
|
||||
/// The setter side lives in the assignment-statement lowering.
|
||||
pub fn lowerObjcPropertyGetter(self: *Lowering, obj_expr: *const ast.Node, field: ast.ForeignFieldDecl, _: []const u8, _: ast.Span) Ref {
|
||||
pub fn lowerObjcPropertyGetter(self: *Lowering, obj_expr: *const ast.Node, field: ast.RuntimeFieldDecl, _: []const u8, _: ast.Span) Ref {
|
||||
const obj_ref = self.lowerExpr(obj_expr);
|
||||
const ret_ty = self.resolveType(field.field_type);
|
||||
const vptr_ty = self.module.types.ptrTo(.void);
|
||||
@@ -228,7 +228,7 @@ pub fn lowerObjcPropertyGetter(self: *Lowering, obj_expr: *const ast.Node, field
|
||||
/// `objc_msg_send(obj, sel_set<Field>:, val)`. M2.2 — setter side.
|
||||
/// Selector: prepend "set", capitalize the first letter of the
|
||||
/// field name, append ":". `backgroundColor` → `setBackgroundColor:`.
|
||||
pub fn lowerObjcPropertySetter(self: *Lowering, obj_expr: *const ast.Node, field: ast.ForeignFieldDecl, val: Ref) void {
|
||||
pub fn lowerObjcPropertySetter(self: *Lowering, obj_expr: *const ast.Node, field: ast.RuntimeFieldDecl, val: Ref) void {
|
||||
const obj_ref = self.lowerExpr(obj_expr);
|
||||
const vptr_ty = self.module.types.ptrTo(.void);
|
||||
|
||||
@@ -361,7 +361,7 @@ pub fn ensureArcRuntimeDecls(self: *Lowering) void {
|
||||
/// Both IMPs land in the cache's methods slice with appropriate
|
||||
/// selectors + encodings; emit_llvm's class_addMethod loop wires
|
||||
/// them up like any other instance method.
|
||||
pub fn emitObjcDefinedClassPropertyImps(self: *Lowering, fcd: *const ast.ForeignClassDecl, field: ast.ForeignFieldDecl) void {
|
||||
pub fn emitObjcDefinedClassPropertyImps(self: *Lowering, fcd: *const ast.RuntimeClassDecl, field: ast.RuntimeFieldDecl) void {
|
||||
const state_ty = self.objc().objcDefinedStateStructType(fcd);
|
||||
const state_info = self.module.types.get(state_ty);
|
||||
if (state_info != .@"struct") return;
|
||||
@@ -404,7 +404,7 @@ pub fn emitObjcDefinedClassPropertyImps(self: *Lowering, fcd: *const ast.Foreign
|
||||
self.registerObjcDefinedPropertyMethodEntries(fcd, field, field_ty, is_readonly);
|
||||
}
|
||||
|
||||
pub fn emitObjcDefinedPropertyGetter(self: *Lowering, fcd: *const ast.ForeignClassDecl, field: ast.ForeignFieldDecl, state_ty: TypeId, fidx: u32, field_ty: TypeId) void {
|
||||
pub fn emitObjcDefinedPropertyGetter(self: *Lowering, fcd: *const ast.RuntimeClassDecl, field: ast.RuntimeFieldDecl, state_ty: TypeId, fidx: u32, field_ty: TypeId) void {
|
||||
const saved_func = self.builder.func;
|
||||
const saved_block = self.builder.current_block;
|
||||
const saved_counter = self.builder.inst_counter;
|
||||
@@ -484,7 +484,7 @@ pub fn emitObjcDefinedPropertyGetter(self: *Lowering, fcd: *const ast.ForeignCla
|
||||
self.builder.finalize();
|
||||
}
|
||||
|
||||
pub fn emitObjcDefinedPropertySetter(self: *Lowering, fcd: *const ast.ForeignClassDecl, field: ast.ForeignFieldDecl, state_ty: TypeId, fidx: u32, field_ty: TypeId) void {
|
||||
pub fn emitObjcDefinedPropertySetter(self: *Lowering, fcd: *const ast.RuntimeClassDecl, field: ast.RuntimeFieldDecl, state_ty: TypeId, fidx: u32, field_ty: TypeId) void {
|
||||
const saved_func = self.builder.func;
|
||||
const saved_block = self.builder.current_block;
|
||||
const saved_counter = self.builder.inst_counter;
|
||||
@@ -610,7 +610,7 @@ pub fn emitObjcDefinedPropertySetter(self: *Lowering, fcd: *const ast.ForeignCla
|
||||
/// entries to the class's method-registration slice so emit_llvm
|
||||
/// calls class_addMethod on each. Selectors + encodings derived
|
||||
/// from the field type.
|
||||
pub fn registerObjcDefinedPropertyMethodEntries(self: *Lowering, fcd: *const ast.ForeignClassDecl, field: ast.ForeignFieldDecl, field_ty: TypeId, is_readonly: bool) void {
|
||||
pub fn registerObjcDefinedPropertyMethodEntries(self: *Lowering, fcd: *const ast.RuntimeClassDecl, field: ast.RuntimeFieldDecl, field_ty: TypeId, is_readonly: bool) void {
|
||||
const cur = self.module.lookupObjcDefinedClass(fcd.name) orelse return;
|
||||
_ = cur;
|
||||
// Find the existing entry and grow its methods slice.
|
||||
@@ -665,7 +665,7 @@ pub fn registerObjcDefinedPropertyMethodEntries(self: *Lowering, fcd: *const ast
|
||||
self.module.setObjcDefinedClassMethods(fcd.name, slice);
|
||||
}
|
||||
|
||||
pub fn emitObjcDefinedClassImp(self: *Lowering, fcd: *const ast.ForeignClassDecl, md: ast.ForeignMethodDecl) void {
|
||||
pub fn emitObjcDefinedClassImp(self: *Lowering, fcd: *const ast.RuntimeClassDecl, md: ast.RuntimeMethodDecl) void {
|
||||
// Class methods (no `*Self` first param) skip the ivar read —
|
||||
// they have no instance state to thread through.
|
||||
if (md.is_static) {
|
||||
@@ -800,7 +800,7 @@ pub fn emitObjcDefinedClassImp(self: *Lowering, fcd: *const ast.ForeignClassDecl
|
||||
/// `current_ctx_ref` as the ctx — so `push Context.{ allocator = ... }`
|
||||
/// flows through to per-instance allocator capture without going via
|
||||
/// the IMP.
|
||||
pub fn emitObjcDefinedClassAllocImp(self: *Lowering, fcd: *const ast.ForeignClassDecl) void {
|
||||
pub fn emitObjcDefinedClassAllocImp(self: *Lowering, fcd: *const ast.RuntimeClassDecl) void {
|
||||
const saved_func = self.builder.func;
|
||||
const saved_block = self.builder.current_block;
|
||||
const saved_counter = self.builder.inst_counter;
|
||||
@@ -858,7 +858,7 @@ pub fn emitObjcDefinedClassAllocImp(self: *Lowering, fcd: *const ast.ForeignClas
|
||||
/// missing (compiler bug — should be impossible after scan pass).
|
||||
pub fn emitObjcDefinedAllocAndInit(
|
||||
self: *Lowering,
|
||||
fcd: *const ast.ForeignClassDecl,
|
||||
fcd: *const ast.RuntimeClassDecl,
|
||||
cls_ref: Ref,
|
||||
ctx_addr: Ref,
|
||||
) ?Ref {
|
||||
@@ -953,7 +953,7 @@ pub fn emitObjcDefinedAllocAndInit(
|
||||
/// ret <result>
|
||||
///
|
||||
/// No ivar read — class methods have no per-instance state.
|
||||
pub fn emitObjcDefinedClassStaticImp(self: *Lowering, fcd: *const ast.ForeignClassDecl, md: ast.ForeignMethodDecl) void {
|
||||
pub fn emitObjcDefinedClassStaticImp(self: *Lowering, fcd: *const ast.RuntimeClassDecl, md: ast.RuntimeMethodDecl) void {
|
||||
const saved_func = self.builder.func;
|
||||
const saved_block = self.builder.current_block;
|
||||
const saved_counter = self.builder.inst_counter;
|
||||
@@ -1050,7 +1050,7 @@ pub fn emitObjcDefinedClassStaticImp(self: *Lowering, fcd: *const ast.ForeignCla
|
||||
/// +alloc time (M4.0a + M4.0b). Reading it back lets -dealloc free
|
||||
/// through the same allocator the instance was constructed with —
|
||||
/// the per-instance allocator design from M1.2 A.5, now realised.
|
||||
pub fn emitObjcDefinedClassDeallocImp(self: *Lowering, fcd: *const ast.ForeignClassDecl) void {
|
||||
pub fn emitObjcDefinedClassDeallocImp(self: *Lowering, fcd: *const ast.RuntimeClassDecl) void {
|
||||
const saved_func = self.builder.func;
|
||||
const saved_block = self.builder.current_block;
|
||||
const saved_counter = self.builder.inst_counter;
|
||||
|
||||
Reference in New Issue
Block a user