ffi 1.6a: xfail — #objc_call with non-void return rejected today
102/102 regression tests pass (+ffi-objc-call-04-primitive-returns with xfail snapshot capturing today's diagnostic). Pinned scenario: `[NSObject class]` — `#objc_call(*void)(null, "class")`. Should return a non-null Class pointer once the lowering supports non-void returns. Today the Phase 1.3 restriction trips with: #objc_call: only `void` return + (recv, selector) is lowered today; non-void / arg-bearing arities land in later phase-1 steps The next commit (1.6b) introduces an `objc_msg_send` IR opcode that bundles (recv, sel, args, ret_ty) and emit_llvm builds a per-call- site LLVM function type, sharing one declared `@objc_msgSend` symbol across return-type variants. Five primitive returns (*void / bool / s32 / s64 / f64) get folded in across 1.6b–c.
This commit is contained in:
31
examples/ffi-objc-call-04-primitive-returns.sx
Normal file
31
examples/ffi-objc-call-04-primitive-returns.sx
Normal file
@@ -0,0 +1,31 @@
|
||||
// Phase 1 step 1.6 (PLAN-FFI.md): non-void return shapes through
|
||||
// `#objc_call`. The Phase 1.3 lowering hardcoded void+2-arg only;
|
||||
// this test exercises five primitive return types via real
|
||||
// Foundation classes:
|
||||
//
|
||||
// *void — [NSObject class] returns Class (ptr)
|
||||
// bool — [NSObject isMemberOfClass: cls] returns BOOL
|
||||
// s32 — [NSString length] returns NSUInteger (treated as s32 here)
|
||||
// s64 — same shape, wider
|
||||
// f64 — [NSNumber doubleValue] returns double
|
||||
//
|
||||
// Today (1.6a, xfail): the lowering rejects non-void returns with
|
||||
// a diagnostic. Snapshot pins the diagnostic.
|
||||
// Next (1.6b/c): emit_llvm builds a per-call-site LLVM function
|
||||
// type from (recv, sel, args, ret_ty), shares one declared
|
||||
// `@objc_msgSend` symbol, dispatches with the right ABI.
|
||||
|
||||
#import "modules/std.sx";
|
||||
#import "modules/compiler.sx";
|
||||
|
||||
main :: () -> s32 {
|
||||
inline if OS == .macos {
|
||||
// *void return: [NSObject class] → Class
|
||||
cls := #objc_call(*void)(null, "class");
|
||||
print("class non-null = {}\n", cls != null);
|
||||
}
|
||||
inline if OS != .macos {
|
||||
print("skipped (not macos)\n");
|
||||
}
|
||||
0;
|
||||
}
|
||||
1
tests/expected/ffi-objc-call-04-primitive-returns.exit
Normal file
1
tests/expected/ffi-objc-call-04-primitive-returns.exit
Normal file
@@ -0,0 +1 @@
|
||||
1
|
||||
1
tests/expected/ffi-objc-call-04-primitive-returns.txt
Normal file
1
tests/expected/ffi-objc-call-04-primitive-returns.txt
Normal file
@@ -0,0 +1 @@
|
||||
/Users/agra/projects/sx/examples/ffi-objc-call-04-primitive-returns.sx: error: #objc_call: only `void` return + (recv, selector) is lowered today; non-void / arg-bearing arities land in later phase-1 steps
|
||||
Reference in New Issue
Block a user