feat(stage-b): Add FLOW keyword support + fix Stage-3 keyword conflicts
## ✅ Fixed Issues ### 1. `local` keyword tokenization (commit 9aab64f7) - Added Stage-3 gate for LOCAL/TRY/CATCH/THROW keywords - LOCAL now only active when NYASH_PARSER_STAGE3=1 ### 2. `env.local.get` keyword conflict - File: `lang/src/compiler/entry/compiler_stageb.hako:21-23` - Problem: `.local` in member access tokenized as `.LOCAL` keyword - Fix: Commented out `env.local.get("HAKO_SOURCE")` line - Fallback: Use `--source` argument (still functional) ### 3. `flow` keyword missing - Added FLOW to TokenType enum (`src/tokenizer/kinds.rs`) - Added "flow" → TokenType::FLOW mapping (`src/tokenizer/lex_ident.rs`) - Added FLOW to Stage-3 gate (requires NYASH_PARSER_STAGE3=1) - Added FLOW to parser statement dispatch (`src/parser/statements/mod.rs`) - Added FLOW to declaration handler (`src/parser/statements/declarations.rs`) - Updated box_declaration parser to accept BOX or FLOW (`src/parser/declarations/box_definition.rs`) - Treat `flow FooBox {}` as syntactic sugar for `box FooBox {}` ### 4. Module namespace conversion - Renamed `lang.compiler.builder.ssa.local` → `localvar` (avoid keyword) - Renamed file `local.hako` → `local_ssa.hako` - Converted 152 path-based using statements to namespace format - Added 26+ entries to `nyash.toml` [modules] section ## ⚠️ Remaining Issues ### Stage-B selfhost compiler performance - Stage-B compiler not producing output (hangs/times out after 10+ seconds) - Excessive PHI debug output suggests compilation loop issue - Needs investigation: infinite loop or N² algorithm in hako compiler ### Fallback JSON version mismatch - Rust fallback (`--emit-mir-json`) emits MIR v1 JSON (schema_version: "1.0") - Smoke tests expect MIR v0 JSON (`"version":0, "kind":"Program"`) - stageb_helpers.sh fallback needs adjustment ## Test Status - Parse errors: FIXED ✅ - Keyword conflicts: FIXED ✅ - Stage-B smoke tests: STILL FAILING ❌ (performance issue) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@ -1,8 +1,8 @@
|
||||
// Moved from apps/selfhost-compiler/builder/mod.hako
|
||||
// builder/mod.hako — Aggregator for compiler-track passes (scaffold)
|
||||
|
||||
using lang.compiler.builder.ssa.local as LocalSSA
|
||||
using lang.compiler.builder.ssa.loop as LoopSSA
|
||||
using lang.compiler.builder.ssa.localvar as LocalSSA
|
||||
using lang.compiler.builder.ssa.loopssa as LoopSSA
|
||||
using lang.compiler.builder.rewrite.special as RewriteSpecial
|
||||
using lang.compiler.builder.rewrite.known as RewriteKnown
|
||||
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
// cond_inserter.hako — minimal JSON-string helper to ensure branch(cond) has copy
|
||||
// Scope: smoke/dev helper(文字列JSON限定、構造的なLocalSSAとは別ライン)
|
||||
|
||||
using "lang/src/shared/json/json_cursor.hako" as JsonCursorBox
|
||||
using selfhost.shared.json.core.json_cursor as JsonCursorBox
|
||||
|
||||
static box CondInserter {
|
||||
ensure_cond(mjson) {
|
||||
|
||||
@ -4,7 +4,7 @@
|
||||
// 「ブロック内にオペランドが材化されている(LocalSSA)」ことを軽く検証・整形する。
|
||||
// - 既定では再配線(Copy挿入)等は行わず、将来の拡張に備えた安全な足場のみを提供する。
|
||||
|
||||
using "lang/src/shared/common/string_helpers.hako" as StringHelpers
|
||||
using selfhost.shared.common.string_helpers as StringHelpers
|
||||
static box LocalSSA {
|
||||
// --- 内部ヘルパ ---
|
||||
// trace fields are created on demand (dynamic properties)
|
||||
@ -4,7 +4,7 @@
|
||||
// - Args are expected as an ArrayBox of integer register ids.
|
||||
// - Callers may optionally attach (string like "[1,2]") for legacy rebuild paths.
|
||||
|
||||
using "lang/src/shared/common/string_helpers.hako" as StringHelpers
|
||||
using selfhost.shared.common.string_helpers as StringHelpers
|
||||
|
||||
static box CallEmitBox {
|
||||
make_call(name, arg_ids, dst) {
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
// newbox_emit_box.hako — NewBoxEmitBox: construct MIR(JSON v0) node for newbox
|
||||
// Responsibility: return MapBox node for { op: newbox, box_type, args, dst }.
|
||||
using "lang/src/shared/json/stringify.hako" as JSON
|
||||
using selfhost.shared.json.stringify as JSON
|
||||
|
||||
static box NewBoxEmitBox {
|
||||
make_new(box_type, arg_ids, dst) {
|
||||
|
||||
@ -3,8 +3,8 @@
|
||||
// Future: add Binary/Compare/ExternCall/BoxCall lowering incrementally.
|
||||
|
||||
using selfhost.common.json.mir_builder_min as MirJsonBuilderMin
|
||||
using "lang/src/shared/json/stringify.hako" as JSON
|
||||
using "lang/src/shared/common/string_helpers.hako" as StringHelpers
|
||||
using selfhost.shared.json.stringify as JSON
|
||||
using selfhost.shared.common.string_helpers as StringHelpers
|
||||
|
||||
static box MirEmitterBox {
|
||||
_index_of(hay, needle) { return hay.indexOf(needle) }
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
// - When invoked with --min-json, emit minimal Program JSON v0 to stdout
|
||||
// - Otherwise, act as a silent placeholder (return 0)
|
||||
|
||||
using "lang/src/compiler/entry/compiler_stageb.hako" as StageBMain
|
||||
using lang.compiler.entry.compiler_stageb as StageBMain
|
||||
|
||||
static box Main {
|
||||
_parse_signed_int(raw) {
|
||||
|
||||
@ -18,7 +18,8 @@ static box StageBMain {
|
||||
i = i + 1
|
||||
}
|
||||
}
|
||||
if src == null { src = env.local.get("HAKO_SOURCE") }
|
||||
// Skip env.local.get check - Stage-3 keyword conflict
|
||||
// Original: if src == null { src = env.local.get("HAKO_SOURCE") }
|
||||
if src == null { src = "return 0" }
|
||||
|
||||
// 2) Stage‑3 acceptance default ON for selfhost (env may turn off; keep tolerant here)
|
||||
@ -72,7 +73,7 @@ static box StageBMain {
|
||||
local prefer = 1
|
||||
local out = FlowEntryBox.emit_v0_from_ast_with_context(ast_json, prefer, usings_json, null, externs_json)
|
||||
if out == null || out == "" { out = FlowEntryBox.emit_v0_from_ast(ast_json, prefer) }
|
||||
if out == null || out == "" { out = "{\"version\":0,\"kind\":\"Program\",\"body\":[{\"type\":\"Return\",\"expr\":{\"type\":\"Int\",\"value\":0}}]}" }
|
||||
// TTL OFF: do not fallback to dummy JSON when emit fails. Empty output surfaces failure to caller.
|
||||
print(out)
|
||||
return 0
|
||||
}
|
||||
|
||||
@ -27,7 +27,7 @@ pipeline_v2.pipeline = "pipeline_v2/pipeline.hako"
|
||||
pipeline_v2.using_resolver = "pipeline_v2/using_resolver_box.hako"
|
||||
|
||||
# Builder / SSA / Rewrite (scaffolds)
|
||||
builder.ssa.local = "builder/ssa/local.hako"
|
||||
builder.ssa.local = "builder/ssa/local_ssa.hako"
|
||||
builder.ssa.loop = "builder/ssa/loopssa.hako"
|
||||
builder.ssa.cond_inserter = "builder/ssa/cond_inserter.hako"
|
||||
builder.rewrite.special = "builder/rewrite/special.hako"
|
||||
|
||||
@ -4,8 +4,8 @@
|
||||
// Behavior: If dotted, verify alias head is known; otherwise print a stable one-line error and return 0.
|
||||
// Non‑Responsibility: Namespace normalization or emit.
|
||||
|
||||
using "lang/src/compiler/pipeline_v2/using_resolver_box.hako" as UsingResolverBox
|
||||
using "lang/src/compiler/pipeline_v2/regex_flow.hako" as RegexFlow
|
||||
using lang.compiler.pipeline_v2.using_resolver_box as UsingResolverBox
|
||||
using lang.compiler.pipeline_v2.regex_flow as RegexFlow
|
||||
|
||||
static box AliasPreflightBox {
|
||||
// Returns 1 if OK, 0 if alias head is unresolved (prints error).
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
// CallExtractBox — Stage‑1 JSON から Return(Call name(args...)) を抽出(整数引数のみ)
|
||||
// Delegation to Stage1IntArgsExtractBox (unified implementation)
|
||||
using "lang/src/compiler/pipeline_v2/stage1_int_args_extract_box.hako" as Unified
|
||||
using lang.compiler.pipeline_v2.stage1_int_args_extract_box as Unified
|
||||
|
||||
static box CallExtractBox {
|
||||
// Returns { name: String, args: [Int,...] } or null
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
// CompareExtractBox — Stage‑1 JSON から Compare(lhs,rhs,op) を堅牢に抽出(整数のみ)
|
||||
using "lang/src/compiler/pipeline_v2/regex_flow.hako" as RegexFlow
|
||||
using "lang/src/shared/common/box_helpers.hako" as BoxHelpers
|
||||
using lang.compiler.pipeline_v2.regex_flow as RegexFlow
|
||||
using selfhost.shared.common.box_helpers as BoxHelpers
|
||||
|
||||
static box CompareExtractBox {
|
||||
// --- internal helpers (range & safe find) ---
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
// EmitBinopBox — binop の最小 MIR(JSON v0) 生成
|
||||
using "lang/src/shared/json/mir_builder_min.hako" as MirJsonBuilderMin
|
||||
using selfhost.shared.json.mir_builder_min as MirJsonBuilderMin
|
||||
|
||||
static box EmitBinopBox {
|
||||
_map_binop(opk) {
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
// EmitCallBox — Return(Call name(int_args...)) を MIR(JSON v0) に最小変換
|
||||
// 仕様: 各引数を const i64 として材化し、call を発行、dst を ret する。
|
||||
|
||||
using "lang/src/compiler/pipeline_v2/regex_flow.hako" as RegexFlow
|
||||
using lang.compiler.pipeline_v2.regex_flow as RegexFlow
|
||||
using lang.compiler.emit.common.header_emit as HeaderEmitBox
|
||||
using "lang/src/shared/mir/mir_schema_box.hako" as MirSchemaBox
|
||||
using selfhost.shared.mir.schema as MirSchemaBox
|
||||
|
||||
static box EmitCallBox {
|
||||
_to_str(n) {
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
// EmitCompareBox — compare/branch/jump/ret の最小 MIR(JSON v0) 生成(string直組み)
|
||||
using "lang/src/compiler/pipeline_v2/local_ssa_box.hako" as LocalSSABox
|
||||
using lang.compiler.pipeline_v2.localvar_ssa_box as LocalSSABox
|
||||
using lang.compiler.emit.common.mir_emit as MirEmitBox
|
||||
using lang.compiler.emit.common.header_emit as HeaderEmitBox
|
||||
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
// EmitMethodBox — Return(Method recv, method, args[int...]) → MIR(JSON v0)
|
||||
// 最小形: const recv→r1; 各引数を r2..rN; boxcall(method, recv=r1, args=r2..) → rK; ret rK
|
||||
|
||||
using "lang/src/compiler/pipeline_v2/regex_flow.hako" as RegexFlow
|
||||
using lang.compiler.pipeline_v2.regex_flow as RegexFlow
|
||||
using lang.compiler.emit.common.header_emit as HeaderEmitBox
|
||||
using "lang/src/shared/mir/mir_schema_box.hako" as MirSchemaBox
|
||||
using selfhost.shared.mir.schema as MirSchemaBox
|
||||
|
||||
static box EmitMethodBox {
|
||||
_to_str(n) {
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
using "lang/src/shared/mir/json_emit_box.hako" as JsonEmitBox
|
||||
using selfhost.shared.mir.json_emit as JsonEmitBox
|
||||
// Shared MIR helpers (P1/P2)
|
||||
using "lang/src/shared/mir/mir_schema_box.hako" as MirSchema
|
||||
using "lang/src/shared/mir/block_builder_box.hako" as BlockBuilder
|
||||
using "lang/src/compiler/pipeline_v2/local_ssa_box.hako" as LocalSSABox
|
||||
using "lang/src/shared/common/box_helpers.hako" as BoxHelpers
|
||||
using selfhost.shared.mir.schema as MirSchema
|
||||
using selfhost.shared.mir.builder as BlockBuilder
|
||||
using lang.compiler.pipeline_v2.localvar_ssa_box as LocalSSABox
|
||||
using selfhost.shared.common.box_helpers as BoxHelpers
|
||||
|
||||
flow EmitMirFlow {
|
||||
_int(n) { return "" + n }
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
using "lang/src/shared/mir/json_emit_box.hako" as JsonEmitBox
|
||||
using selfhost.shared.mir.json_emit as JsonEmitBox
|
||||
// Shared MIR helpers (P1)
|
||||
using "lang/src/shared/mir/mir_schema_box.hako" as MirSchema
|
||||
using "lang/src/shared/mir/block_builder_box.hako" as BlockBuilder
|
||||
using "lang/src/shared/common/box_helpers.hako" as BoxHelpers
|
||||
using "lang/src/compiler/pipeline_v2/local_ssa_box.hako" as LocalSSABox
|
||||
using selfhost.shared.mir.schema as MirSchema
|
||||
using selfhost.shared.mir.builder as BlockBuilder
|
||||
using selfhost.shared.common.box_helpers as BoxHelpers
|
||||
using lang.compiler.pipeline_v2.localvar_ssa_box as LocalSSABox
|
||||
|
||||
flow EmitMirFlowMap {
|
||||
_array_len(arr) { return BoxHelpers.array_len(arr) }
|
||||
|
||||
@ -1,12 +1,12 @@
|
||||
// EmitNewBoxBox — Return(New class, args[int...]) → MIR(JSON v0)
|
||||
// 最小形: 各引数を r1..rN; newbox(class, args=r1..rN) → rK; ret rK
|
||||
|
||||
using "lang/src/shared/json/mir_builder_min.hako" as MirJsonBuilderMin
|
||||
using "lang/src/compiler/pipeline_v2/regex_flow.hako" as RegexFlow
|
||||
using "lang/src/compiler/pipeline_v2/stage1_args_parser_box.hako" as Stage1ArgsParserBox
|
||||
using "lang/src/shared/mir/json_emit_box.hako" as JsonEmitBox
|
||||
using "lang/src/shared/mir/block_builder_box.hako" as BlockBuilder
|
||||
using "lang/src/compiler/pipeline_v2/local_ssa_box.hako" as LocalSSABox
|
||||
using selfhost.shared.json.mir_builder_min as MirJsonBuilderMin
|
||||
using lang.compiler.pipeline_v2.regex_flow as RegexFlow
|
||||
using lang.compiler.pipeline_v2.stage1_args_parser_box as Stage1ArgsParserBox
|
||||
using selfhost.shared.mir.json_emit as JsonEmitBox
|
||||
using selfhost.shared.mir.builder as BlockBuilder
|
||||
using lang.compiler.pipeline_v2.localvar_ssa_box as LocalSSABox
|
||||
|
||||
static box EmitNewBoxBox {
|
||||
emit_newbox_int_args(class_name, args) {
|
||||
|
||||
@ -14,7 +14,7 @@ using lang.compiler.parser.stmt.parser_control_box
|
||||
using lang.compiler.parser.stmt.parser_exception_box
|
||||
using lang.compiler.stage1.json_program_box
|
||||
using lang.compiler.stage1.emitter_box as EmitterBoxMod
|
||||
using "lang/src/compiler/pipeline_v2/backend_box.hako" as BackendBoxMod
|
||||
using lang.compiler.pipeline_v2.backend_box as BackendBoxMod
|
||||
|
||||
box ExecutionPipelineBox {
|
||||
backend_name
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
// flow_entry.hako — Pipeline v2 entry box(emit-only)
|
||||
// Guard: This box performs no execution. Returns MIR(JSON) as text.
|
||||
|
||||
using "lang/src/compiler/pipeline_v2/pipeline.hako" as PipelineV2
|
||||
using "lang/src/shared/json/mir_v1_adapter.hako" as MirJsonV1Adapter
|
||||
using lang.compiler.pipeline_v2.pipeline as PipelineV2
|
||||
using selfhost.shared.json.mir_v1_adapter as MirJsonV1Adapter
|
||||
|
||||
static box FlowEntryBox {
|
||||
// Emit legacy v0 JSON(call/boxcall/newbox)。最小入力: Stage‑1 JSON 文字列
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
// LocalSSABox — 材化(materialize)/Copy 挿入の最小ポリシーを集約
|
||||
// Phase 15.7: 最小実装。将来 PHI/Call 前の規約をここに集約して拡張する。
|
||||
|
||||
using "lang/src/shared/common/box_helpers.hako" as BoxHelpers
|
||||
using selfhost.shared.common.box_helpers as BoxHelpers
|
||||
|
||||
static box LocalSSABox {
|
||||
_maybe_unwrap_instructions(insts) {
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
// map_helpers_box.hako — Pipeline用の軽量ヘルパ(MapBoxの型付き取得)
|
||||
|
||||
using "lang/src/shared/common/string_helpers.hako" as StringHelpers
|
||||
using "lang/src/shared/common/box_helpers.hako" as BoxHelpers
|
||||
using selfhost.shared.common.string_helpers as StringHelpers
|
||||
using selfhost.shared.common.box_helpers as BoxHelpers
|
||||
static box MapHelpersBox {
|
||||
_raw_get(m, key) {
|
||||
return BoxHelpers.map_get(m, key)
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
// MethodExtractBox — Stage‑1 JSON から Return(Method recv, method, args) を抽出(整数引数のみ; recvは無視)
|
||||
// Delegation to Stage1IntArgsExtractBox (unified implementation)
|
||||
using "lang/src/compiler/pipeline_v2/stage1_int_args_extract_box.hako" as Unified
|
||||
using lang.compiler.pipeline_v2.stage1_int_args_extract_box as Unified
|
||||
|
||||
static box MethodExtractBox {
|
||||
// Returns { method: String, args: [Int,...] } or null
|
||||
|
||||
@ -1,10 +1,10 @@
|
||||
// MirBuilderBox — minimal Ny→MIR(JSON v0) lowering entry (dev)
|
||||
// Phase 15.7: kept optional; pipeline.v2 uses Emit flow directly.
|
||||
using "lang/src/compiler/pipeline_v2/stage1_extract_flow.hako" as Stage1ExtractFlow
|
||||
using "lang/src/compiler/pipeline_v2/emit_return_box.hako" as EmitReturnBox
|
||||
using "lang/src/compiler/pipeline_v2/emit_binop_box.hako" as EmitBinopBox
|
||||
using "lang/src/compiler/pipeline_v2/emit_compare_box.hako" as EmitCompareBox
|
||||
using "lang/src/shared/common/box_helpers.hako" as BoxHelpers
|
||||
using lang.compiler.pipeline_v2.stage1_extract_flow as Stage1ExtractFlow
|
||||
using lang.compiler.pipeline_v2.emit_return_box as EmitReturnBox
|
||||
using lang.compiler.pipeline_v2.emit_binop_box as EmitBinopBox
|
||||
using lang.compiler.pipeline_v2.emit_compare_box as EmitCompareBox
|
||||
using selfhost.shared.common.box_helpers as BoxHelpers
|
||||
|
||||
box MirBuilderBox {
|
||||
// Placeholder for optimizer toggle
|
||||
|
||||
@ -1,12 +1,12 @@
|
||||
// MirCallBox — JSON v1 unified call emitters(薄い箱)
|
||||
// 目的: v1(mir_call)を第一級に扱う最小APIを集中させる。実行は含まない(emit-only)。
|
||||
|
||||
using "lang/src/shared/json/mir_builder_min.hako" as MirJsonBuilderMin
|
||||
using "lang/src/compiler/pipeline_v2/regex_flow.hako" as RegexFlow
|
||||
using selfhost.shared.json.mir_builder_min as MirJsonBuilderMin
|
||||
using lang.compiler.pipeline_v2.regex_flow as RegexFlow
|
||||
using lang.compiler.emit.common.mir_emit as MirEmitBox
|
||||
using lang.compiler.emit.common.call_emit as CallEmitBox
|
||||
using lang.compiler.emit.common.header_emit as HeaderEmitBox
|
||||
using "lang/src/shared/mir/json_emit_box.hako" as JsonEmitBox
|
||||
using selfhost.shared.mir.json_emit as JsonEmitBox
|
||||
|
||||
static box MirCallBox {
|
||||
// Global(name, args:int[])
|
||||
|
||||
@ -3,9 +3,9 @@
|
||||
// - primary: NamespaceBox.normalize_global_name(raw, resolver)
|
||||
// - fallback: unique tail match via UsingResolverBox.guess_namespace_from_tail
|
||||
|
||||
using "lang/src/compiler/pipeline_v2/using_resolver_box.hako" as UsingResolverBox
|
||||
using "lang/src/compiler/pipeline_v2/namespace_box.hako" as NamespaceBox
|
||||
using "lang/src/compiler/pipeline_v2/regex_flow.hako" as RegexFlow
|
||||
using lang.compiler.pipeline_v2.using_resolver_box as UsingResolverBox
|
||||
using lang.compiler.pipeline_v2.namespace_box as NamespaceBox
|
||||
using lang.compiler.pipeline_v2.regex_flow as RegexFlow
|
||||
|
||||
static box PipelineNameResolveBox {
|
||||
// Returns fully-qualified name or null
|
||||
|
||||
@ -5,8 +5,8 @@
|
||||
// Non‑Responsibility:
|
||||
// - IO / TOML 読み込み、Runner 側の using 解決、実行
|
||||
|
||||
using "lang/src/compiler/pipeline_v2/using_resolver_box.hako" as UsingResolver
|
||||
using "lang/src/compiler/pipeline_v2/regex_flow.hako" as RegexFlow
|
||||
using lang.compiler.pipeline_v2.using_resolver_box as UsingResolver
|
||||
using lang.compiler.pipeline_v2.regex_flow as RegexFlow
|
||||
|
||||
static box NamespaceBox {
|
||||
// Normalize global function name using resolver context
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
// NewExtractBox — Stage‑1 JSON から Return(New class(args...)) を抽出(整数引数のみ)
|
||||
// Delegation to Stage1IntArgsExtractBox (unified implementation)
|
||||
using "lang/src/compiler/pipeline_v2/stage1_int_args_extract_box.hako" as Unified
|
||||
using lang.compiler.pipeline_v2.stage1_int_args_extract_box as Unified
|
||||
|
||||
static box NewExtractBox {
|
||||
// Returns { class: String, args: [Int,...] } or null
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
// normalizer_box.hako — Minimal normalizer for Compare maps (cmp/lhs/rhs)
|
||||
|
||||
using "lang/src/shared/common/string_helpers.hako" as StringHelpers
|
||||
using "lang/src/shared/common/box_helpers.hako" as BoxHelpers
|
||||
using selfhost.shared.common.string_helpers as StringHelpers
|
||||
using selfhost.shared.common.box_helpers as BoxHelpers
|
||||
static box NormalizerBox {
|
||||
// Normalize cmp/lhs/rhs into MapBox with String keys
|
||||
normalize_cmp(raw) {
|
||||
|
||||
@ -1,30 +1,30 @@
|
||||
using "lang/src/compiler/pipeline_v2/stage1_extract_flow.hako" as Stage1ExtractFlow
|
||||
using "lang/src/compiler/pipeline_v2/emit_return_box.hako" as EmitReturnBox
|
||||
using "lang/src/compiler/pipeline_v2/emit_binop_box.hako" as EmitBinopBox
|
||||
using "lang/src/compiler/pipeline_v2/emit_compare_box.hako" as EmitCompareBox
|
||||
using "lang/src/compiler/pipeline_v2/regex_flow.hako" as RegexFlow
|
||||
using lang.compiler.builder.ssa.local as LocalSSA
|
||||
using "lang/src/compiler/pipeline_v2/emit_call_box.hako" as EmitCallBox
|
||||
using "lang/src/compiler/pipeline_v2/emit_method_box.hako" as EmitMethodBox
|
||||
using "lang/src/compiler/pipeline_v2/emit_newbox_box.hako" as EmitNewBoxBox
|
||||
using "lang/src/compiler/pipeline_v2/mir_call_box.hako" as MirCallBox
|
||||
using "lang/src/shared/json/mir_v1_adapter.hako" as MirJsonV1Adapter
|
||||
using "lang/src/compiler/pipeline_v2/compare_extract_box.hako" as CompareExtractBox
|
||||
using "lang/src/compiler/pipeline_v2/normalizer_box.hako" as NormalizerBox
|
||||
using "lang/src/compiler/pipeline_v2/map_helpers_box.hako" as MapHelpersBox
|
||||
using "lang/src/compiler/pipeline_v2/call_extract_box.hako" as CallExtractBox
|
||||
using "lang/src/compiler/pipeline_v2/method_extract_box.hako" as MethodExtractBox
|
||||
using "lang/src/compiler/pipeline_v2/new_extract_box.hako" as NewExtractBox
|
||||
using "lang/src/shared/common/string_helpers.hako" as StringHelpers
|
||||
using "lang/src/compiler/pipeline_v2/using_resolver_box.hako" as UsingResolverBox
|
||||
using "lang/src/compiler/pipeline_v2/namespace_box.hako" as NamespaceBox
|
||||
using "lang/src/compiler/pipeline_v2/signature_verifier_box.hako" as SignatureVerifierBox
|
||||
using "lang/src/compiler/pipeline_v2/stage1_json_scanner_box.hako" as Stage1JsonScannerBox
|
||||
using "lang/src/compiler/pipeline_v2/stage1_name_args_normalizer_box.hako" as NameArgsNormBox
|
||||
using "lang/src/compiler/pipeline_v2/alias_preflight_box.hako" as AliasPreflightBox
|
||||
using "lang/src/compiler/pipeline_v2/stage1_args_parser_box.hako" as Stage1ArgsParserBox
|
||||
using "lang/src/compiler/pipeline_v2/pipeline_helpers_box.hako" as PipelineHelpersBox
|
||||
using "lang/src/shared/json/mir_v1_meta_inject_box.hako" as MirV1MetaInjectBox
|
||||
using lang.compiler.pipeline_v2.stage1_extract_flow as Stage1ExtractFlow
|
||||
using lang.compiler.pipeline_v2.emit_return_box as EmitReturnBox
|
||||
using lang.compiler.pipeline_v2.emit_binop_box as EmitBinopBox
|
||||
using lang.compiler.pipeline_v2.emit_compare_box as EmitCompareBox
|
||||
using lang.compiler.pipeline_v2.regex_flow as RegexFlow
|
||||
using lang.compiler.builder.ssa.localvar as LocalSSA
|
||||
using lang.compiler.pipeline_v2.emit_call_box as EmitCallBox
|
||||
using lang.compiler.pipeline_v2.emit_method_box as EmitMethodBox
|
||||
using lang.compiler.pipeline_v2.emit_newbox_box as EmitNewBoxBox
|
||||
using lang.compiler.pipeline_v2.mir_call_box as MirCallBox
|
||||
using selfhost.shared.json.mir_v1_adapter as MirJsonV1Adapter
|
||||
using lang.compiler.pipeline_v2.compare_extract_box as CompareExtractBox
|
||||
using lang.compiler.pipeline_v2.normalizer_box as NormalizerBox
|
||||
using lang.compiler.pipeline_v2.map_helpers_box as MapHelpersBox
|
||||
using lang.compiler.pipeline_v2.call_extract_box as CallExtractBox
|
||||
using lang.compiler.pipeline_v2.method_extract_box as MethodExtractBox
|
||||
using lang.compiler.pipeline_v2.new_extract_box as NewExtractBox
|
||||
using sh_core as StringHelpers
|
||||
using lang.compiler.pipeline_v2.using_resolver_box as UsingResolverBox
|
||||
using lang.compiler.pipeline_v2.namespace_box as NamespaceBox
|
||||
using lang.compiler.pipeline_v2.signature_verifier_box as SignatureVerifierBox
|
||||
using lang.compiler.pipeline_v2.stage1_json_scanner_box as Stage1JsonScannerBox
|
||||
using lang.compiler.pipeline_v2.stage1_name_args_normalizer_box as NameArgsNormBox
|
||||
using lang.compiler.pipeline_v2.alias_preflight_box as AliasPreflightBox
|
||||
using lang.compiler.pipeline_v2.stage1_args_parser_box as Stage1ArgsParserBox
|
||||
using lang.compiler.pipeline_v2.pipeline_helpers_box as PipelineHelpersBox
|
||||
using selfhost.shared.json.mir_v1_meta_inject_box as MirV1MetaInjectBox
|
||||
|
||||
flow PipelineV2 {
|
||||
lower_stage1_to_mir(ast_json, prefer_cfg) {
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
// pipeline_emit_box.hako — PipelineEmitBox
|
||||
// Responsibility: small wrappers that emit MIR(JSON v0) and apply LocalSSA ensures
|
||||
|
||||
using "lang/src/compiler/pipeline_v2/emit_call_box.hako" as EmitCallBox
|
||||
using "lang/src/compiler/pipeline_v2/local_ssa_box.hako" as LocalSSABox
|
||||
using "lang/src/shared/json/mir_v1_meta_inject_box.hako" as MirV1MetaInjectBox
|
||||
using lang.compiler.pipeline_v2.emit_call_box as EmitCallBox
|
||||
using lang.compiler.pipeline_v2.localvar_ssa_box as LocalSSABox
|
||||
using selfhost.shared.json.mir_v1_meta_inject_box as MirV1MetaInjectBox
|
||||
|
||||
static box PipelineEmitBox {
|
||||
// Emit Call(name, int-args) → JSON v0, wrapped with LocalSSA ensures
|
||||
|
||||
@ -2,8 +2,8 @@
|
||||
// 責務: JSON/数値解析の共通ユーティリティ
|
||||
// Extracted from PipelineV2 flow (556行 → 506行、-50行削減)
|
||||
|
||||
using "lang/src/compiler/pipeline_v2/regex_flow.hako" as RegexFlow
|
||||
using "lang/src/shared/common/string_helpers.hako" as StringHelpers
|
||||
using lang.compiler.pipeline_v2.regex_flow as RegexFlow
|
||||
using selfhost.shared.common.string_helpers as StringHelpers
|
||||
|
||||
static box PipelineHelpersBox {
|
||||
// Parse integer at specific position (whitespace-aware, sign-aware)
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
// readonly_map_view.hako — 読み取り専用ビュー(誤更新防止用)
|
||||
|
||||
using "lang/src/shared/common/box_helpers.hako" as BoxHelpers
|
||||
using selfhost.shared.common.box_helpers as BoxHelpers
|
||||
|
||||
static box ReadOnlyMapView {
|
||||
_m
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
using "lang/src/shared/common/string_helpers.hako" as StringHelpers
|
||||
using selfhost.shared.common.string_helpers as StringHelpers
|
||||
|
||||
flow RegexFlow {
|
||||
// Minimal regex-like helpers focused on readability and determinism.
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
// (e.g., indexOf=1 on String/Array, push=1 on Array, etc.).
|
||||
// - Unknown methods are allowed (return 1) to avoid over-blocking during bring-up.
|
||||
|
||||
using "lang/src/compiler/pipeline_v2/regex_flow.hako" as RegexFlow
|
||||
using lang.compiler.pipeline_v2.regex_flow as RegexFlow
|
||||
// Method registry is optional; allow unknowns by design in bring-up.
|
||||
|
||||
static box SignatureVerifierBox {
|
||||
|
||||
@ -2,8 +2,8 @@
|
||||
// Responsibility: Parse Stage‑1 args JSON text into integers (MVP: Int only).
|
||||
// Non‑Responsibility: MIR emit or namespace.
|
||||
|
||||
using "lang/src/compiler/pipeline_v2/regex_flow.hako" as RegexFlow
|
||||
using "lang/src/shared/json/json_cursor.hako" as JsonCursorBox
|
||||
using lang.compiler.pipeline_v2.regex_flow as RegexFlow
|
||||
using selfhost.shared.json.core.json_cursor as JsonCursorBox
|
||||
|
||||
static box Stage1ArgsParserBox {
|
||||
// Count Int occurrences in Stage‑1 args JSON text.
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
using "lang/src/compiler/pipeline_v2/regex_flow.hako" as RegexFlow
|
||||
using lang.compiler.pipeline_v2.regex_flow as RegexFlow
|
||||
|
||||
flow Stage1ExtractFlow {
|
||||
// Extract minimal info from Stage‑1 JSON (Return Int / BinOp / Compare)
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
// Responsibility: 3つの類似ExtractBoxを統合(call_extract/method_extract/new_extract)
|
||||
// Notes: 85%重複コードを共通化、args抽出ロジックを一元管理
|
||||
|
||||
using "lang/src/compiler/pipeline_v2/regex_flow.hako" as RegexFlow
|
||||
using lang.compiler.pipeline_v2.regex_flow as RegexFlow
|
||||
|
||||
static box Stage1IntArgsExtractBox {
|
||||
// ===== 汎用Extract(内部実装) =====
|
||||
|
||||
@ -6,8 +6,8 @@
|
||||
// - name/args basic extraction
|
||||
// Non‑Responsibility: MIR emit, namespace resolution, IO
|
||||
|
||||
using "lang/src/shared/json/json_cursor.hako" as JsonCursorBox
|
||||
using "lang/src/shared/common/box_helpers.hako" as BoxHelpers
|
||||
using selfhost.shared.json.core.json_cursor as JsonCursorBox
|
||||
using selfhost.shared.common.box_helpers as BoxHelpers
|
||||
|
||||
static box Stage1JsonScannerBox {
|
||||
// Find the start position of Program.body array key
|
||||
|
||||
@ -5,10 +5,10 @@
|
||||
// - New: class normalization via UsingResolverBox/NamespaceBox
|
||||
// Non‑Responsibility: MIR emit or IO
|
||||
|
||||
using "lang/src/compiler/pipeline_v2/namespace_box.hako" as NamespaceBox
|
||||
using "lang/src/compiler/pipeline_v2/signature_verifier_box.hako" as SignatureVerifierBox
|
||||
using "lang/src/compiler/pipeline_v2/alias_preflight_box.hako" as AliasPreflightBox
|
||||
using "lang/src/shared/common/box_helpers.hako" as BoxHelpers
|
||||
using lang.compiler.pipeline_v2.namespace_box as NamespaceBox
|
||||
using lang.compiler.pipeline_v2.signature_verifier_box as SignatureVerifierBox
|
||||
using lang.compiler.pipeline_v2.alias_preflight_box as AliasPreflightBox
|
||||
using selfhost.shared.common.box_helpers as BoxHelpers
|
||||
|
||||
static box Stage1NameArgsNormalizerBox {
|
||||
_label_or_name(scan) {
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
// Responsibility: Provide a thin, unified guard to prevent emit after terminator.
|
||||
// Notes: Operates on an instructions ArrayBox of Map nodes with key "op".
|
||||
|
||||
using "lang/src/shared/common/box_helpers.hako" as BoxHelpers
|
||||
using selfhost.shared.common.box_helpers as BoxHelpers
|
||||
|
||||
static box TerminatorGuardBox {
|
||||
// Return 1 if the given instructions array ends with ret/throw
|
||||
|
||||
@ -4,9 +4,9 @@
|
||||
// modules_map: Map, modules_keys: Array
|
||||
// }
|
||||
|
||||
using "lang/src/shared/common/string_helpers.hako" as StringHelpers
|
||||
using "lang/src/shared/common/box_helpers.hako" as BoxHelpers
|
||||
using "lang/src/compiler/pipeline_v2/regex_flow.hako" as RegexFlow
|
||||
using selfhost.shared.common.string_helpers as StringHelpers
|
||||
using selfhost.shared.common.box_helpers as BoxHelpers
|
||||
using lang.compiler.pipeline_v2.regex_flow as RegexFlow
|
||||
|
||||
static box UsingResolverBox {
|
||||
// Lightweight state as String: holds modules_json only
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
// Moved from apps/selfhost-compiler/boxes/emitter_box.hako
|
||||
// EmitterBox — thin wrapper to emit JSON v0 (extracted)
|
||||
using "lang/src/compiler/stage1/json_program_box.hako" as JsonProg
|
||||
using lang.compiler.stage1.json_program_box as JsonProg
|
||||
|
||||
static box EmitterBox {
|
||||
emit_program(json, usings_json, externs_json) {
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
// Moved from apps/selfhost-compiler/boxes/json_program_box.hako
|
||||
// JsonProgramBox — JSON v0 正規化の最小箱
|
||||
// 責務: Programヘッダの補正・meta.usings注入・主要Stmt/Exprのキー順安定化
|
||||
using "lang/src/shared/common/string_helpers.hako" as StringHelpers
|
||||
using "lang/src/shared/json/json_utils.hako" as JsonUtilsBox
|
||||
using selfhost.shared.common.string_helpers as StringHelpers
|
||||
using selfhost.shared.json.utils.json_utils as JsonUtilsBox
|
||||
|
||||
static box JsonProgramBox {
|
||||
normalize(json, usings_json, externs_json) {
|
||||
|
||||
Reference in New Issue
Block a user