ffi 2.7 green: parser accepts all seven type-introducer directive forms

Six new lexer tokens (`hash_jni_interface`, `hash_objc_class`,
`hash_objc_protocol`, `hash_swift_class`, `hash_swift_struct`,
`hash_swift_protocol`) join the existing `hash_jni_class`. All seven
share the body grammar from Phases 2.1–2.6.

AST refactored: `JniClassDecl` → `ForeignClassDecl` with a
`runtime: ForeignRuntime` enum discriminator; `JniMethodDecl` →
`ForeignMethodDecl` (with `jni_descriptor_override` renamed for
clarity since it's JNI-only); `JniFieldDecl` → `ForeignFieldDecl`;
`JniClassMember` → `ForeignClassMember`. AST variant renamed
`jni_class_decl` → `foreign_class_decl`.

`parseForeignClassDecl` takes the runtime as a parameter; the
`parseConstBinding` dispatch table now maps each of the seven
directive tokens to its `ForeignRuntime` variant via
`foreignRuntimeForCurrent`. No codegen yet — Phase 3 picks up Obj-C
runtime, Phase 4 picks up Swift. Runtime-specific body items (fields,
descriptor override) are validated at sema time in later steps.

126/126 examples green.
This commit is contained in:
agra
2026-05-20 10:15:10 +03:00
parent dc3821aeb0
commit 5fd8e0fbbe
8 changed files with 73 additions and 29 deletions

View File

@@ -907,8 +907,8 @@ pub const Analyzer = struct {
}
}
},
.jni_class_decl => |jd| {
try self.addSymbol(jd.name, .type_alias, null, node.span);
.foreign_class_decl => |fd| {
try self.addSymbol(fd.name, .type_alias, null, node.span);
},
.impl_block => |ib| {
// Each impl block gets its own scope so methods don't conflict across impls
@@ -1309,7 +1309,7 @@ pub fn findNodeAtOffset(node: *Node, offset: u32) ?*Node {
.tuple_type_expr,
.ufcs_alias,
.closure_type_expr,
.jni_class_decl,
.foreign_class_decl,
=> {},
.struct_decl => |sd| {
for (sd.methods) |method_node| {