docs+runner+parser: SSOT+AST using finalized (legacy text inlining removed); provider verify reads nyash.toml; preflight warn hook; method-body guard removed; CURRENT_TASK updated for next JSON work

This commit is contained in:
Selfhosting Dev
2025-09-26 00:27:02 +09:00
parent d9f26d4549
commit 85084664c2
77 changed files with 1259 additions and 1026 deletions

View File

@ -0,0 +1,26 @@
# E2E Tests Overview
Purpose
- Track end-to-end coverage with plugins and core features, both interpreter and VM.
HTTP (plugins)
- GET basic (VM): `e2e_vm_http_get_basic` → body `OK`
- POST + headers (VM): `e2e_vm_http_post_and_headers``201:V:R`
- Status 404 (VM): `e2e_vm_http_status_404``404:NF`
- Status 500 (VM): `e2e_vm_http_status_500``500:ERR`
- Client error (unreachable) (VM): `e2e_vm_http_client_error_result``Result.Err(ErrorBox)`
FileBox (plugins)
- Close returns void (Interp/VM)
- Open/Write/Read (VM): `e2e_vm_plugin_filebox_open_rw``HELLO`
- copyFrom(handle) (VM): `e2e_vm_plugin_filebox_copy_from_handle``HELLO`
MIR/VM Core
- Ref ops MIR build: `mir_phase6_lowering_ref_ops`
- Ref ops VM exec: `mir_phase6_vm_ref_ops`
- Async ops MIR/VM: `mir_phase7_async_ops`
Conventions
- Use distinct ports per test (8080+). Enable logs only on failure to keep CI output tidy.
- Plugins logs: `NYASH_NET_LOG=1 NYASH_NET_LOG_FILE=net_plugin.log`.

View File

@ -0,0 +1,75 @@
# Cranelift AOT Smoke (Windowsfirst)
Purpose
- Validate the Craneliftbased AOT pipeline endtoend:
1) Build `nyash` with `cranelift-jit` feature.
2) Emit an object via `NYASH_AOT_OBJECT_OUT` while running `--backend cranelift`.
3) Link the object with NyRT into a runnable binary (via LinkerBox or helper scripts).
4) Run the binary and assert output.
Prerequisites
- Build flags: `cargo build --release --features cranelift-jit`
- Windows:
- Prefer MSVC `link.exe` (Developer Command Prompt or properly set env).
- Fallback: `lld-link` in `PATH`.
- PowerShell available for `tools/aot_smoke_cranelift.ps1`.
- Unix (optional): system linker (`ld`), or `lld`/`mold`, and `tools/aot_smoke_cranelift.sh`.
Environment toggles
- `NYASH_CLIF_ARRAY_SMOKE=1`: run array smoke (simple Result check).
- `NYASH_CLIF_ARRAY_RET_SMOKE=1`: run “return value” array smoke.
- `NYASH_CLIF_ECHO_SMOKE=1`: run echo smoke (stdin → stdout).
- `NYASH_CLIF_VINVOKE_SMOKE=1`: run variablelength invoke smoke (plugins required).
- `NYASH_CLIF_VINVOKE_RET_SMOKE=1`: run vinvoke return/size smokes (plugins required).
- `NYASH_DISABLE_PLUGINS=1`: disable plugindependent smokes.
- `NYASH_LINK_VERBOSE=1`: print final link command.
Pseudo run
- Script: `tools/aot_smoke_cranelift.sh` / `tools/aot_smoke_cranelift.ps1`
- Typical invocation: `./tools/aot_smoke_cranelift.sh release`
Pseudo output (example)
```
[clif-aot-smoke] building nyash (release, feature=cranelift-jit)...
[clif-aot-smoke] emitting object via --backend cranelift ...
[clif-aot-smoke] OK: object generated: /ABS/path/target/aot_objects/core_smoke.obj (1536 bytes)
[clif-aot-smoke][win] linking app_clif.exe using link.exe
[clif-aot-smoke][win] entry=nyash_main subsystem=CONSOLE runtime=nyrt.lib
[clif-aot-smoke] running app_clif.exe ...
[clif-aot-smoke] output: Result: 3
[clif-aot-smoke] OK: core smoke passed
[clif-aot-smoke] skipping array smoke (set NYASH_CLIF_ARRAY_SMOKE=1 to enable)
[clif-aot-smoke] skipping echo smoke (set NYASH_CLIF_ECHO_SMOKE=1 to enable)
[clif-aot-smoke] skipping vinvoke smokes (set NYASH_CLIF_VINVOKE_SMOKE=1 / NYASH_CLIF_VINVOKE_RET_SMOKE=1)
```
What the script does (intended)
- Build:
- `cargo build --release --features cranelift-jit`
- Emit object:
- Ensure stable output dir: `mkdir -p target/aot_objects`
- `NYASH_AOT_OBJECT_OUT="$PWD/target/aot_objects/core_smoke.obj" ./target/release/nyash --backend cranelift apps/hello/main.nyash > /dev/null || true`
- Validate file exists and nonzero size.
- Link:
- Windows: PowerShell `tools/aot_smoke_cranelift.ps1 -Mode release`
- Unix: `tools/aot_smoke_cranelift.sh release`
- Run and verify:
- `./app_clif[.exe]` → expect a line including `Result:`.
Windows specifics
- Prefer MSVC `link.exe`; autofallback to `lld-link` if present.
- If neither available, fail with a helpful message to open a Developer Command Prompt or install LLVM lld.
- Use `.obj` extension for emitted object; still accept `.o` if emitted by a GNU toolchain.
Exit codes
- 0: all enabled smokes passed
- 1: object missing/empty, or unexpected program output
- 2: toolchain missing (no Cranelift build or no linker)
Future alignment with LinkerBox
- This smoke is the acceptance test for LinkerBoxs AOT path on Cranelift:
- Same entrypoint (`nyash_main`), runtime linkage (`nyrt.lib`/`libnyrt.a`), and CLI env (`NYASH_LINKER`, `NYASH_LINK_FLAGS`, `NYASH_LINK_VERBOSE`).
- When LinkerBox becomes default, keep CLI stable and swap implementation behind it.

