runner: add NyVM wrapper core_bridge (canonicalize/dump) + opt-in wrapper canary; export module in common_util

This commit is contained in:
nyash-codex
2025-11-01 02:51:49 +09:00
parent 5597b78f0d
commit 978bb4a5c6
25 changed files with 604 additions and 27 deletions

View File

@ -0,0 +1,9 @@
# CHECKLIST — Phase 20.33 (StageB)
- [x] StageB 専用エントリ(`lang/src/compiler/entry/compiler_stageb.hako`)を追加。`--prefer-cfg` を受理。
- [x] `ParserBox.parse_program2` → AST JSON を取得Quiet: 1行。StageA map parser は空/空白/エスケープに対応。
- [x] pipeline_v2 FlowEntry.emit_v0_from_ast で v0 を出力prefer_cfg=1 既定)。
- [x] selfhost canaryreturn/binop/if/indexを StageB でも PASSoptin `SMOKES_ENABLE_STAGEB=1` で緑)。
- [ ] v1→v0 降格MirJsonV1Adapter経路を整備必要箇所のみ
- [x] tools/smokes/v2/profiles/quick/core/selfhost_* を追加optin。配列ネスト/境界ケースを含む。
- [x] ドキュメント更新README/PLAN/CHECKLIST

View File

@ -0,0 +1,33 @@
# PLAN — Phase 20.33 (Hakorune コンパイラ StageB)
## ゴール(概要)
- Hako 製コンパイラを StageB に引き上げ、Ny → JSON v0 を実用レベルで安定出力。
- 入口を `ParserBox → pipeline_v2(FlowEntry)` に統一し、1 行 JSONQuiet契約を維持。
- 代表構文return/binop/compare/if/index/new/boxcall/externcallを優先対応。
## フェーズ分割
1) 入口統合StageB ルートの optin 実装)
- `lang/src/compiler/entry/compiler_stageb.hako` を追加(既定: StageB emit 専用)。
- `ParserBox.parse_program2(src)``FlowEntryBox.emit_v0_from_ast(ast_json, prefer_cfg)` → print 1 行 JSON。
- フラグ: `--prefer-cfg <N>` で pipeline 選好を切替できるようにする。
2) 代表構文の緑化
- binop/compare/if/index/new/boxcall/externcall を pipeline_v2 で受理できるよう確認。
- StageA canary と同等の selfhost canary を StageB でも PASS。
- StageA 側の map parser空/空白/エスケープを強化し、StageB 引受け前の入力を安定化。
3) v1→v0 アダプタの橋渡し
- MirCall(v1) を出す経路は `MirJsonV1Adapter` で v0 に降格。
- JSON 形状の差分を最小化し、Runner/VM と整合を取る。
4) スモーク整備optin
- `tools/smokes/v2/profiles/quick/core/selfhost_*` を追加し、GateC 直行と Runner 経由の両方で緑を確認。
- StageB canary (binop/if/index) に配列ネスト・境界ケースを追加。`SMOKES_ENABLE_STAGEB=1` でのみ実行。
5) ドキュメント更新
- README/PLAN/CHECKLIST を適宜更新。CI 既定は変更せず既定OFF
## トグル/フラグdev
- `--stage-b`entry 直下で StageB パスを有効化)
- オプション:`--prefer-cfg {0|1|2}`(未指定は 1
## 受け入れ基準
- selfhost canaryStageB: return/binop/if/index が緑GateC
- ny-llvmc の最小ケースreturn/binopで v0→EXE 生成が PASS。
- 既定 OFF のため、quick/integration の回帰なし。

View File

@ -23,11 +23,17 @@
- v1 互換: MirCallv1→ MirJsonV1Adapter で v0 に降格(当面の橋渡し)
受け入れ基準
- JSON v0 canaryHako: return/binop/if/indexarray/map緑。
- JSON v0 canaryHako: return/binop/if/indexarray/map/whitespace)緑。
- RunnerGateCで v0 を読み VM 実行 → Rust ラインと同じ出力。
- ny-llvmcllvmliteで v0→EXE 生成が最小ケースで PASS。
- 既定 OFF のため quick/integration は回帰なし。
実装メモ
- StageB エントリを `lang/src/compiler/entry/compiler_stageb.hako` として分離。`--source` / `--prefer-cfg {0|1|2}` を受理。
- StageA map parser を強化(空/空白/エスケープ対応)。対応済み canary: `index_operator_hako`
- StageB canary は `SMOKES_ENABLE_STAGEB=1` で有効化。binop/if/indexネスト・境界ケース込みを opt-in で検証可能。
- Module 解決: `nyash.toml` に lang/compiler/shared/vm の論理名を追記し、using resolver から参照可能にした。
マイルストーン
1) 入口統一
- Main.main → ParserBox.parse → pipeline_v2 → FlowEntry.emit_v0 で 1 行 JSON 出力。