Stage-B: route FlowEntry context (using/extern) and default Stage-B entry
This commit is contained in:
@ -39,7 +39,7 @@ Update — 2025-09-28 (json_query_vm PASS・最終ガード適用)
|
||||
|
||||
Update — 2025-10-31 (Phase 20.33 bring-up)
|
||||
- Stage-A map literal parser hardened(空/空白/エスケープ); quick `index_operator_hako` expands coverage。
|
||||
- Stage-B entry separated (`lang/src/compiler/entry/compiler_stageb.hako`); opt-in canaries(binop/if/index + nested/boundary)green with `SMOKES_ENABLE_STAGEB=1`。
|
||||
- Stage-B entry separated (`lang/src/compiler/entry/compiler_stageb.hako`); FlowEntry `emit_v0_from_ast_with_context` (using/extern) を既定採用。opt-in canaries(binop/if/index + nested/boundary)green with `SMOKES_ENABLE_STAGEB=1`。
|
||||
- `nyash.toml` modules updated to expose lang/compiler/shared/vm namespaces for resolver。
|
||||
- quick profile: 72/72 PASS(FileBox 未展開時は SKIP ハンドリング)。
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
|
||||
- [x] Stage‑B 専用エントリ(`lang/src/compiler/entry/compiler_stageb.hako`)を追加。`--prefer-cfg` を受理。
|
||||
- [x] `ParserBox.parse_program2` → AST JSON を取得(Quiet: 1行)。Stage‑A map parser は空/空白/エスケープに対応。
|
||||
- [x] pipeline_v2 FlowEntry.emit_v0_from_ast で v0 を出力(prefer_cfg=1 既定)。
|
||||
- [x] FlowEntry.emit_v0_from_ast_with_context(using/extern メタを統合)。
|
||||
- [x] selfhost canary(return/binop/if/index)を Stage‑B でも PASS(opt‑in `SMOKES_ENABLE_STAGEB=1` で緑)。
|
||||
- [ ] v1→v0 降格(MirJsonV1Adapter)経路を整備(必要箇所のみ)。
|
||||
- [x] tools/smokes/v2/profiles/quick/core/selfhost_* を追加(opt‑in)。配列ネスト/境界ケースを含む。
|
||||
|
||||
@ -8,8 +8,8 @@
|
||||
## フェーズ分割
|
||||
1) 入口統合(Stage‑B ルートの opt‑in 実装)
|
||||
- `lang/src/compiler/entry/compiler_stageb.hako` を追加(既定: Stage‑B emit 専用)。
|
||||
- `ParserBox.parse_program2(src)` → `FlowEntryBox.emit_v0_from_ast(ast_json, prefer_cfg)` → print 1 行 JSON。
|
||||
- フラグ: `--prefer-cfg <N>` で pipeline 選好を切替できるようにする。
|
||||
- `ParserBox.parse_program2(src)` → `FlowEntryBox.emit_v0_from_ast_with_context(..., usings, modules?, externs)` → print 1 行 JSON。
|
||||
- フラグ: `--prefer-cfg <N>` で pipeline 選好を切替。Stage‑B は using あり / externs あり時の経路を統合済み。
|
||||
2) 代表構文の緑化
|
||||
- binop/compare/if/index/new/boxcall/externcall を pipeline_v2 で受理できるよう確認。
|
||||
- Stage‑A canary と同等の selfhost canary を Stage‑B でも PASS。
|
||||
|
||||
@ -29,7 +29,7 @@
|
||||
- 既定 OFF のため quick/integration は回帰なし。
|
||||
|
||||
実装メモ
|
||||
- Stage‑B エントリを `lang/src/compiler/entry/compiler_stageb.hako` として分離。`--source` / `--prefer-cfg {0|1|2}` を受理。
|
||||
- Stage‑B エントリを `lang/src/compiler/entry/compiler_stageb.hako` として分離。`FlowEntryBox.emit_v0_from_ast_with_context`(using/extern メタを集約)を既定で使う。
|
||||
- Stage‑A map parser を強化(空/空白/エスケープ対応)。対応済み canary: `index_operator_hako`
|
||||
- Stage‑B canary は `SMOKES_ENABLE_STAGEB=1` で有効化。binop/if/index(ネスト・境界ケース込み)を opt-in で検証可能。
|
||||
- Module 解決: `nyash.toml` に lang/compiler/shared/vm の論理名を追記し、using resolver から参照可能にした。
|
||||
|
||||
@ -65,7 +65,10 @@ static box StageBMain {
|
||||
local externs_json = p.get_externs_json()
|
||||
local ast_json = p.parse_program2(src)
|
||||
local prefer = flags.prefer_cfg
|
||||
local jv0 = FlowEntryBox.emit_v0_from_ast(ast_json, prefer)
|
||||
local jv0 = FlowEntryBox.emit_v0_from_ast_with_context(ast_json, prefer, usings_json, null, externs_json)
|
||||
if jv0 == null {
|
||||
jv0 = FlowEntryBox.emit_v0_from_ast(ast_json, prefer)
|
||||
}
|
||||
// Attach usings metadata when available(Stage-B pipeline consumes via resolver)
|
||||
if jv0 == null || jv0 == "" { jv0 = "{\"version\":0,\"kind\":\"Program\",\"body\":[{\"type\":\"Return\",\"expr\":{\"type\":\"Int\",\"value\":0}}]}" }
|
||||
print(jv0)
|
||||
|
||||
@ -9,12 +9,27 @@ static box FlowEntryBox {
|
||||
emit_v0_from_ast(ast_json, prefer_cfg) {
|
||||
return PipelineV2.lower_stage1_to_mir(ast_json, prefer_cfg)
|
||||
}
|
||||
// Emit v0 with using context (alias/module maps) — prefer this when names need resolution
|
||||
// Emit v0 with using context(alias/module maps)
|
||||
emit_v0_from_ast_with_usings(ast_json, prefer_cfg, usings_json, modules_json) {
|
||||
print("[DEBUG FlowEntry] emit_v0_from_ast_with_usings called")
|
||||
local result = PipelineV2.lower_stage1_to_mir_with_usings(ast_json, prefer_cfg, usings_json, modules_json)
|
||||
print("[DEBUG FlowEntry] result=" + result)
|
||||
return result
|
||||
return PipelineV2.lower_stage1_to_mir_with_usings(ast_json, prefer_cfg, usings_json, modules_json)
|
||||
}
|
||||
|
||||
// Emit v0 with optional using / extern metadata(Stage‑B entry)
|
||||
emit_v0_from_ast_with_context(ast_json, prefer_cfg, usings_json, modules_json, externs_json) {
|
||||
local used_with_usings = 0
|
||||
local out = null
|
||||
if usings_json != null && usings_json != "" && usings_json != "[]" {
|
||||
out = PipelineV2.lower_stage1_to_mir_with_usings(ast_json, prefer_cfg, usings_json, modules_json)
|
||||
if out != null { used_with_usings = 1 }
|
||||
}
|
||||
if out == null {
|
||||
out = PipelineV2.lower_stage1_to_mir(ast_json, prefer_cfg)
|
||||
}
|
||||
if externs_json != null && externs_json != "" && externs_json != "[]" && used_with_usings == 0 {
|
||||
local j1 = PipelineV2.lower_stage1_to_mir_v1_with_meta(ast_json, prefer_cfg, externs_json)
|
||||
if j1 != null { out = MirJsonV1Adapter.to_v0(j1) }
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
// Emit v1 → v0 互換 JSON(unified mir_call を一旦生成して適応)。自己ホスト実行向け
|
||||
|
||||
Reference in New Issue
Block a user