View File

@ -0,0 +1,3 @@
🔌 v2 plugin system initialized from nyash.toml
✅ v2 plugin system fully configured
🚀 Nyash MIR Compiler - Processing file: local_tests/await_simple.nyash 🚀

View File

@ -0,0 +1,74 @@
🔌 v2 plugin system initialized from nyash.toml
✅ v2 plugin system fully configured
🚀 Nyash MIR Compiler - Processing file: local_tests/test_vm_array_getset.nyash 🚀
🚀 MIR Output for local_tests/test_vm_array_getset.nyash:
; MIR Module: main
; Module Statistics:
; Functions: 1
; Globals: 0
; Total Blocks: 1
; Total Instructions: 50
; Pure Functions: 1
define void @main() {
; Function Statistics:
; Blocks: 1
; Instructions: 50
; Values: 0
; Phi Functions: 0
; Pure: yes
bb0:
0: safepoint
1: %0 = const "__me__"
2: %1 = new ArrayBox()
3: call %1.birth()
4: ref_set %0.arr = %1
5: %2 = ref_get %0.arr
6: %3 = const 1
7: %4 = new IntegerBox(%3)
8: call %4.birth(%3)
9: %5 = call %2.push(%4)
10: %6 = ref_get %0.arr
11: %7 = const 2
12: %8 = new IntegerBox(%7)
13: call %8.birth(%7)
14: %9 = call %6.push(%8)
15: %10 = ref_get %0.arr
16: %11 = const 3
17: %12 = new IntegerBox(%11)
18: call %12.birth(%11)
19: %13 = call %10.push(%12)
20: %14 = ref_get %0.arr
21: %15 = const 1
22: %16 = new IntegerBox(%15)
23: call %16.birth(%15)
24: %17 = const 42
25: %18 = new IntegerBox(%17)
26: call %18.birth(%17)
27: %19 = call %14.set(%16, %18)
28: %23 = ref_get %0.arr
29: %24 = const 0
30: %25 = new IntegerBox(%24)
31: call %25.birth(%24)
32: %26 = call %23.get(%25)
33: %27 = ref_get %0.arr
34: %28 = const 1
35: %29 = new IntegerBox(%28)
36: call %29.birth(%28)
37: %30 = call %27.get(%29)
38: %31 = ref_get %0.arr
39: %32 = const 2
40: %33 = new IntegerBox(%32)
41: call %33.birth(%32)
42: %34 = call %31.get(%33)
43: %35 = call %26.toString()
44: print %35
45: %36 = call %30.toString()
46: print %36
47: %37 = call %34.toString()
48: print %37
49: ret %37
; effects: pure|io|read|write|alloc
}

View File

@ -0,0 +1,31 @@
🔌 v2 plugin system initialized from nyash.toml
✅ v2 plugin system fully configured
🚀 Nyash MIR Compiler - Processing file: local_tests/extern_console_log.nyash 🚀
🚀 MIR Output for local_tests/extern_console_log.nyash:
; MIR Module: main
; Module Statistics:
; Functions: 1
; Globals: 0
; Total Blocks: 1
; Total Instructions: 7
; Pure Functions: 1
define void @main() {
; Function Statistics:
; Blocks: 1
; Instructions: 7
; Values: 0
; Phi Functions: 0
; Pure: yes
bb0:
0: safepoint
1: %0 = const "ok"
2: %1 = new StringBox(%0)
3: call %1.birth(%0)
4: extern_call env.console.log(%1) [effects: io]
5: %2 = const void
6: ret %2
; effects: pure|io|read|alloc
}

