Properties on sx-defined #objc_class declarations now synthesize
getter (always) and setter (unless 'readonly') IMPs that GEP into
the hidden state struct and load / store the corresponding field.
The state struct already holds every user-declared field
(objcDefinedStateStructType), so no new layout work — the IMPs
just dispatch a struct_gep + load/store through the __sx_state
ivar.
For each '#property' field on a sx-defined class:
Getter '__<Cls>_<field>_imp(self, _cmd) -> T':
state = object_getIvar(self, load(__<Cls>_state_ivar))
return state.<field>
Setter '__<Cls>_set<Field>_imp(self, _cmd, val) -> void':
state = object_getIvar(self, load(__<Cls>_state_ivar))
state.<field> = val
Both IMPs land in the cache's methods slice (mirroring the
method-IMP wiring from M1.2 A.4b.iii) so emit_llvm's
class_addMethod loop registers them on the class without
special-casing. Selector mangling:
getter: <field> (e.g. 'width')
setter: set<Field>: (e.g. 'setWidth:')
Type encoding derived from the field's resolved IR TypeId.
'readonly' (the only modifier honored in this slice) skips the
setter emission AND the corresponding method entry — so the
runtime reports the selector as absent. Other modifiers
(strong, weak, copy, assign) parse fine but stay no-ops until
M4.2 wires up ARC ops in the setter body.
152-objc-property-sx-defined.sx round-trips on macOS:
b.width = 10; b.height = 7;
read back through getter IMPs.
area is readonly — class_getInstanceMethod(SxBox, sel(setArea:))
returns NULL, confirming the setter is absent.
182 example tests pass (+1). zig build test green.