Adds `examples/ffi-jni-call-04-jint-return.sx` exercising
`#jni_call(s32)(env, target, "getCount", "()I")` inside a runtime-
reachable but never-invoked helper (`g_should_call` stays false, so
the dereferences don't fire). Today the emit_llvm switch falls
through to `LLVMGetUndef` for any non-void return — the IR snapshot
captures that placeholder.
The next commit adds the `.s32 => 49` (CallIntMethod) arm. The
snapshot will update to show the full GetObjectClass → GetMethodID →
CallIntMethod sequence (reusing the slot interning landed in 1.17,
since `("getCount", "()I")` is a fresh literal pair).
27 lines
874 B
Plaintext
27 lines
874 B
Plaintext
// Phase 1 step 1.18 (PLAN-FFI.md): `#jni_call(s32)` (jint return).
|
|
// Today the lowering for any non-void return drops to `LLVMGetUndef`
|
|
// — the IR snapshot captures that placeholder. Step 1.18-fix wires
|
|
// the `.s32 => 49` (`CallIntMethod`) arm and the snapshot updates to
|
|
// show the full GetObjectClass + GetMethodID + CallIntMethod
|
|
// sequence (using the cache machinery landed in 1.17).
|
|
//
|
|
// Runtime: unreachable. Same `g_should_call` global pattern as
|
|
// `ffi-jni-call-03` — keeps `read_int` alive so the IR snapshot has
|
|
// the JNI lowering visible, but the dereferences never execute.
|
|
|
|
#import "modules/std.sx";
|
|
|
|
g_should_call : bool = false;
|
|
|
|
read_int :: (env: *void, target: *void) -> s32 {
|
|
#jni_call(s32)(env, target, "getCount", "()I");
|
|
}
|
|
|
|
main :: () -> s32 {
|
|
if g_should_call {
|
|
_ := read_int(null, null);
|
|
}
|
|
print("ok\n");
|
|
0;
|
|
}
|