View File

@ -0,0 +1,68 @@
🔌 v2 plugin system initialized from nyash.toml
✅ v2 plugin system fully configured
🚀 Nyash MIR Compiler - Processing file: local_tests/loop_nested_if_test.nyash 🚀
🚀 MIR Output for local_tests/loop_nested_if_test.nyash:
; MIR Module: main
; Module Statistics:
; Functions: 1
; Globals: 0
; Total Blocks: 7
; Total Instructions: 28
; Pure Functions: 1
define void @main() {
; Function Statistics:
; Blocks: 7
; Instructions: 28
; Values: 0
; Phi Functions: 2
; Pure: yes
bb0:
0: safepoint
1: %1 = const 0
2: %2 = new IntegerBox(%1)
3: call %2.birth(%1)
4: br label bb1
; effects: pure|read|alloc
bb1: ; preds(bb6)
0: %3 = phi [%2, bb0], [%13, bb6]
1: %4 = const 1
2: %5 = new IntegerBox(%4)
3: call %5.birth(%4)
4: %6 = icmp Lt %3, %5
5: br %6, label bb2, label bb3
; effects: pure|read|alloc
bb2:
0: safepoint
1: %7 = const true
2: %8 = new BoolBox(%7)
3: call %8.birth(%7)
4: br %8, label bb4, label bb5
; effects: pure|read|alloc
bb3:
0: %14 = const void
1: ret %14
bb4:
0: %9 = const 1
1: %10 = new IntegerBox(%9)
2: call %10.birth(%9)
3: br label bb6
; effects: pure|read|alloc
bb5:
0: %11 = const 2
1: %12 = new IntegerBox(%11)
2: call %12.birth(%11)
3: br label bb6
; effects: pure|read|alloc
bb6:
0: %13 = phi [%10, bb4], [%12, bb5]
1: br label bb1
}

View File

@ -0,0 +1,52 @@
🔌 v2 plugin system initialized from nyash.toml
✅ v2 plugin system fully configured
🚀 Nyash MIR Compiler - Processing file: local_tests/simple_loop_test.nyash 🚀
🚀 MIR Output for local_tests/simple_loop_test.nyash:
; MIR Module: main
; Module Statistics:
; Functions: 1
; Globals: 0
; Total Blocks: 4
; Total Instructions: 20
; Pure Functions: 1
define void @main() {
; Function Statistics:
; Blocks: 4
; Instructions: 20
; Values: 0
; Phi Functions: 1
; Pure: yes
bb0:
0: safepoint
1: %1 = const 0
2: %2 = new IntegerBox(%1)
3: call %2.birth(%1)
4: br label bb1
; effects: pure|read|alloc
bb1: ; preds(bb2)
0: %3 = phi [%2, bb0], [%9, bb2]
1: %4 = const 3
2: %5 = new IntegerBox(%4)
3: call %5.birth(%4)
4: %6 = icmp Lt %3, %5
5: br %6, label bb2, label bb3
; effects: pure|read|alloc
bb2:
0: safepoint
1: print %3
2: %7 = const 1
3: %8 = new IntegerBox(%7)
4: call %8.birth(%7)
5: %9 = %3 Add %8
6: br label bb1
; effects: pure|io|read|alloc
bb3:
0: %10 = const void
1: ret %10
}

View File

@ -0,0 +1,80 @@
🔌 v2 plugin system initialized from nyash.toml
✅ v2 plugin system fully configured
🚀 Nyash MIR Compiler - Processing file: local_tests/typeop_in_if_loop_poc.nyash 🚀
🚀 MIR Output for local_tests/typeop_in_if_loop_poc.nyash:
; MIR Module: main
; Module Statistics:
; Functions: 1
; Globals: 0
; Total Blocks: 7
; Total Instructions: 38
; Pure Functions: 1
define void @main() {
; Function Statistics:
; Blocks: 7
; Instructions: 38
; Values: 0
; Phi Functions: 3
; Pure: yes
; TypeOp: 2 (check: 2, cast: 0)
bb0:
0: safepoint
1: %1 = const 1
2: %2 = new IntegerBox(%1)
3: call %2.birth(%1)
4: %3 = typeop check %2 Integer
5: br %3, label bb1, label bb2
; effects: pure|read|alloc
bb1:
0: %4 = const "ok-if"
1: %5 = new StringBox(%4)
2: call %5.birth(%4)
3: print %5
4: br label bb3
; effects: pure|io|read|alloc
bb2:
0: %6 = const "ng-if"
1: %7 = new StringBox(%6)
2: call %7.birth(%6)
3: print %7
4: br label bb3
; effects: pure|io|read|alloc
bb3:
0: %8 = phi [%5, bb1], [%7, bb2]
1: %10 = const 0
2: %11 = new IntegerBox(%10)
3: call %11.birth(%10)
4: br label bb4
; effects: pure|read|alloc
bb4: ; preds(bb5)
0: %13 = phi [%2, bb3], [%13, bb5]
1: %12 = phi [%11, bb3], [%20, bb5]
2: %14 = const 1
3: %15 = new IntegerBox(%14)
4: call %15.birth(%14)
5: %16 = icmp Lt %12, %15
6: br %16, label bb5, label bb6
; effects: pure|read|alloc
bb5:
0: safepoint
1: %17 = typeop check %13 Integer
2: print %17
3: %18 = const 1
4: %19 = new IntegerBox(%18)
5: call %19.birth(%18)
6: %20 = %12 Add %19
7: br label bb4
; effects: pure|io|read|alloc
bb6:
0: %21 = const void
1: ret %21
}

