`#jni_call(void)(target, "name", "sig")` (3 args before the first
string literal) should work inside an enclosing `#jni_env(env) { ... }`
scope, picking up the env from the block's value directly. Today's
lowering expects 4+ args and errors with "#jni_call requires env,
target, method name, and signature".
The make-green follow-up adds a lowering-side env stack maintained
across the `#jni_env` body walk, and a disambiguation in
`lowerJniCall` that detects "env omitted" via the position of the
first string-literal arg (method name at index 1 → omitted; at index
2 → explicit env).
31 lines
962 B
Plaintext
31 lines
962 B
Plaintext
// Phase 2 step 2.16b (PLAN-FFI.md): xfail then green for the
|
|
// lexical-direct env resolution inside a `#jni_env` scope.
|
|
//
|
|
// `#jni_call(T)(target, "name", "sig", args...)` — three args before
|
|
// the first string literal — has the env omitted. The lowering walks
|
|
// the in-progress AST visit stack to find the enclosing `#jni_env(env)`
|
|
// block and uses that env value directly as the IR-level env arg.
|
|
// No thread-local read, no per-call lookup; env stays register-
|
|
// resident across loop bodies (the hot-path optimisation).
|
|
//
|
|
// Today's lower expects 4+ args and errors when called with 3.
|
|
|
|
#import "modules/std.sx";
|
|
|
|
g_should_call : bool = false;
|
|
|
|
unused_jni :: (env: *void, target: *void) {
|
|
#jni_env(env) {
|
|
// Omitted env — env comes from the enclosing #jni_env scope.
|
|
#jni_call(void)(target, "noop", "()V");
|
|
}
|
|
}
|
|
|
|
main :: () -> s32 {
|
|
if g_should_call {
|
|
unused_jni(null, null);
|
|
}
|
|
print("ok\n");
|
|
0;
|
|
}
|