From 082ef430a325e91dddd44625c8524073e3e217d5 Mon Sep 17 00:00:00 2001 From: agra Date: Wed, 20 May 2026 09:31:23 +0300 Subject: [PATCH] ffi 2.3 xfail: `static` method body item in `#jni_class` `Math :: #jni_class("java/lang/Math") { static abs :: (n: s32) -> s32; }` should parse, today's 2.2 parser treats `static` as a plain identifier and errors at the following `abs`. The make-green follow-up adds a `static` keyword recognition step in the body loop and an `is_static` flag on `JniMethodDecl`. --- examples/ffi-jni-class-03-static.sx | 19 +++++++++++++++++++ tests/expected/ffi-jni-class-03-static.exit | 1 + tests/expected/ffi-jni-class-03-static.txt | 1 + 3 files changed, 21 insertions(+) create mode 100644 examples/ffi-jni-class-03-static.sx create mode 100644 tests/expected/ffi-jni-class-03-static.exit create mode 100644 tests/expected/ffi-jni-class-03-static.txt diff --git a/examples/ffi-jni-class-03-static.sx b/examples/ffi-jni-class-03-static.sx new file mode 100644 index 0000000..040b660 --- /dev/null +++ b/examples/ffi-jni-class-03-static.sx @@ -0,0 +1,19 @@ +// Phase 2 step 2.3 (PLAN-FFI.md): xfail then green for the `static` +// method body item inside a `#jni_class` declaration. +// +// `static name :: (args...) -> Ret;` declares a class/static method — +// no implicit `self`, dispatched via `GetStaticMethodID` / `CallStatic*` +// at lowering time (Phase 2.12). Step 2.3 extends `parseJniClassDecl` +// to recognise the `static` prefix and mark the resulting +// `JniMethodDecl` with `is_static = true`. + +#import "modules/std.sx"; + +Math :: #jni_class("java/lang/Math") { + static abs :: (n: s32) -> s32; +} + +main :: () -> s32 { + print("parse-only ok\n"); + 0; +} diff --git a/tests/expected/ffi-jni-class-03-static.exit b/tests/expected/ffi-jni-class-03-static.exit new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/tests/expected/ffi-jni-class-03-static.exit @@ -0,0 +1 @@ +1 diff --git a/tests/expected/ffi-jni-class-03-static.txt b/tests/expected/ffi-jni-class-03-static.txt new file mode 100644 index 0000000..8c068a4 --- /dev/null +++ b/tests/expected/ffi-jni-class-03-static.txt @@ -0,0 +1 @@ +/Users/agra/projects/sx/examples/ffi-jni-class-03-static.sx:13:12: error: expected '::'