ffi 2.1: parser accepts Foo :: #jni_class("path") { } opaque form

New `hash_jni_class` token + lexer entry, `JniClassDecl` AST node
(alias + java path; body deferred to 2.2+), `parseJniClassDecl`
consuming `("...") { }` and rejecting non-empty bodies for now.
Sema registers the alias as a type_alias symbol; LSP classifies
the directive as a keyword. The 2.0 xfail snapshot flips to
`parse-only ok`, exit 0.

120/120 examples green; zig test clean.
This commit is contained in:
agra
2026-05-20 09:24:14 +03:00
parent 4c670e66f3
commit 32b464e959
8 changed files with 48 additions and 2 deletions

View File

@@ -81,6 +81,7 @@ pub const Node = struct {
protocol_decl: ProtocolDecl,
impl_block: ImplBlock,
ffi_intrinsic_call: FfiIntrinsicCall,
jni_class_decl: JniClassDecl,
pub fn declName(self: Data) ?[]const u8 {
return switch (self) {
@@ -94,6 +95,7 @@ pub const Node = struct {
.ufcs_alias => |d| d.name,
.c_import_decl => |d| d.name,
.protocol_decl => |d| d.name,
.jni_class_decl => |d| d.name,
else => null,
};
}
@@ -531,6 +533,12 @@ pub const ProtocolDecl = struct {
type_params: []const StructTypeParam = &.{}, // for `protocol(Target: Type) { ... }`
};
pub const JniClassDecl = struct {
name: []const u8, // sx-side alias (left of `::`)
java_path: []const u8, // directive arg, e.g. "java/path/Foo"
body: []const *Node = &.{}, // body items (methods, fields, #extends, ...) — empty in 2.1
};
pub const ImplBlock = struct {
protocol_name: []const u8,
target_type: []const u8,