Files
sx/examples/1309-ffi-objc-class-method-lowering.sx
agra d8076b9333 lang: rename signed integer types sN -> iN
Surface rename of the signed integer family: s1..s64 become i1..i64
(u1..u64, usize, isize unchanged). 'string' keeps the s-prefix arm in
name classification; width parsing moves to the i-prefix arm next to
isize.

Internal TypeId tags follow the surface (.s8/.s16/.s32/.s64 ->
.i8/.i16/.i32/.i64), as do mono-key mangle fragments (ptr_i64,
tu_i64_bool) and all display/diagnostic formatting (i{d}).

Migrated in the same sweep: stdlib + examples + issue repros + FFI C
companions (shared symbol names like ffi_id_i64), expected
stdout/stderr/ir snapshots, specs.md, readme.md, CLAUDE.md/AGENTS.md,
implementation_plan.md, docs/, issue writeups. Vendored stb_image and
historical flow state left untouched.

zig build test: 426/426; examples suite: 595/595.
2026-06-12 09:31:53 +03:00

43 lines
1.3 KiB
Plaintext

// M1.2 A.2c / A.3 — instance-method body lowering on sx-defined
// `#objc_class`.
//
// The Obj-C runtime invokes class methods via the IMP pointers
// wired up in M1.2 A.4. No sx-side call path drives lazy lowering,
// so the eager pass `lowerObjcDefinedClassMethods` walks the
// `objc_defined_class_cache` and force-lowers every bodied method
// after Pass 1 finishes.
//
// `*Self` substitution (A.2b) routes the param's pointee type to
// the hidden state-struct `__<ClassName>State`. `self.counter`
// then resolves as a plain struct field access — A.3's "free if
// types align". The IR snapshot pins the round-trip:
//
// define internal void @SxFoo.bump(ptr __sx_ctx, ptr self) {
// %gep = getelementptr inbounds { i32 }, ptr %self, 0, 0
// %v = load i32, ptr %gep
// %inc = add i32 %v, 1
// store i32 %inc, ptr %gep
// ret void
// }
//
// IMP-trampoline emission (the C-ABI shim that the Obj-C runtime
// calls and that reads the `__sx_state` ivar) lands separately
// in M1.2 A.4 alongside class-pair init. Runtime dispatch
// (M1.2 A.7) stays gated until then.
#import "modules/std.sx";
#import "modules/build.sx";
SxFoo :: #objc_class("SxFoo") {
counter: i32;
bump :: (self: *Self) {
self.counter += 1;
}
}
main :: () -> i32 {
print("compiled\n");
0
}