View File

@ -0,0 +1,34 @@
🔌 v2 plugin system initialized from nyash.toml
✅ v2 plugin system fully configured
🚀 Nyash MIR Compiler - Processing file: local_tests/typeop_is_as_func_poc.nyash 🚀
🚀 MIR Output for local_tests/typeop_is_as_func_poc.nyash:
; MIR Module: main
; Module Statistics:
; Functions: 1
; Globals: 0
; Total Blocks: 1
; Total Instructions: 9
; Pure Functions: 1
define void @main() {
; Function Statistics:
; Blocks: 1
; Instructions: 9
; Values: 0
; Phi Functions: 0
; Pure: yes
; TypeOp: 2 (check: 1, cast: 1)
bb0:
0: safepoint
1: %1 = const 42
2: %2 = new IntegerBox(%1)
3: call %2.birth(%1)
4: %3 = typeop check %2 Integer
5: print %3
6: %4 = typeop cast %2 Integer
7: print %4
8: ret %4
; effects: pure|io|read|alloc
}

View File

@ -0,0 +1,38 @@
🔌 v2 plugin system initialized from nyash.toml
✅ v2 plugin system fully configured
🚀 Nyash MIR Compiler - Processing file: local_tests/typeop_is_as_poc.nyash 🚀
🚀 MIR Output for local_tests/typeop_is_as_poc.nyash:
; MIR Module: main
; Module Statistics:
; Functions: 1
; Globals: 0
; Total Blocks: 1
; Total Instructions: 13
; Pure Functions: 1
define void @main() {
; Function Statistics:
; Blocks: 1
; Instructions: 13
; Values: 0
; Phi Functions: 0
; Pure: yes
; TypeOp: 4 (check: 2, cast: 2)
bb0:
0: safepoint
1: %1 = const 7
2: %2 = new IntegerBox(%1)
3: call %2.birth(%1)
4: %3 = typeop check %2 Integer
5: print %3
6: %4 = typeop cast %2 Integer
7: print %4
8: %5 = typeop check %2 Integer
9: print %5
10: %6 = typeop cast %2 Integer
11: print %6
12: ret %6
; effects: pure|io|read|alloc
}

View File

@ -0,0 +1,57 @@
🔌 v2 plugin system initialized from nyash.toml
✅ v2 plugin system fully configured
🚀 Nyash MIR Compiler - Processing file: local_tests/typeop_mixed.nyash 🚀
🚀 MIR Output for local_tests/typeop_mixed.nyash:
; MIR Module: main
; Module Statistics:
; Functions: 1
; Globals: 0
; Total Blocks: 4
; Total Instructions: 24
; Pure Functions: 1
define void @main() {
; Function Statistics:
; Blocks: 4
; Instructions: 24
; Values: 0
; Phi Functions: 1
; Pure: yes
; TypeOp: 5 (check: 3, cast: 2)
bb0:
0: safepoint
1: %1 = const 1
2: %2 = new IntegerBox(%1)
3: call %2.birth(%1)
4: %3 = new IntegerBox(%2)
5: call %3.birth(%2)
6: %5 = typeop check %3 Integer
7: %7 = typeop cast %3 Integer
8: %9 = typeop check %3 Integer
9: %11 = typeop cast %3 Integer
10: %12 = typeop check %3 Integer
11: br %12, label bb1, label bb2
; effects: pure|read|alloc
bb1:
0: %13 = const 1
1: %14 = new IntegerBox(%13)
2: call %14.birth(%13)
3: print %14
4: br label bb3
; effects: pure|io|read|alloc
bb2:
0: %15 = const 0
1: %16 = new IntegerBox(%15)
2: call %16.birth(%15)
3: print %16
4: br label bb3
; effects: pure|io|read|alloc
bb3:
0: %17 = phi [%14, bb1], [%16, bb2]
1: ret %17
}