ffi 2.16a green: parser + AST + sema for #jni_env(env) { body }
New `hash_jni_env` lexer token; `parsePrimary` dispatches to a small
`parseJniEnvBlock` that consumes `(env) { body }` and returns a new
`JniEnvBlock` AST node (env_expr + body block).
Sema's analyzeNode arm recurses into env + body inside a pushed
scope; findNodeAtOffset descends through both children for go-to-
definition.
Lowering treats it as a syntactic wrapper around the block: env is
evaluated for side effects, body lowers as a normal block. The TL
push/pop semantics (synthesizing the env stack so `#jni_call`'s env
arg can become optional) land in 2.16b.
`expectSemicolonAfter` recognises `jni_env_block` as block-form so
statement-position uses don't need a trailing `;` — matches `if` /
`while` / `for` / bare blocks.
Test runs through the block body and prints expected output; xfail
snapshot flips to green. 127/127 examples green.
This commit is contained in:
@@ -82,6 +82,7 @@ pub const Node = struct {
|
||||
impl_block: ImplBlock,
|
||||
ffi_intrinsic_call: FfiIntrinsicCall,
|
||||
foreign_class_decl: ForeignClassDecl,
|
||||
jni_env_block: JniEnvBlock,
|
||||
|
||||
pub fn declName(self: Data) ?[]const u8 {
|
||||
return switch (self) {
|
||||
@@ -571,6 +572,11 @@ pub const ForeignClassDecl = struct {
|
||||
members: []const ForeignClassMember = &.{},
|
||||
};
|
||||
|
||||
pub const JniEnvBlock = struct {
|
||||
env: *Node, // expression yielding the *JNIEnv for this scope
|
||||
body: *Node, // block (or expression) — runs with `env` scoped via TL push/pop
|
||||
};
|
||||
|
||||
pub const ImplBlock = struct {
|
||||
protocol_name: []const u8,
|
||||
target_type: []const u8,
|
||||
|
||||
Reference in New Issue
Block a user