`Lowering` gains a `jni_env_stack: ArrayList(Ref)`. When lowering the `jni_env_block` arm pushes the env_expr's Ref before lowering the body and pops after; `defer` ensures cleanup on early return. `lowerJniCall` now disambiguates explicit-vs-omitted env via the position of the first string-literal arg: at index 1 → omitted (3-arg form `target, "name", "sig"`), at index 2 → explicit (4-arg form `env, target, "name", "sig"`). Omitted form reads the top of `jni_env_stack`; missing scope → diagnostic. End-to-end test runs cleanly. Locked-in IR snapshot at `tests/expected/ffi-jni-env-02-lexical-direct.ir` shows env coming from the enclosing fn's `*void` param straight into the jni_msg_send expansion — no extra load, no thread-local read. The hot-path optimisation from the design discussion is now real. 128/128 examples + 1 new IR snapshot green; zig test clean.
2 lines
2 B
Plaintext
2 lines
2 B
Plaintext
0
|