ffi 2.16a xfail: #jni_env(env) { body } block-form intrinsic

`#jni_env(synth_env) { ... }` should parse as a block-scoped env
intrinsic, today the lexer doesn't know the directive and the parser
errors at the `#` token in expression position. The make-green
follow-up adds the `hash_jni_env` lexer token, parser arm in
parsePrimary, AST node, and sema acceptance — body runs as a normal
block, env captured for later. TL push/pop semantics + optional env
in `#jni_call` land in 2.16b.
This commit is contained in:
agra
2026-05-20 10:32:56 +03:00
parent ca840ff6c8
commit 93adde5a3d
3 changed files with 23 additions and 0 deletions

View File

@@ -0,0 +1,21 @@
// Phase 2 step 2.16a (PLAN-FFI.md): xfail then green for the
// `#jni_env(env) { body }` block-form intrinsic.
//
// Scopes a JNIEnv* over a lexical block. Step 2.16a lands parser +
// AST + sema acceptance — the body runs as a normal block, the env
// arg is captured but not yet used at lowering. The TL push/pop
// semantics (step 2.16b) and lexical-direct resolution in `#jni_call`
// (step 2.16c) follow.
//
// Today the lexer doesn't recognise `#jni_env` and the parser errors
// at the unknown directive token.
#import "modules/std.sx";
main :: () -> s32 {
synth_env : *void = null;
#jni_env(synth_env) {
print("inside #jni_env scope\n");
}
0;
}

View File

@@ -0,0 +1 @@
1

View File

@@ -0,0 +1 @@
/Users/agra/projects/sx/examples/ffi-jni-env-01-block.sx:17:5: error: unexpected token in expression