diff --git a/lang/src/compiler/builder/mod.hako b/lang/src/compiler/builder/mod.hako index 2985363a..5e5ceafa 100644 --- a/lang/src/compiler/builder/mod.hako +++ b/lang/src/compiler/builder/mod.hako @@ -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 diff --git a/lang/src/compiler/builder/ssa/cond_inserter.hako b/lang/src/compiler/builder/ssa/cond_inserter.hako index d8a61645..5fdb960c 100644 --- a/lang/src/compiler/builder/ssa/cond_inserter.hako +++ b/lang/src/compiler/builder/ssa/cond_inserter.hako @@ -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) { diff --git a/lang/src/compiler/builder/ssa/local.hako b/lang/src/compiler/builder/ssa/local_ssa.hako similarity index 97% rename from lang/src/compiler/builder/ssa/local.hako rename to lang/src/compiler/builder/ssa/local_ssa.hako index 15021c82..15bfff3f 100644 --- a/lang/src/compiler/builder/ssa/local.hako +++ b/lang/src/compiler/builder/ssa/local_ssa.hako @@ -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) diff --git a/lang/src/compiler/emit/common/call_emit_box.hako b/lang/src/compiler/emit/common/call_emit_box.hako index 125a1afb..04462d3c 100644 --- a/lang/src/compiler/emit/common/call_emit_box.hako +++ b/lang/src/compiler/emit/common/call_emit_box.hako @@ -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) { diff --git a/lang/src/compiler/emit/common/newbox_emit_box.hako b/lang/src/compiler/emit/common/newbox_emit_box.hako index e3b73ff9..b611c1c0 100644 --- a/lang/src/compiler/emit/common/newbox_emit_box.hako +++ b/lang/src/compiler/emit/common/newbox_emit_box.hako @@ -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) { diff --git a/lang/src/compiler/emit/mir_emitter_box.hako b/lang/src/compiler/emit/mir_emitter_box.hako index d3647c64..e0e97acb 100644 --- a/lang/src/compiler/emit/mir_emitter_box.hako +++ b/lang/src/compiler/emit/mir_emitter_box.hako @@ -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) } diff --git a/lang/src/compiler/entry/compiler.hako b/lang/src/compiler/entry/compiler.hako index 41a083c8..066b88ac 100644 --- a/lang/src/compiler/entry/compiler.hako +++ b/lang/src/compiler/entry/compiler.hako @@ -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) { diff --git a/lang/src/compiler/entry/compiler_stageb.hako b/lang/src/compiler/entry/compiler_stageb.hako index bce16ba5..dbf90fe6 100644 --- a/lang/src/compiler/entry/compiler_stageb.hako +++ b/lang/src/compiler/entry/compiler_stageb.hako @@ -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 } diff --git a/lang/src/compiler/hako_module.toml b/lang/src/compiler/hako_module.toml index 3f738ac0..ad53de7d 100644 --- a/lang/src/compiler/hako_module.toml +++ b/lang/src/compiler/hako_module.toml @@ -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" diff --git a/lang/src/compiler/pipeline_v2/alias_preflight_box.hako b/lang/src/compiler/pipeline_v2/alias_preflight_box.hako index aabf7a7a..378d5186 100644 --- a/lang/src/compiler/pipeline_v2/alias_preflight_box.hako +++ b/lang/src/compiler/pipeline_v2/alias_preflight_box.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). diff --git a/lang/src/compiler/pipeline_v2/call_extract_box.hako b/lang/src/compiler/pipeline_v2/call_extract_box.hako index f45f28ea..ece5b8ef 100644 --- a/lang/src/compiler/pipeline_v2/call_extract_box.hako +++ b/lang/src/compiler/pipeline_v2/call_extract_box.hako @@ -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 diff --git a/lang/src/compiler/pipeline_v2/compare_extract_box.hako b/lang/src/compiler/pipeline_v2/compare_extract_box.hako index 867a2327..2a9b87e4 100644 --- a/lang/src/compiler/pipeline_v2/compare_extract_box.hako +++ b/lang/src/compiler/pipeline_v2/compare_extract_box.hako @@ -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) --- diff --git a/lang/src/compiler/pipeline_v2/emit_binop_box.hako b/lang/src/compiler/pipeline_v2/emit_binop_box.hako index e9258aa3..c544119e 100644 --- a/lang/src/compiler/pipeline_v2/emit_binop_box.hako +++ b/lang/src/compiler/pipeline_v2/emit_binop_box.hako @@ -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) { diff --git a/lang/src/compiler/pipeline_v2/emit_call_box.hako b/lang/src/compiler/pipeline_v2/emit_call_box.hako index 12cfdc4b..297c8483 100644 --- a/lang/src/compiler/pipeline_v2/emit_call_box.hako +++ b/lang/src/compiler/pipeline_v2/emit_call_box.hako @@ -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) { diff --git a/lang/src/compiler/pipeline_v2/emit_compare_box.hako b/lang/src/compiler/pipeline_v2/emit_compare_box.hako index 2b417987..2e8d5d29 100644 --- a/lang/src/compiler/pipeline_v2/emit_compare_box.hako +++ b/lang/src/compiler/pipeline_v2/emit_compare_box.hako @@ -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 diff --git a/lang/src/compiler/pipeline_v2/emit_method_box.hako b/lang/src/compiler/pipeline_v2/emit_method_box.hako index 66ca9914..9792068c 100644 --- a/lang/src/compiler/pipeline_v2/emit_method_box.hako +++ b/lang/src/compiler/pipeline_v2/emit_method_box.hako @@ -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) { diff --git a/lang/src/compiler/pipeline_v2/emit_mir_flow.hako b/lang/src/compiler/pipeline_v2/emit_mir_flow.hako index e4c09214..ecff1c2f 100644 --- a/lang/src/compiler/pipeline_v2/emit_mir_flow.hako +++ b/lang/src/compiler/pipeline_v2/emit_mir_flow.hako @@ -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 } diff --git a/lang/src/compiler/pipeline_v2/emit_mir_flow_map.hako b/lang/src/compiler/pipeline_v2/emit_mir_flow_map.hako index 6468b2a9..9563edec 100644 --- a/lang/src/compiler/pipeline_v2/emit_mir_flow_map.hako +++ b/lang/src/compiler/pipeline_v2/emit_mir_flow_map.hako @@ -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) } diff --git a/lang/src/compiler/pipeline_v2/emit_newbox_box.hako b/lang/src/compiler/pipeline_v2/emit_newbox_box.hako index 172d3903..47e02868 100644 --- a/lang/src/compiler/pipeline_v2/emit_newbox_box.hako +++ b/lang/src/compiler/pipeline_v2/emit_newbox_box.hako @@ -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) { diff --git a/lang/src/compiler/pipeline_v2/execution_pipeline_box.hako b/lang/src/compiler/pipeline_v2/execution_pipeline_box.hako index bcdcc7fe..5bc0291e 100644 --- a/lang/src/compiler/pipeline_v2/execution_pipeline_box.hako +++ b/lang/src/compiler/pipeline_v2/execution_pipeline_box.hako @@ -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 diff --git a/lang/src/compiler/pipeline_v2/flow_entry.hako b/lang/src/compiler/pipeline_v2/flow_entry.hako index 8f8300ac..59151c1e 100644 --- a/lang/src/compiler/pipeline_v2/flow_entry.hako +++ b/lang/src/compiler/pipeline_v2/flow_entry.hako @@ -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 文字列 diff --git a/lang/src/compiler/pipeline_v2/local_ssa_box.hako b/lang/src/compiler/pipeline_v2/local_ssa_box.hako index 26080f02..90644965 100644 --- a/lang/src/compiler/pipeline_v2/local_ssa_box.hako +++ b/lang/src/compiler/pipeline_v2/local_ssa_box.hako @@ -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) { diff --git a/lang/src/compiler/pipeline_v2/map_helpers_box.hako b/lang/src/compiler/pipeline_v2/map_helpers_box.hako index a5243bfe..6ddc6fe9 100644 --- a/lang/src/compiler/pipeline_v2/map_helpers_box.hako +++ b/lang/src/compiler/pipeline_v2/map_helpers_box.hako @@ -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) diff --git a/lang/src/compiler/pipeline_v2/method_extract_box.hako b/lang/src/compiler/pipeline_v2/method_extract_box.hako index dcad49aa..938ca4fc 100644 --- a/lang/src/compiler/pipeline_v2/method_extract_box.hako +++ b/lang/src/compiler/pipeline_v2/method_extract_box.hako @@ -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 diff --git a/lang/src/compiler/pipeline_v2/mir_builder_box.hako b/lang/src/compiler/pipeline_v2/mir_builder_box.hako index 4782332c..edbe4b25 100644 --- a/lang/src/compiler/pipeline_v2/mir_builder_box.hako +++ b/lang/src/compiler/pipeline_v2/mir_builder_box.hako @@ -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 diff --git a/lang/src/compiler/pipeline_v2/mir_call_box.hako b/lang/src/compiler/pipeline_v2/mir_call_box.hako index 820bb73b..c570efe3 100644 --- a/lang/src/compiler/pipeline_v2/mir_call_box.hako +++ b/lang/src/compiler/pipeline_v2/mir_call_box.hako @@ -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[]) diff --git a/lang/src/compiler/pipeline_v2/name_resolve_box.hako b/lang/src/compiler/pipeline_v2/name_resolve_box.hako index 09ff3c9a..b576fc21 100644 --- a/lang/src/compiler/pipeline_v2/name_resolve_box.hako +++ b/lang/src/compiler/pipeline_v2/name_resolve_box.hako @@ -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 diff --git a/lang/src/compiler/pipeline_v2/namespace_box.hako b/lang/src/compiler/pipeline_v2/namespace_box.hako index 0fc9931e..cae0b308 100644 --- a/lang/src/compiler/pipeline_v2/namespace_box.hako +++ b/lang/src/compiler/pipeline_v2/namespace_box.hako @@ -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 diff --git a/lang/src/compiler/pipeline_v2/new_extract_box.hako b/lang/src/compiler/pipeline_v2/new_extract_box.hako index d693e46d..5c963e05 100644 --- a/lang/src/compiler/pipeline_v2/new_extract_box.hako +++ b/lang/src/compiler/pipeline_v2/new_extract_box.hako @@ -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 diff --git a/lang/src/compiler/pipeline_v2/normalizer_box.hako b/lang/src/compiler/pipeline_v2/normalizer_box.hako index f93811c3..ecd12cd4 100644 --- a/lang/src/compiler/pipeline_v2/normalizer_box.hako +++ b/lang/src/compiler/pipeline_v2/normalizer_box.hako @@ -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) { diff --git a/lang/src/compiler/pipeline_v2/pipeline.hako b/lang/src/compiler/pipeline_v2/pipeline.hako index 73c6eea8..ac934fce 100644 --- a/lang/src/compiler/pipeline_v2/pipeline.hako +++ b/lang/src/compiler/pipeline_v2/pipeline.hako @@ -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) { diff --git a/lang/src/compiler/pipeline_v2/pipeline_emit_box.hako b/lang/src/compiler/pipeline_v2/pipeline_emit_box.hako index 48b0cea4..008925f4 100644 --- a/lang/src/compiler/pipeline_v2/pipeline_emit_box.hako +++ b/lang/src/compiler/pipeline_v2/pipeline_emit_box.hako @@ -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 diff --git a/lang/src/compiler/pipeline_v2/pipeline_helpers_box.hako b/lang/src/compiler/pipeline_v2/pipeline_helpers_box.hako index 68ebe83c..fc0f0370 100644 --- a/lang/src/compiler/pipeline_v2/pipeline_helpers_box.hako +++ b/lang/src/compiler/pipeline_v2/pipeline_helpers_box.hako @@ -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) diff --git a/lang/src/compiler/pipeline_v2/readonly_map_view.hako b/lang/src/compiler/pipeline_v2/readonly_map_view.hako index 5b3c2881..d5fe01c7 100644 --- a/lang/src/compiler/pipeline_v2/readonly_map_view.hako +++ b/lang/src/compiler/pipeline_v2/readonly_map_view.hako @@ -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 diff --git a/lang/src/compiler/pipeline_v2/regex_flow.hako b/lang/src/compiler/pipeline_v2/regex_flow.hako index 6004da28..42dd4fa5 100644 --- a/lang/src/compiler/pipeline_v2/regex_flow.hako +++ b/lang/src/compiler/pipeline_v2/regex_flow.hako @@ -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. diff --git a/lang/src/compiler/pipeline_v2/signature_verifier_box.hako b/lang/src/compiler/pipeline_v2/signature_verifier_box.hako index 20497dbb..828f65f5 100644 --- a/lang/src/compiler/pipeline_v2/signature_verifier_box.hako +++ b/lang/src/compiler/pipeline_v2/signature_verifier_box.hako @@ -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 { diff --git a/lang/src/compiler/pipeline_v2/stage1_args_parser_box.hako b/lang/src/compiler/pipeline_v2/stage1_args_parser_box.hako index 482b3d1b..14f7898e 100644 --- a/lang/src/compiler/pipeline_v2/stage1_args_parser_box.hako +++ b/lang/src/compiler/pipeline_v2/stage1_args_parser_box.hako @@ -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. diff --git a/lang/src/compiler/pipeline_v2/stage1_extract_flow.hako b/lang/src/compiler/pipeline_v2/stage1_extract_flow.hako index 7092fba5..376517ee 100644 --- a/lang/src/compiler/pipeline_v2/stage1_extract_flow.hako +++ b/lang/src/compiler/pipeline_v2/stage1_extract_flow.hako @@ -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) diff --git a/lang/src/compiler/pipeline_v2/stage1_int_args_extract_box.hako b/lang/src/compiler/pipeline_v2/stage1_int_args_extract_box.hako index 40af391b..5563f22a 100644 --- a/lang/src/compiler/pipeline_v2/stage1_int_args_extract_box.hako +++ b/lang/src/compiler/pipeline_v2/stage1_int_args_extract_box.hako @@ -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(内部実装) ===== diff --git a/lang/src/compiler/pipeline_v2/stage1_json_scanner_box.hako b/lang/src/compiler/pipeline_v2/stage1_json_scanner_box.hako index 96a843db..ea8ff1a4 100644 --- a/lang/src/compiler/pipeline_v2/stage1_json_scanner_box.hako +++ b/lang/src/compiler/pipeline_v2/stage1_json_scanner_box.hako @@ -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 diff --git a/lang/src/compiler/pipeline_v2/stage1_name_args_normalizer_box.hako b/lang/src/compiler/pipeline_v2/stage1_name_args_normalizer_box.hako index 8622ca53..541f3cb9 100644 --- a/lang/src/compiler/pipeline_v2/stage1_name_args_normalizer_box.hako +++ b/lang/src/compiler/pipeline_v2/stage1_name_args_normalizer_box.hako @@ -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) { diff --git a/lang/src/compiler/pipeline_v2/terminator_guard_box.hako b/lang/src/compiler/pipeline_v2/terminator_guard_box.hako index dc27420b..e51de07f 100644 --- a/lang/src/compiler/pipeline_v2/terminator_guard_box.hako +++ b/lang/src/compiler/pipeline_v2/terminator_guard_box.hako @@ -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 diff --git a/lang/src/compiler/pipeline_v2/using_resolver_box.hako b/lang/src/compiler/pipeline_v2/using_resolver_box.hako index 355645f6..de069d9f 100644 --- a/lang/src/compiler/pipeline_v2/using_resolver_box.hako +++ b/lang/src/compiler/pipeline_v2/using_resolver_box.hako @@ -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 diff --git a/lang/src/compiler/stage1/emitter_box.hako b/lang/src/compiler/stage1/emitter_box.hako index 772988ee..de874397 100644 --- a/lang/src/compiler/stage1/emitter_box.hako +++ b/lang/src/compiler/stage1/emitter_box.hako @@ -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) { diff --git a/lang/src/compiler/stage1/json_program_box.hako b/lang/src/compiler/stage1/json_program_box.hako index d3be6a46..369e28e4 100644 --- a/lang/src/compiler/stage1/json_program_box.hako +++ b/lang/src/compiler/stage1/json_program_box.hako @@ -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) { diff --git a/lang/src/shared/common/box_helpers.hako b/lang/src/shared/common/box_helpers.hako index d7373c38..5f629f5b 100644 --- a/lang/src/shared/common/box_helpers.hako +++ b/lang/src/shared/common/box_helpers.hako @@ -2,7 +2,7 @@ // 目的: ArrayBox/MapBox の安全な操作を統一的に提供 // 削減: 7ファイル × 2パターン = 14重複 → 1箇所に集約 -using "lang/src/shared/common/string_helpers.hako" as StringHelpers +using selfhost.shared.common.string_helpers as StringHelpers static box BoxHelpers { // ArrayBox.size/1 の結果unwrap (MapBox-wrapped integer対応) diff --git a/lang/src/shared/common/mini_vm_scan.hako b/lang/src/shared/common/mini_vm_scan.hako index 48709592..e90cad03 100644 --- a/lang/src/shared/common/mini_vm_scan.hako +++ b/lang/src/shared/common/mini_vm_scan.hako @@ -1,7 +1,7 @@ // Mini-VM scanning and numeric helpers // Delegation Policy: all scanning primitives route to JsonCursorBox to avoid divergence. -using "lang/src/shared/common/string_helpers.hako" as StringHelpers -using "lang/src/shared/json/json_cursor.hako" as JsonCursorBox +using selfhost.shared.common.string_helpers as StringHelpers +using selfhost.shared.json.core.json_cursor as JsonCursorBox static box MiniVmScan { // helper: find needle from position pos (escape-aware where needed) diff --git a/lang/src/shared/json/core/json_scan.hako b/lang/src/shared/json/core/json_scan.hako index b9d603e5..c3acf2fd 100644 --- a/lang/src/shared/json/core/json_scan.hako +++ b/lang/src/shared/json/core/json_scan.hako @@ -1,8 +1,8 @@ // json_scan.hako — JsonScanBox // Escape-aware JSON structure scanning helpers. -using "lang/src/shared/json/core/string_scan.hako" as StringScanBox -using "lang/src/shared/common/string_helpers.hako" as StringHelpers +using selfhost.shared.json.core.string_scan as StringScanBox +using selfhost.shared.common.string_helpers as StringHelpers static box JsonScanBox { // minimal string→int (delegate to shared helper) diff --git a/lang/src/shared/json/core/string_scan.hako b/lang/src/shared/json/core/string_scan.hako index 88edc188..9c86590d 100644 --- a/lang/src/shared/json/core/string_scan.hako +++ b/lang/src/shared/json/core/string_scan.hako @@ -1,7 +1,7 @@ // string_scan.hako — StringScanBox // Escape-aware string scanning helpers for JSON/text processing. -using "lang/src/shared/common/string_ops.hako" as StringOps +using selfhost.shared.common.string_ops as StringOps static box StringScanBox { // Return the single-character string at index i (empty if out of bounds) diff --git a/lang/src/shared/json/json_cursor.hako b/lang/src/shared/json/json_cursor.hako index fcb72140..296771a5 100644 --- a/lang/src/shared/json/json_cursor.hako +++ b/lang/src/shared/json/json_cursor.hako @@ -2,9 +2,9 @@ // Responsibility: provide a minimal, escape-aware scanning facade used by JsonFragBox // Delegates to StringOps, StringScanBox and JsonScanBox. -using "lang/src/shared/common/string_ops.hako" as StringOps -using "lang/src/shared/json/core/string_scan.hako" as StringScanBox -using "lang/src/shared/json/core/json_scan.hako" as JsonScanBox +using selfhost.shared.common.string_ops as StringOps +using selfhost.shared.json.core.string_scan as StringScanBox +using selfhost.shared.json.core.json_scan as JsonScanBox static box JsonCursorBox { index_of_from(hay, needle, pos) { diff --git a/lang/src/shared/json/json_utils.hako b/lang/src/shared/json/json_utils.hako index 471a12be..aa530c76 100644 --- a/lang/src/shared/json/json_utils.hako +++ b/lang/src/shared/json/json_utils.hako @@ -1,7 +1,7 @@ // JsonUtilsBox — JSON読み取りユーティリティの共通箱 // 責務: JSON値抽出・JSON構造パース・トップレベル配列分割 // Extracted from JsonProgramBox (480行 → 345行, 削減 ~135行) -using "lang/src/shared/common/string_helpers.hako" as StringHelpers +using selfhost.shared.common.string_helpers as StringHelpers static box JsonUtilsBox { // Extract JSON value by key (returns value with '@' + end position marker) diff --git a/lang/src/shared/json/mir_builder2.hako b/lang/src/shared/json/mir_builder2.hako index edee29fc..da0dad93 100644 --- a/lang/src/shared/json/mir_builder2.hako +++ b/lang/src/shared/json/mir_builder2.hako @@ -1,5 +1,5 @@ // mir_builder2.hako — Instance builder(引数渡しバグ回避のため、非staticで内部状態を保持) -using "lang/src/shared/common/string_helpers.hako" as StringHelpers +using selfhost.shared.common.string_helpers as StringHelpers using lang.compiler.emit.common.json_emit as JsonEmitBox using lang.compiler.emit.common.mir_emit as MirEmitBox using lang.compiler.emit.common.header_emit as HeaderEmitBox diff --git a/lang/src/shared/json/mir_builder_min.hako b/lang/src/shared/json/mir_builder_min.hako index 461b6aec..523cb15b 100644 --- a/lang/src/shared/json/mir_builder_min.hako +++ b/lang/src/shared/json/mir_builder_min.hako @@ -1,13 +1,13 @@ // mir_builder_min.nyash — Minimal MIR(JSON v0) builder for selfhost tests // Scope: selfhost only (apps/selfhost/...); no core/runtime changes. -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 using lang.compiler.emit.common.json_emit as JsonEmitBox using lang.compiler.emit.common.mir_emit as MirEmitBox using lang.compiler.emit.common.call_emit as CallEmitBox using lang.compiler.emit.common.newbox_emit as NewBoxEmitBox -using "lang/src/shared/json/json_inst_encode_box.hako" as JsonInstEncodeBox +using selfhost.shared.json.json_inst_encode_box as JsonInstEncodeBox box MirJsonBuilderMin { buf: StringBox diff --git a/lang/src/shared/json/mir_v1_adapter.hako b/lang/src/shared/json/mir_v1_adapter.hako index 8b0aacfa..24da9a64 100644 --- a/lang/src/shared/json/mir_v1_adapter.hako +++ b/lang/src/shared/json/mir_v1_adapter.hako @@ -1,7 +1,7 @@ // mir_v1_adapter.nyash — Minimal JSON v1 (mir_call) to v0 adapter for selfhost // Scope: selfhost only. Transforms op:"mir_call" into legacy v0 ops (call/boxcall/newbox). -using "lang/src/shared/json/json_cursor.hako" as JsonCursorBox +using selfhost.shared.json.core.json_cursor as JsonCursorBox static box MirJsonV1Adapter { // Delegate to JsonCursorBox (escape-aware implementations, fixes 2 escape bugs) diff --git a/lang/src/shared/json/utils/json_frag.hako b/lang/src/shared/json/utils/json_frag.hako index d08f921e..8a765d30 100644 --- a/lang/src/shared/json/utils/json_frag.hako +++ b/lang/src/shared/json/utils/json_frag.hako @@ -2,8 +2,8 @@ // 責務: 文字列JSONから key:int / key:str を簡便に取り出す。 // 非責務: 実行・評価(構造検査やVM実行は他箱に委譲)。 -using "lang/src/shared/json/json_cursor.hako" as JsonCursorBox -using "lang/src/shared/common/string_helpers.hako" as StringHelpers +using selfhost.shared.json.core.json_cursor as JsonCursorBox +using selfhost.shared.common.string_helpers as StringHelpers static box JsonFragBox { // 基本ヘルパ diff --git a/lang/src/shared/mir/block_builder_box.hako b/lang/src/shared/mir/block_builder_box.hako index 02cadf64..67cef3f2 100644 --- a/lang/src/shared/mir/block_builder_box.hako +++ b/lang/src/shared/mir/block_builder_box.hako @@ -1,9 +1,9 @@ // selfhost/shared/mir/block_builder_box.hako // BlockBuilderBox — small helpers to assemble P1 shapes -using "lang/src/shared/mir/mir_schema_box.hako" as MirSchemaBox -using "lang/src/shared/mir/loop_form_box.hako" as LoopFormBox -using "lang/src/shared/common/string_helpers.hako" as StringHelpers +using selfhost.shared.mir.schema as MirSchemaBox +using selfhost.shared.mir.loopform as LoopFormBox +using selfhost.shared.common.string_helpers as StringHelpers static box BlockBuilderBox { diff --git a/lang/src/shared/mir/json_emit_box.hako b/lang/src/shared/mir/json_emit_box.hako index 1425f681..b817daad 100644 --- a/lang/src/shared/mir/json_emit_box.hako +++ b/lang/src/shared/mir/json_emit_box.hako @@ -1,8 +1,8 @@ // selfhost/shared/mir/json_emit_box.hako // JsonEmitBox — Gate C JSON emitter (schema_version 1.0, numbers unwrapped) -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 JsonEmitBox { _expect_map(val, context) { diff --git a/lang/src/shared/mir/loop_form_box.hako b/lang/src/shared/mir/loop_form_box.hako index 35804376..a2d5a371 100644 --- a/lang/src/shared/mir/loop_form_box.hako +++ b/lang/src/shared/mir/loop_form_box.hako @@ -1,7 +1,7 @@ // selfhost/shared/mir/loop_form_box.hako // LoopFormBox — minimal loop structure builder (P2: continue/break snapshots + Exit PHI) -using "lang/src/shared/mir/mir_schema_box.hako" as MirSchemaBox +using selfhost.shared.mir.schema as MirSchemaBox static box LoopFormBox { diff --git a/lang/src/shared/mir/mir_io_box.hako b/lang/src/shared/mir/mir_io_box.hako index a5b0f638..736cca10 100644 --- a/lang/src/shared/mir/mir_io_box.hako +++ b/lang/src/shared/mir/mir_io_box.hako @@ -9,15 +9,15 @@ using "lang/src/vm/boxes/result_box.hako" as Result using "lang/src/vm/boxes/result_helpers.hako" as ResultHelpers -using "lang/src/shared/json/json_cursor.hako" as JsonCursorBox +using selfhost.shared.json.core.json_cursor as JsonCursorBox using "lang/src/shared/json/json_canonical_box.hako" as JsonCanonicalBox using "lang/src/vm/hakorune-vm/function_locator.hako" as FunctionLocatorBox using "lang/src/vm/hakorune-vm/blocks_locator.hako" as BlocksLocatorBox using "lang/src/vm/hakorune-vm/instrs_locator.hako" as InstrsLocatorBox using "lang/src/vm/hakorune-vm/backward_object_scanner.hako" as BackwardObjectScannerBox using "lang/src/vm/hakorune-vm/block_iterator.hako" as BlockIteratorBox -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 MirIoBox { // Internal: provider gate (yyjson) diff --git a/lang/src/shared/mir/mir_schema_box.hako b/lang/src/shared/mir/mir_schema_box.hako index 4837ce93..48223914 100644 --- a/lang/src/shared/mir/mir_schema_box.hako +++ b/lang/src/shared/mir/mir_schema_box.hako @@ -1,7 +1,7 @@ // selfhost/shared/mir/mir_schema_box.hako // MirSchemaBox — minimal MIR(JSON v0) constructors (P1 scope) -using "lang/src/shared/common/string_helpers.hako" as StringHelpers +using selfhost.shared.common.string_helpers as StringHelpers static box MirSchemaBox { _expect_map(val, context) { diff --git a/lang/src/vm/boxes/cfg_navigator.hako b/lang/src/vm/boxes/cfg_navigator.hako index 4cc5366d..38d327b0 100644 --- a/lang/src/vm/boxes/cfg_navigator.hako +++ b/lang/src/vm/boxes/cfg_navigator.hako @@ -1,6 +1,6 @@ // cfg_navigator.hako — CfgNavigatorBox(ブロックの先頭/末尾シーク) -using "lang/src/shared/common/string_ops.hako" as StringOps +using selfhost.shared.common.string_ops as StringOps using "lang/src/shared/json/json_cursor.hako" as JsonCursorBox static box CfgNavigatorBox { diff --git a/lang/src/vm/boxes/mir_vm_m2.hako b/lang/src/vm/boxes/mir_vm_m2.hako index 06d31500..00d8f332 100644 --- a/lang/src/vm/boxes/mir_vm_m2.hako +++ b/lang/src/vm/boxes/mir_vm_m2.hako @@ -1,7 +1,7 @@ // mir_vm_m2.nyash — Ny製の最小MIR(JSON v0)実行器(M2: const/binop/ret) using "lang/src/shared/common/string_helpers.hako" as StringHelpers -using "lang/src/shared/common/string_ops.hako" as StringOps +using selfhost.shared.common.string_ops as StringOps static box MirVmM2 { _str_to_int(s) { return StringHelpers.to_i64(s) } diff --git a/lang/src/vm/boxes/mir_vm_min.hako b/lang/src/vm/boxes/mir_vm_min.hako index a9e2b04f..f6a12d5d 100644 --- a/lang/src/vm/boxes/mir_vm_min.hako +++ b/lang/src/vm/boxes/mir_vm_min.hako @@ -1,7 +1,7 @@ // mir_vm_min.hako — Ny製の最小MIR(JSON v0)実行器(const/compare/copy/branch/jump/ret の最小) using "lang/src/vm/boxes/op_handlers.hako" as OpHandlersBox using "lang/src/shared/common/string_helpers.hako" as StringHelpers -using "lang/src/shared/common/string_ops.hako" as StringOps +using selfhost.shared.common.string_ops as StringOps using "lang/src/shared/json/utils/json_frag.hako" as JsonFragBox using "lang/src/shared/json/json_cursor.hako" as JsonCursorBox using "lang/src/vm/boxes/operator_box.hako" as OperatorBox diff --git a/lang/src/vm/boxes/seam_inspector.hako b/lang/src/vm/boxes/seam_inspector.hako index 29ac1e7f..cd0333a8 100644 --- a/lang/src/vm/boxes/seam_inspector.hako +++ b/lang/src/vm/boxes/seam_inspector.hako @@ -2,7 +2,7 @@ // Usage: import and call report(text) or analyze_dump_file(path) using "lang/src/shared/common/string_helpers.hako" as StringHelpers -using "lang/src/shared/common/string_ops.hako" as StringOps +using selfhost.shared.common.string_ops as StringOps using "lang/src/shared/common/mini_vm_scan.hako" as MiniVmScan static box SeamInspector { diff --git a/lang/src/vm/collect_mixed_smoke.hako b/lang/src/vm/collect_mixed_smoke.hako index 0d1cf7de..268dbe07 100644 --- a/lang/src/vm/collect_mixed_smoke.hako +++ b/lang/src/vm/collect_mixed_smoke.hako @@ -1,5 +1,5 @@ using "lang/src/shared/common/string_helpers.hako" as StringHelpers -using "lang/src/shared/common/string_ops.hako" as StringOps +using selfhost.shared.common.string_ops as StringOps using "lang/src/shared/common/mini_vm_scan.hako" as MiniVmScan static box Main { // --- minimal helpers --- diff --git a/lang/src/vm/flow_runner.hako b/lang/src/vm/flow_runner.hako index d8b2a8b8..13ef94ff 100644 --- a/lang/src/vm/flow_runner.hako +++ b/lang/src/vm/flow_runner.hako @@ -2,7 +2,7 @@ using "lang/src/compiler/pipeline_v2/flow_entry.hako" as FlowEntryBox using hakorune.vm.mir_min as MirVmMin -using "lang/src/shared/common/string_ops.hako" as StringOps +using selfhost.shared.common.string_ops as StringOps static box FlowRunner { _read_digits(text, pos) { local out = "" local i = pos loop(true) { local ch = text.substring(i, i+1) if ch == "" { break } if ch >= "0" && ch <= "9" { out = out + ch i = i + 1 } else { break } } return out } diff --git a/lang/src/vm/hakorune-vm/args_extractor.hako b/lang/src/vm/hakorune-vm/args_extractor.hako index ecb552de..d5699dd4 100644 --- a/lang/src/vm/hakorune-vm/args_extractor.hako +++ b/lang/src/vm/hakorune-vm/args_extractor.hako @@ -1,7 +1,7 @@ // ArgsExtractorBox - Extract and load arguments from MirCall JSON // Single Responsibility: Parse args array, load values from registers -using "lang/src/shared/common/string_ops.hako" as StringOps +using selfhost.shared.common.string_ops as StringOps using "lang/src/shared/common/string_helpers.hako" as StringHelpers using "lang/src/vm/hakorune-vm/value_manager.hako" as ValueManagerBox diff --git a/lang/src/vm/hakorune-vm/binop_handler.hako b/lang/src/vm/hakorune-vm/binop_handler.hako index a7ac9d4b..f342186b 100644 --- a/lang/src/vm/hakorune-vm/binop_handler.hako +++ b/lang/src/vm/hakorune-vm/binop_handler.hako @@ -2,7 +2,7 @@ // Handles: %dst = %lhs op_kind %rhs (Add/Sub/Mul/Div/Mod) using "lang/src/shared/common/string_helpers.hako" as StringHelpers -using "lang/src/shared/common/string_ops.hako" as StringOps +using selfhost.shared.common.string_ops as StringOps using "lang/src/vm/boxes/result_box.hako" as Result using "lang/src/vm/hakorune-vm/value_manager.hako" as ValueManagerBox using "lang/src/vm/hakorune-vm/reg_guard.hako" as RegGuardBox diff --git a/lang/src/vm/hakorune-vm/block_mapper.hako b/lang/src/vm/hakorune-vm/block_mapper.hako index ec61f9c0..63b365a2 100644 --- a/lang/src/vm/hakorune-vm/block_mapper.hako +++ b/lang/src/vm/hakorune-vm/block_mapper.hako @@ -3,7 +3,7 @@ using "lang/src/shared/json/json_cursor.hako" as JsonCursorBox using "lang/src/shared/common/string_helpers.hako" as StringHelpers -using "lang/src/shared/common/string_ops.hako" as StringOps +using selfhost.shared.common.string_ops as StringOps using "lang/src/vm/boxes/result_box.hako" as Result using "lang/src/vm/hakorune-vm/function_locator.hako" as FunctionLocatorBox using "lang/src/vm/hakorune-vm/blocks_locator.hako" as BlocksLocatorBox diff --git a/lang/src/vm/hakorune-vm/callee_parser.hako b/lang/src/vm/hakorune-vm/callee_parser.hako index cb20e971..481600f6 100644 --- a/lang/src/vm/hakorune-vm/callee_parser.hako +++ b/lang/src/vm/hakorune-vm/callee_parser.hako @@ -1,7 +1,7 @@ // CalleeParserBox - Extract callee information from MirCall JSON // Single Responsibility: Parse callee field and extract type/name -using "lang/src/shared/common/string_ops.hako" as StringOps +using selfhost.shared.common.string_ops as StringOps using "lang/src/shared/common/string_helpers.hako" as StringHelpers using "lang/src/vm/hakorune-vm/json_field_extractor.hako" as JsonFieldExtractor diff --git a/lang/src/vm/hakorune-vm/closure_call_handler.hako b/lang/src/vm/hakorune-vm/closure_call_handler.hako index e907a00e..ba89bd90 100644 --- a/lang/src/vm/hakorune-vm/closure_call_handler.hako +++ b/lang/src/vm/hakorune-vm/closure_call_handler.hako @@ -3,7 +3,7 @@ // Note: Full closure calling via Callee::Value is Phase 4 Day 16 using "lang/src/vm/boxes/result_box.hako" as Result -using "lang/src/shared/common/string_ops.hako" as StringOps +using selfhost.shared.common.string_ops as StringOps using "lang/src/shared/common/string_helpers.hako" as StringHelpers using "lang/src/shared/json/json_cursor.hako" as JsonCursorBox diff --git a/lang/src/vm/hakorune-vm/const_handler.hako b/lang/src/vm/hakorune-vm/const_handler.hako index f2965bf0..c56d7531 100644 --- a/lang/src/vm/hakorune-vm/const_handler.hako +++ b/lang/src/vm/hakorune-vm/const_handler.hako @@ -2,7 +2,7 @@ // Handles: %dst = const value using "lang/src/shared/common/string_helpers.hako" as StringHelpers -using "lang/src/shared/common/string_ops.hako" as StringOps +using selfhost.shared.common.string_ops as StringOps using "lang/src/vm/boxes/result_box.hako" as Result using "lang/src/vm/hakorune-vm/value_manager.hako" as ValueManagerBox using "lang/src/vm/hakorune-vm/json_field_extractor.hako" as JsonFieldExtractor diff --git a/lang/src/vm/hakorune-vm/hakorune_vm_core.hako b/lang/src/vm/hakorune-vm/hakorune_vm_core.hako index ce2769e4..f296ebf3 100644 --- a/lang/src/vm/hakorune-vm/hakorune_vm_core.hako +++ b/lang/src/vm/hakorune-vm/hakorune_vm_core.hako @@ -4,7 +4,7 @@ // Phase 1 Day 3: 制御フロー実装(Branch/Jump/Phi)- 箱化モジュール化 using "lang/src/shared/json/json_cursor.hako" as JsonCursorBox using "lang/src/shared/common/string_helpers.hako" as StringHelpers -using "lang/src/shared/common/string_ops.hako" as StringOps +using selfhost.shared.common.string_ops as StringOps using "lang/src/vm/hakorune-vm/json_scan_guard.hako" as JsonScanGuardBox using "lang/src/vm/boxes/result_box.hako" as Result // Phase 1 Day 3: 箱化モジュール化 diff --git a/lang/src/vm/hakorune-vm/instruction_dispatcher.hako b/lang/src/vm/hakorune-vm/instruction_dispatcher.hako index dbbd3268..396ad1cd 100644 --- a/lang/src/vm/hakorune-vm/instruction_dispatcher.hako +++ b/lang/src/vm/hakorune-vm/instruction_dispatcher.hako @@ -1,7 +1,7 @@ // InstructionDispatcherBox - Dispatch instructions to specific handlers // Single Responsibility: Extract op field and route to correct handler -using "lang/src/shared/common/string_ops.hako" as StringOps +using selfhost.shared.common.string_ops as StringOps using "lang/src/vm/boxes/result_box.hako" as Result using "lang/src/vm/hakorune-vm/json_field_extractor.hako" as JsonFieldExtractor using "lang/src/vm/hakorune-vm/value_manager.hako" as ValueManagerBox diff --git a/lang/src/vm/hakorune-vm/json_field_extractor.hako b/lang/src/vm/hakorune-vm/json_field_extractor.hako index aa05c11d..d4f8f88f 100644 --- a/lang/src/vm/hakorune-vm/json_field_extractor.hako +++ b/lang/src/vm/hakorune-vm/json_field_extractor.hako @@ -2,7 +2,7 @@ // Centralizes JSON field parsing logic using "lang/src/shared/common/string_helpers.hako" as StringHelpers -using "lang/src/shared/common/string_ops.hako" as StringOps +using selfhost.shared.common.string_ops as StringOps static box JsonFieldExtractor { // Extract integer field from JSON diff --git a/lang/src/vm/hakorune-vm/newbox_handler.hako b/lang/src/vm/hakorune-vm/newbox_handler.hako index fbc64ca0..cf204160 100644 --- a/lang/src/vm/hakorune-vm/newbox_handler.hako +++ b/lang/src/vm/hakorune-vm/newbox_handler.hako @@ -4,7 +4,7 @@ using "lang/src/vm/boxes/result_box.hako" as Result using "lang/src/vm/hakorune-vm/value_manager.hako" as ValueManagerBox using "lang/src/vm/hakorune-vm/json_field_extractor.hako" as JsonFieldExtractor -using "lang/src/shared/common/string_ops.hako" as StringOps +using selfhost.shared.common.string_ops as StringOps using "lang/src/vm/gc/gc_runtime.hako" as GcRuntime static box NewBoxHandlerBox { diff --git a/lang/src/vm/hakorune-vm/phi_handler.hako b/lang/src/vm/hakorune-vm/phi_handler.hako index aa5b3ec6..040b6fef 100644 --- a/lang/src/vm/hakorune-vm/phi_handler.hako +++ b/lang/src/vm/hakorune-vm/phi_handler.hako @@ -3,7 +3,7 @@ using "lang/src/shared/json/json_cursor.hako" as JsonCursorBox using "lang/src/shared/common/string_helpers.hako" as StringHelpers -using "lang/src/shared/common/string_ops.hako" as StringOps +using selfhost.shared.common.string_ops as StringOps using "lang/src/vm/boxes/result_box.hako" as Result using "lang/src/vm/hakorune-vm/core_bridge_ops.hako" as CoreBridgeOps diff --git a/lang/src/vm/hakorune-vm/terminator_handler.hako b/lang/src/vm/hakorune-vm/terminator_handler.hako index acb7b585..4949165a 100644 --- a/lang/src/vm/hakorune-vm/terminator_handler.hako +++ b/lang/src/vm/hakorune-vm/terminator_handler.hako @@ -2,7 +2,7 @@ // Strategy: 箱化モジュール化 - Ret/Jump/Branch を分離 using "lang/src/shared/common/string_helpers.hako" as StringHelpers -using "lang/src/shared/common/string_ops.hako" as StringOps +using selfhost.shared.common.string_ops as StringOps using "lang/src/vm/boxes/result_box.hako" as Result using "lang/src/vm/hakorune-vm/instrs_locator.hako" as InstrsLocatorBox using "lang/src/vm/hakorune-vm/backward_object_scanner.hako" as BackwardObjectScannerBox diff --git a/lang/src/vm/hakorune-vm/unaryop_handler.hako b/lang/src/vm/hakorune-vm/unaryop_handler.hako index 6570af9a..f5ea9962 100644 --- a/lang/src/vm/hakorune-vm/unaryop_handler.hako +++ b/lang/src/vm/hakorune-vm/unaryop_handler.hako @@ -2,7 +2,7 @@ // Handles: %dst = op_kind %operand (Neg/Not/BitNot) using "lang/src/shared/common/string_helpers.hako" as StringHelpers -using "lang/src/shared/common/string_ops.hako" as StringOps +using selfhost.shared.common.string_ops as StringOps using "lang/src/vm/boxes/result_box.hako" as Result using "lang/src/vm/hakorune-vm/value_manager.hako" as ValueManagerBox using "lang/src/vm/hakorune-vm/reg_guard.hako" as RegGuardBox diff --git a/nyash.toml b/nyash.toml index 36a3f27d..3f1c05f4 100644 --- a/nyash.toml +++ b/nyash.toml @@ -72,12 +72,52 @@ path = "lang/src/shared/common/string_helpers.hako" "lang.compiler.stage1.emitter_box" = "lang/src/compiler/stage1/emitter_box.hako" "lang.compiler.pipeline_v2.flow_entry" = "lang/src/compiler/pipeline_v2/flow_entry.hako" "lang.compiler.pipeline_v2.pipeline" = "lang/src/compiler/pipeline_v2/pipeline.hako" +"lang.compiler.pipeline_v2.stage1_extract_flow" = "lang/src/compiler/pipeline_v2/stage1_extract_flow.hako" +"lang.compiler.pipeline_v2.emit_return_box" = "lang/src/compiler/pipeline_v2/emit_return_box.hako" +"lang.compiler.pipeline_v2.emit_binop_box" = "lang/src/compiler/pipeline_v2/emit_binop_box.hako" +"lang.compiler.pipeline_v2.emit_compare_box" = "lang/src/compiler/pipeline_v2/emit_compare_box.hako" +"lang.compiler.pipeline_v2.regex_flow" = "lang/src/compiler/pipeline_v2/regex_flow.hako" +"lang.compiler.pipeline_v2.emit_call_box" = "lang/src/compiler/pipeline_v2/emit_call_box.hako" +"lang.compiler.pipeline_v2.emit_method_box" = "lang/src/compiler/pipeline_v2/emit_method_box.hako" +"lang.compiler.pipeline_v2.emit_newbox_box" = "lang/src/compiler/pipeline_v2/emit_newbox_box.hako" +"lang.compiler.pipeline_v2.mir_call_box" = "lang/src/compiler/pipeline_v2/mir_call_box.hako" +"lang.compiler.pipeline_v2.compare_extract_box" = "lang/src/compiler/pipeline_v2/compare_extract_box.hako" +"lang.compiler.pipeline_v2.normalizer_box" = "lang/src/compiler/pipeline_v2/normalizer_box.hako" +"lang.compiler.pipeline_v2.map_helpers_box" = "lang/src/compiler/pipeline_v2/map_helpers_box.hako" +"lang.compiler.pipeline_v2.call_extract_box" = "lang/src/compiler/pipeline_v2/call_extract_box.hako" +"lang.compiler.pipeline_v2.method_extract_box" = "lang/src/compiler/pipeline_v2/method_extract_box.hako" +"lang.compiler.pipeline_v2.new_extract_box" = "lang/src/compiler/pipeline_v2/new_extract_box.hako" +"lang.compiler.pipeline_v2.using_resolver_box" = "lang/src/compiler/pipeline_v2/using_resolver_box.hako" +"lang.compiler.pipeline_v2.namespace_box" = "lang/src/compiler/pipeline_v2/namespace_box.hako" +"lang.compiler.pipeline_v2.signature_verifier_box" = "lang/src/compiler/pipeline_v2/signature_verifier_box.hako" +"lang.compiler.pipeline_v2.stage1_json_scanner_box" = "lang/src/compiler/pipeline_v2/stage1_json_scanner_box.hako" +"lang.compiler.pipeline_v2.stage1_name_args_normalizer_box" = "lang/src/compiler/pipeline_v2/stage1_name_args_normalizer_box.hako" +"lang.compiler.pipeline_v2.alias_preflight_box" = "lang/src/compiler/pipeline_v2/alias_preflight_box.hako" +"lang.compiler.pipeline_v2.stage1_args_parser_box" = "lang/src/compiler/pipeline_v2/stage1_args_parser_box.hako" +"lang.compiler.pipeline_v2.pipeline_helpers_box" = "lang/src/compiler/pipeline_v2/pipeline_helpers_box.hako" +"lang.compiler.pipeline_v2.backend_box" = "lang/src/compiler/pipeline_v2/backend_box.hako" +"lang.compiler.pipeline_v2.execution_pipeline_box" = "lang/src/compiler/pipeline_v2/execution_pipeline_box.hako" +"lang.compiler.pipeline_v2.mir_builder_box" = "lang/src/compiler/pipeline_v2/mir_builder_box.hako" +"lang.compiler.pipeline_v2.name_resolve_box" = "lang/src/compiler/pipeline_v2/name_resolve_box.hako" +"lang.compiler.pipeline_v2.pipeline_emit_box" = "lang/src/compiler/pipeline_v2/pipeline_emit_box.hako" +"lang.compiler.pipeline_v2.readonly_map_view" = "lang/src/compiler/pipeline_v2/readonly_map_view.hako" +"lang.compiler.pipeline_v2.stage1_int_args_extract_box" = "lang/src/compiler/pipeline_v2/stage1_int_args_extract_box.hako" +"lang.compiler.pipeline_v2.terminator_guard_box" = "lang/src/compiler/pipeline_v2/terminator_guard_box.hako" +"lang.compiler.pipeline_v2.emit_mir_flow" = "lang/src/compiler/pipeline_v2/emit_mir_flow.hako" +"lang.compiler.pipeline_v2.emit_mir_flow_map" = "lang/src/compiler/pipeline_v2/emit_mir_flow_map.hako" +"selfhost.shared.json.mir_v1_meta_inject_box" = "lang/src/shared/json/mir_v1_meta_inject_box.hako" +"selfhost.shared.json.json_inst_encode_box" = "lang/src/shared/json/json_inst_encode_box.hako" +"selfhost.shared.common.string_ops" = "lang/src/shared/common/string_ops.hako" "lang.compiler.pipeline_v2.using_resolver" = "lang/src/compiler/pipeline_v2/using_resolver_box.hako" -"lang.compiler.builder.ssa.local" = "lang/src/compiler/builder/ssa/local.hako" +"lang.compiler.builder.ssa.localvar" = "lang/src/compiler/builder/ssa/local_ssa.hako" "lang.compiler.builder.ssa.loop" = "lang/src/compiler/builder/ssa/loopssa.hako" "lang.compiler.builder.ssa.cond_inserter" = "lang/src/compiler/builder/ssa/cond_inserter.hako" "lang.compiler.builder.rewrite.special" = "lang/src/compiler/builder/rewrite/special.hako" "lang.compiler.builder.rewrite.known" = "lang/src/compiler/builder/rewrite/known.hako" +"lang.compiler.pipeline_v2.localvar_ssa_box" = "lang/src/compiler/pipeline_v2/local_ssa_box.hako" +"lang.compiler.entry.compiler" = "lang/src/compiler/entry/compiler.hako" +"lang.compiler.entry.compiler_stageb" = "lang/src/compiler/entry/compiler_stageb.hako" +"lang.compiler.emit.mir_emitter_box" = "lang/src/compiler/emit/mir_emitter_box.hako" "lang.compiler.emit.common.json_emit_box" = "lang/src/compiler/emit/common/json_emit_box.hako" "lang.compiler.emit.common.mir_emit_box" = "lang/src/compiler/emit/common/mir_emit_box.hako" "lang.compiler.emit.common.call_emit_box" = "lang/src/compiler/emit/common/call_emit_box.hako" @@ -95,13 +135,16 @@ path = "lang/src/shared/common/string_helpers.hako" "selfhost.shared.common.mini_vm_binop" = "lang/src/shared/common/mini_vm_binop.hako" "selfhost.shared.common.mini_vm_compare" = "lang/src/shared/common/mini_vm_compare.hako" "selfhost.shared.common.string_helpers" = "lang/src/shared/common/string_helpers.hako" -"selfhost.shared.common.string_ops" = "lang/src/shared/common/string_ops.hako" "selfhost.shared.common.box_helpers" = "lang/src/shared/common/box_helpers.hako" "selfhost.shared.json.mir_builder_min" = "lang/src/shared/json/mir_builder_min.hako" "selfhost.shared.json.mir_v1_adapter" = "lang/src/shared/json/mir_v1_adapter.hako" "selfhost.shared.json.core.json_cursor" = "lang/src/shared/json/json_cursor.hako" +"selfhost.shared.json.core.string_scan" = "lang/src/shared/json/core/string_scan.hako" +"selfhost.shared.json.core.json_scan" = "lang/src/shared/json/core/json_scan.hako" "selfhost.shared.json.utils.json_utils" = "lang/src/shared/json/json_utils.hako" +"selfhost.shared.json.stringify" = "lang/src/shared/json/stringify.hako" "selfhost.shared.mir.schema" = "lang/src/shared/mir/mir_schema_box.hako" +"selfhost.shared.mir.loopform" = "lang/src/shared/mir/loop_form_box.hako" "selfhost.shared.mir.builder" = "lang/src/shared/mir/block_builder_box.hako" "selfhost.shared.mir.io" = "lang/src/shared/mir/mir_io_box.hako" "selfhost.shared.mir.json_emit" = "lang/src/shared/mir/json_emit_box.hako" diff --git a/src/parser/declarations/box_definition.rs b/src/parser/declarations/box_definition.rs index b4c9a239..bd1bb7b2 100644 --- a/src/parser/declarations/box_definition.rs +++ b/src/parser/declarations/box_definition.rs @@ -111,7 +111,15 @@ impl NyashParser { /// box宣言をパース: box Name { fields... methods... } pub fn parse_box_declaration(&mut self) -> Result { - self.consume(TokenType::BOX)?; + // Accept either 'box' or 'flow' (flow is syntactic sugar for static box) + if !self.match_token(&TokenType::BOX) && !self.match_token(&TokenType::FLOW) { + return Err(ParseError::UnexpectedToken { + found: self.current_token().token_type.clone(), + expected: "'box' or 'flow'".to_string(), + line: self.current_token().line, + }); + } + self.advance(); // consume BOX or FLOW let (name, type_parameters, extends, implements) = box_header::parse_header(self)?; diff --git a/src/parser/declarations/static_box.rs b/src/parser/declarations/static_box.rs index 4f59f77e..1b0839ba 100644 --- a/src/parser/declarations/static_box.rs +++ b/src/parser/declarations/static_box.rs @@ -106,23 +106,12 @@ impl NyashParser { self.current_token().token_type ); } - if self.match_token(&TokenType::RBRACE) { - self.consume(TokenType::RBRACE)?; - } else if self.is_at_end() { - // Safety valve: if EOF is reached right after members (common at file end), - // accept as implicitly closed static box. This keeps behavior stable for - // well-formed sources and avoids false negatives on seam edges. - if std::env::var("NYASH_PARSER_TRACE_STATIC").ok().as_deref() == Some("1") { - eprintln!("[parser][static-box] accepting EOF as closing '}}' (at file end)"); - } - } else { - // Still something else here; report a structured error - let line = self.current_token().line; - return Err(ParseError::UnexpectedToken { - expected: "RBRACE".to_string(), - found: self.current_token().token_type.clone(), - line, - }); + + // Consume the closing RBRACE of the static box + self.consume(TokenType::RBRACE)?; + + if std::env::var("NYASH_PARSER_TRACE_STATIC").ok().as_deref() == Some("1") { + eprintln!("[parser][static-box] successfully closed static box '{}'", name); } // 🔥 Static初期化ブロックから依存関係を抽出 diff --git a/src/parser/statements/declarations.rs b/src/parser/statements/declarations.rs index 7445d7cc..dc534ab2 100644 --- a/src/parser/statements/declarations.rs +++ b/src/parser/statements/declarations.rs @@ -15,6 +15,7 @@ impl NyashParser { pub(super) fn parse_declaration_statement(&mut self) -> Result { match &self.current_token().token_type { TokenType::BOX => self.parse_box_declaration(), + TokenType::FLOW => self.parse_box_declaration(), // flow is syntactic sugar for static box TokenType::IMPORT => self.parse_import(), TokenType::INTERFACE => self.parse_interface_box_declaration(), TokenType::GLOBAL => self.parse_global_var(), diff --git a/src/parser/statements/mod.rs b/src/parser/statements/mod.rs index 10009bb9..6a6816ee 100644 --- a/src/parser/statements/mod.rs +++ b/src/parser/statements/mod.rs @@ -194,6 +194,7 @@ impl NyashParser { // Declarations TokenType::BOX + | TokenType::FLOW | TokenType::IMPORT | TokenType::INTERFACE | TokenType::GLOBAL diff --git a/src/runner/child_env.rs b/src/runner/child_env.rs index 62d0f7ba..31383d5d 100644 --- a/src/runner/child_env.rs +++ b/src/runner/child_env.rs @@ -19,3 +19,21 @@ pub fn post_run_exit_if_oob_strict_triggered() -> ! { std::process::exit(0) } +/// Apply a consistent child environment for selfhost/core wrapper executions. +/// - Forces JSON-only quiet pipe +/// - Disables plugins to avoid host-side side effects +/// - Disables file-based using resolution (namespace-first policy) +/// - Skips nyash.toml env injection to reduce drift +pub fn apply_core_wrapper_env(cmd: &mut std::process::Command) { + // Remove noisy or recursive toggles + cmd.env_remove("NYASH_USE_NY_COMPILER"); + cmd.env_remove("NYASH_CLI_VERBOSE"); + // Enforce quiet JSON capture + cmd.env("NYASH_JSON_ONLY", "1"); + // Restrict environment to avoid plugin/using drift + cmd.env("NYASH_DISABLE_PLUGINS", "1"); + cmd.env("NYASH_SKIP_TOML_ENV", "1"); + cmd.env("NYASH_USING_AST", "0"); + cmd.env("NYASH_ALLOW_USING_FILE", "0"); + cmd.env("HAKO_ALLOW_USING_FILE", "0"); +} diff --git a/src/runner/dispatch.rs b/src/runner/dispatch.rs index 7615ae4d..f96ec0fd 100644 --- a/src/runner/dispatch.rs +++ b/src/runner/dispatch.rs @@ -37,7 +37,7 @@ pub(crate) fn execute_file_with_backend(runner: &NyashRunner, filename: &str) { return; } Err(e) => { - eprintln!("❌ Direct bridge parse error: {}", e); + eprintln!("❌ Direct bridge parse error in {}: {}", filename, e); process::exit(1); } } @@ -56,7 +56,7 @@ pub(crate) fn execute_file_with_backend(runner: &NyashRunner, filename: &str) { let ast = match NyashParser::parse_from_string(&code) { Ok(ast) => ast, Err(e) => { - eprintln!("❌ Parse error: {}", e); + eprintln!("❌ Parse error in {}: {}", filename, e); process::exit(1); } }; @@ -79,7 +79,7 @@ pub(crate) fn execute_file_with_backend(runner: &NyashRunner, filename: &str) { }; let ast = match NyashParser::parse_from_string(&code) { Ok(ast) => ast, - Err(e) => { eprintln!("❌ Parse error: {}", e); process::exit(1); } + Err(e) => { eprintln!("❌ Parse error in {}: {}", filename, e); process::exit(1); } }; let expanded = if crate::r#macro::enabled() { let a = crate::r#macro::maybe_expand_and_dump(&ast, false); diff --git a/src/runner/modes/common.rs b/src/runner/modes/common.rs index 33765c62..f977ade1 100644 --- a/src/runner/modes/common.rs +++ b/src/runner/modes/common.rs @@ -114,7 +114,7 @@ impl NyashRunner { ast } Err(e) => { - eprintln!("❌ Parse error: {}", e); + eprintln!("❌ Parse error in {}: {}", filename, e); process::exit(1); } }; diff --git a/src/runner/modes/common_util/resolve/strip.rs b/src/runner/modes/common_util/resolve/strip.rs index 4da67e55..a9d9b525 100644 --- a/src/runner/modes/common_util/resolve/strip.rs +++ b/src/runner/modes/common_util/resolve/strip.rs @@ -72,7 +72,9 @@ pub fn collect_using_and_strip( // can organize their modules via file paths. if (prod || !crate::config::env::allow_using_file()) && !inside_pkg { return Err(format!( - "using: file paths are disallowed in this profile. Add it to nyash.toml [using] (packages/aliases) and reference by name: {}", + "{}:{}: using: file paths are disallowed in this profile. Add it to nyash.toml [using] (packages/aliases) and reference by name: {}", + filename, + line_no, target )); } @@ -220,7 +222,9 @@ pub fn collect_using_and_strip( } } else { return Err(format!( - "using: '{}' not found in nyash.toml [using]. Define a package or alias and use its name (prod profile)", + "{}:{}: using: '{}' not found in nyash.toml [using]. Define a package or alias and use its name (prod profile)", + filename, + line_no, target )); } @@ -311,7 +315,7 @@ pub fn collect_using_and_strip( prelude_paths.push(path_str); } } - Err(e) => return Err(format!("using: {}", e)), + Err(e) => return Err(format!("{}:{}: using: {}", filename, line_no, e)), } } continue; diff --git a/src/runner/modes/common_util/selfhost/child.rs b/src/runner/modes/common_util/selfhost/child.rs index 0e815ff9..13ee29e1 100644 --- a/src/runner/modes/common_util/selfhost/child.rs +++ b/src/runner/modes/common_util/selfhost/child.rs @@ -17,6 +17,8 @@ pub fn run_ny_program_capture_json( ) -> Option { use std::process::Command; let mut cmd = Command::new(exe); + // Apply consistent child env to avoid plugin/using drift + crate::runner::child_env::apply_core_wrapper_env(&mut cmd); cmd.arg("--backend").arg("vm").arg(program); for a in extra_args { cmd.arg(a); diff --git a/src/runner/modes/cranelift.rs b/src/runner/modes/cranelift.rs index fb1daf18..4f2f64fc 100644 --- a/src/runner/modes/cranelift.rs +++ b/src/runner/modes/cranelift.rs @@ -13,7 +13,7 @@ impl NyashRunner { // Parse → AST let ast = match NyashParser::parse_from_string(&code) { Ok(ast) => ast, - Err(e) => { eprintln!("❌ Parse error: {}", e); process::exit(1); } + Err(e) => { eprintln!("❌ Parse error in {}: {}", filename, e); process::exit(1); } }; let ast = crate::r#macro::maybe_expand_and_dump(&ast, false); // AST → MIR diff --git a/src/runner/modes/llvm.rs b/src/runner/modes/llvm.rs index d7edef8f..dec9f1b7 100644 --- a/src/runner/modes/llvm.rs +++ b/src/runner/modes/llvm.rs @@ -58,7 +58,7 @@ impl NyashRunner { let main_ast = match NyashParser::parse_from_string(code_ref) { Ok(ast) => ast, Err(e) => { - eprintln!("❌ Parse error: {}", e); + eprintln!("❌ Parse error in {}: {}", filename, e); process::exit(1); } }; diff --git a/src/runner/modes/mir.rs b/src/runner/modes/mir.rs index 9482d352..c89c1bf7 100644 --- a/src/runner/modes/mir.rs +++ b/src/runner/modes/mir.rs @@ -21,7 +21,7 @@ impl NyashRunner { let ast = match NyashParser::parse_from_string(&code) { Ok(ast) => ast, Err(e) => { - eprintln!("❌ Parse error: {}", e); + eprintln!("❌ Parse error in {}: {}", filename, e); process::exit(1); } }; diff --git a/src/runner/modes/mir_interpreter.rs b/src/runner/modes/mir_interpreter.rs index b040f526..cc774637 100644 --- a/src/runner/modes/mir_interpreter.rs +++ b/src/runner/modes/mir_interpreter.rs @@ -15,7 +15,7 @@ impl NyashRunner { // Parse to AST let ast = match NyashParser::parse_from_string(&code) { Ok(ast) => ast, - Err(e) => { eprintln!("❌ Parse error: {}", e); process::exit(1); } + Err(e) => { eprintln!("❌ Parse error in {}: {}", filename, e); process::exit(1); } }; let ast = crate::r#macro::maybe_expand_and_dump(&ast, false); diff --git a/src/runner/modes/pyvm.rs b/src/runner/modes/pyvm.rs index 7ea3f1ee..72bf4bb5 100644 --- a/src/runner/modes/pyvm.rs +++ b/src/runner/modes/pyvm.rs @@ -82,7 +82,7 @@ pub fn execute_pyvm_only(runner: &NyashRunner, filename: &str) { let ast = match NyashParser::parse_from_string(&code) { Ok(ast) => ast, Err(e) => { - eprintln!("❌ Parse error: {}", e); + eprintln!("❌ Parse error in {}: {}", filename, e); process::exit(1); } }; diff --git a/src/runner/modes/vm.rs b/src/runner/modes/vm.rs index 8eef5ef9..08a28109 100644 --- a/src/runner/modes/vm.rs +++ b/src/runner/modes/vm.rs @@ -154,7 +154,8 @@ impl NyashRunner { let main_ast = match NyashParser::parse_from_string(code_ref) { Ok(ast) => ast, Err(e) => { - eprintln!("❌ Parse error: {}", e); + eprintln!("❌ Parse error in main source ({}): {}", + cfg.file.as_ref().map(|s| s.as_str()).unwrap_or(""), e); if std::env::var("NYASH_STRIP_DEBUG").ok().as_deref() == Some("1") { eprintln!("[vm-debug] Parse failed for main source"); eprintln!("[vm-debug] Line 15-25 of source:"); diff --git a/src/runner/modes/vm_fallback.rs b/src/runner/modes/vm_fallback.rs index 1663b8f2..898f8af4 100644 --- a/src/runner/modes/vm_fallback.rs +++ b/src/runner/modes/vm_fallback.rs @@ -58,7 +58,7 @@ impl NyashRunner { let main_ast = match NyashParser::parse_from_string(&code2) { Ok(ast) => ast, Err(e) => { - eprintln!("❌ Parse error: {}", e); + eprintln!("❌ Parse error in {}: {}", filename, e); process::exit(1); } }; diff --git a/src/runner/modes/wasm.rs b/src/runner/modes/wasm.rs index f1258767..7739df50 100644 --- a/src/runner/modes/wasm.rs +++ b/src/runner/modes/wasm.rs @@ -17,7 +17,7 @@ impl NyashRunner { // Parse to AST let ast = match NyashParser::parse_from_string(&code) { Ok(ast) => ast, - Err(e) => { eprintln!("❌ Parse error: {}", e); process::exit(1); } + Err(e) => { eprintln!("❌ Parse error in {}: {}", filename, e); process::exit(1); } }; let ast = crate::r#macro::maybe_expand_and_dump(&ast, false); diff --git a/src/runner/selfhost.rs b/src/runner/selfhost.rs index 031b9570..c1f89439 100644 --- a/src/runner/selfhost.rs +++ b/src/runner/selfhost.rs @@ -164,8 +164,18 @@ impl NyashRunner { parser_prog, timeout_ms, &extra, - &["NYASH_USE_NY_COMPILER", "NYASH_CLI_VERBOSE"], - &[("NYASH_JSON_ONLY", "1")], + &[ + "NYASH_USE_NY_COMPILER", + "NYASH_CLI_VERBOSE", + ], + &[ + ("NYASH_JSON_ONLY", "1"), + ("NYASH_DISABLE_PLUGINS", "1"), + ("NYASH_SKIP_TOML_ENV", "1"), + ("NYASH_USING_AST", "0"), + ("NYASH_ALLOW_USING_FILE", "0"), + ("HAKO_ALLOW_USING_FILE", "0"), + ], ) { match json::parse_json_v0_line(&line) { Ok(module) => { @@ -360,9 +370,7 @@ impl NyashRunner { .unwrap_or_else(|_| std::path::PathBuf::from("target/release/nyash")); let mut cmd = std::process::Command::new(exe); cmd.arg("--backend").arg("vm").arg(&inline_path); - cmd.env_remove("NYASH_USE_NY_COMPILER"); - cmd.env_remove("NYASH_CLI_VERBOSE"); - cmd.env("NYASH_JSON_ONLY", "1"); + crate::runner::child_env::apply_core_wrapper_env(&mut cmd); let timeout_ms: u64 = std::env::var("NYASH_NY_COMPILER_TIMEOUT_MS") .ok() .and_then(|s| s.parse().ok()) diff --git a/src/tokenizer/kinds.rs b/src/tokenizer/kinds.rs index 0c114496..5930bc61 100644 --- a/src/tokenizer/kinds.rs +++ b/src/tokenizer/kinds.rs @@ -40,6 +40,7 @@ pub enum TokenType { CLEANUP, THROW, LOCAL, + FLOW, STATIC, OUTBOX, NOT, diff --git a/src/tokenizer/lex_ident.rs b/src/tokenizer/lex_ident.rs index 2ff3bccb..84491688 100644 --- a/src/tokenizer/lex_ident.rs +++ b/src/tokenizer/lex_ident.rs @@ -46,6 +46,7 @@ impl NyashTokenizer { "cleanup" => TokenType::CLEANUP, "throw" => TokenType::THROW, "local" => TokenType::LOCAL, + "flow" => TokenType::FLOW, "static" => TokenType::STATIC, "outbox" => TokenType::OUTBOX, "not" => TokenType::NOT, @@ -61,12 +62,13 @@ impl NyashTokenizer { _ => TokenType::IDENTIFIER(identifier.clone()), }; - // Stage-3 gate: LOCAL/TRY/CATCH/THROW require NYASH_PARSER_STAGE3=1 + // Stage-3 gate: LOCAL/FLOW/TRY/CATCH/THROW require NYASH_PARSER_STAGE3=1 let stage3_enabled = crate::config::env::parser_stage3(); if !stage3_enabled { let is_stage3 = matches!( tok, TokenType::LOCAL + | TokenType::FLOW | TokenType::TRY | TokenType::CATCH | TokenType::THROW @@ -83,6 +85,7 @@ impl NyashTokenizer { let is_stage3 = matches!( tok, TokenType::LOCAL + | TokenType::FLOW | TokenType::TRY | TokenType::CATCH | TokenType::THROW diff --git a/src/using/resolver.rs b/src/using/resolver.rs index a63ddf2b..690a8234 100644 --- a/src/using/resolver.rs +++ b/src/using/resolver.rs @@ -15,11 +15,16 @@ pub fn populate_from_toml( packages: &mut HashMap, ) -> Result { let mut policy = UsingPolicy::default(); + // Prefer CWD nyash.toml; if missing, honor NYASH_ROOT/nyash.toml for tools that run from subdirs let path = std::path::Path::new("nyash.toml"); - if !path.exists() { + let text = if path.exists() { + std::fs::read_to_string(path) + } else if let Ok(root) = std::env::var("NYASH_ROOT") { + let alt = std::path::Path::new(&root).join("nyash.toml"); + if alt.exists() { std::fs::read_to_string(alt) } else { return Ok(policy); } + } else { return Ok(policy); } - let text = std::fs::read_to_string(path) .map_err(|e| UsingError::ReadToml(e.to_string()))?; let doc = toml::from_str::(&text) .map_err(|e| UsingError::ParseToml(e.to_string()))?; diff --git a/tools/smokes/v2/lib/stageb_helpers.sh b/tools/smokes/v2/lib/stageb_helpers.sh index 7d7d74b7..c40d5d2a 100644 --- a/tools/smokes/v2/lib/stageb_helpers.sh +++ b/tools/smokes/v2/lib/stageb_helpers.sh @@ -8,13 +8,25 @@ stageb_compile_to_json() { local json_out="/tmp/hako_stageb_$$.mir.json" printf "%s\n" "$code" > "$hako_tmp" local raw="/tmp/hako_stageb_raw_$$.txt" - # Route A: Hako(Stage-B) entry — preferred when available - NYASH_PARSER_ALLOW_SEMICOLON=1 HAKO_ALLOW_USING_FILE=1 NYASH_ALLOW_USING_FILE=1 \ - HAKO_PARSER_STAGE3=1 NYASH_PARSER_STAGE3=1 \ - NYASH_VARMAP_GUARD_STRICT=0 NYASH_BLOCK_SCHEDULE_VERIFY=0 \ - NYASH_QUIET=1 HAKO_QUIET=1 NYASH_CLI_VERBOSE=0 \ - "$NYASH_BIN" --backend vm \ - "$NYASH_ROOT/lang/src/compiler/entry/compiler_stageb.hako" -- --source "$(cat "$hako_tmp")" > "$raw" 2>&1 || true + # Route A: Hako(Stage-B) entry — preferred when available (run from repo root so nyash.toml resolves) + ( + export NYASH_PARSER_ALLOW_SEMICOLON=1 + export NYASH_ALLOW_USING_FILE=0 + export HAKO_ALLOW_USING_FILE=0 + export NYASH_USING_AST=1 + export HAKO_PARSER_STAGE3=1 + export NYASH_PARSER_STAGE3=1 + export NYASH_VARMAP_GUARD_STRICT=0 + export NYASH_BLOCK_SCHEDULE_VERIFY=0 + export NYASH_QUIET=1 + export HAKO_QUIET=1 + export NYASH_CLI_VERBOSE=0 + # Ensure module resolution works regardless of CWD by injecting minimal keys + export NYASH_MODULES="lang.compiler.parser.box=$NYASH_ROOT/lang/src/compiler/parser/parser_box.hako,lang.compiler.pipeline_v2.flow_entry=$NYASH_ROOT/lang/src/compiler/pipeline_v2/flow_entry.hako" + cd "$NYASH_ROOT" && \ + "$NYASH_BIN" --backend vm \ + "$NYASH_ROOT/lang/src/compiler/entry/compiler_stageb.hako" -- --source "$(cat "$hako_tmp")" + ) > "$raw" 2>&1 || true if awk '/"version":0/ && /"kind":"Program"/ {print; found=1; exit} END{exit(found?0:1)}' "$raw" > "$json_out"; then rm -f "$raw" "$hako_tmp" echo "$json_out" @@ -23,6 +35,10 @@ stageb_compile_to_json() { # Route B: Rust builder fallback — emit MIR(JSON v0) directly from temp source # TTL: remove once Stage‑B selfhost entry is green (doc in phase-20.33/DEBUG.md) + if [ "${HAKO_STAGEB_ALLOW_FALLBACK:-${NYASH_STAGEB_ALLOW_FALLBACK:-0}}" != "1" ]; then + rm -f "$raw" "$hako_tmp" "$json_out" + return 1 + fi local ny_tmp="/tmp/hako_stageb_src_$$.nyash" printf "%s\n" "$code" > "$ny_tmp" rm -f "$json_out" @@ -36,7 +52,7 @@ stageb_compile_to_json() { # Give up; return an empty path (caller treats as skip) rm -f "$raw" "$hako_tmp" "$ny_tmp" "$json_out" - echo "$json_out" + return 1 } stageb_json_nonempty() { diff --git a/tools/smokes/v2/profiles/quick/core/array/gate_c_oob_read_file_vm.sh b/tools/smokes/v2/profiles/quick/core/array/gate_c_oob_read_file_vm.sh new file mode 100644 index 00000000..ca8429c0 --- /dev/null +++ b/tools/smokes/v2/profiles/quick/core/array/gate_c_oob_read_file_vm.sh @@ -0,0 +1,20 @@ +#!/bin/bash +# gate_c_oob_read_file_vm.sh — Gate‑C(Core): array OOB read should fail (file mode) +set -euo pipefail +SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" +ROOT="$(git -C "$SCRIPT_DIR" rev-parse --show-toplevel 2>/dev/null || cd "$SCRIPT_DIR"/../../../../../../../../.. && pwd)" +source "$ROOT/tools/smokes/v2/lib/test_runner.sh" +source "$ROOT/tools/smokes/v2/lib/stageb_helpers.sh" +require_env || exit 2 + +code='box Main { static method main() { local a=[1,2]; print(a[5]); return 0; } }' +json=$(stageb_compile_to_json "$code") || { echo "[FAIL] stageb emit failed" >&2; exit 1; } +if [ ! -s "$json" ]; then echo "[FAIL] stageb json empty" >&2; exit 1; fi +set +e +HAKO_OOB_STRICT=1 HAKO_OOB_STRICT_FAIL=1 NYASH_QUIET=1 HAKO_QUIET=1 NYASH_CLI_VERBOSE=0 \ + "$NYASH_BIN" --json-file "$json" >/dev/null 2>&1 +rc=$? +set -e +rm -f "$json" +if [ $rc -ne 0 ]; then echo "[PASS] gate_c_oob_read_file_vm"; else echo "[FAIL] gate_c_oob_read_file_vm rc=$rc" >&2; exit 1; fi + diff --git a/tools/smokes/v2/profiles/quick/core/array/gate_c_oob_read_pipe_vm.sh b/tools/smokes/v2/profiles/quick/core/array/gate_c_oob_read_pipe_vm.sh new file mode 100644 index 00000000..96e8d491 --- /dev/null +++ b/tools/smokes/v2/profiles/quick/core/array/gate_c_oob_read_pipe_vm.sh @@ -0,0 +1,20 @@ +#!/bin/bash +# gate_c_oob_read_pipe_vm.sh — Gate‑C(Core): array OOB read should fail (pipe mode) +set -euo pipefail +SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" +ROOT="$(git -C "$SCRIPT_DIR" rev-parse --show-toplevel 2>/dev/null || cd "$SCRIPT_DIR"/../../../../../../../../.. && pwd)" +source "$ROOT/tools/smokes/v2/lib/test_runner.sh" +source "$ROOT/tools/smokes/v2/lib/stageb_helpers.sh" +require_env || exit 2 + +code='box Main { static method main() { local a=[1,2]; print(a[5]); return 0; } }' +json=$(stageb_compile_to_json "$code") || { echo "[FAIL] stageb emit failed" >&2; exit 1; } +if [ ! -s "$json" ]; then echo "[FAIL] stageb json empty" >&2; exit 1; fi +set +e +HAKO_OOB_STRICT=1 HAKO_OOB_STRICT_FAIL=1 NYASH_QUIET=1 HAKO_QUIET=1 NYASH_CLI_VERBOSE=0 \ + "$NYASH_BIN" --ny-parser-pipe < "$json" >/dev/null 2>&1 +rc=$? +set -e +rm -f "$json" +if [ $rc -ne 0 ]; then echo "[PASS] gate_c_oob_read_pipe_vm"; else echo "[FAIL] gate_c_oob_read_pipe_vm rc=$rc" >&2; exit 1; fi + diff --git a/tools/smokes/v2/profiles/quick/core/array/gate_c_oob_write_file_vm.sh b/tools/smokes/v2/profiles/quick/core/array/gate_c_oob_write_file_vm.sh new file mode 100644 index 00000000..114976fb --- /dev/null +++ b/tools/smokes/v2/profiles/quick/core/array/gate_c_oob_write_file_vm.sh @@ -0,0 +1,20 @@ +#!/bin/bash +# gate_c_oob_write_file_vm.sh — Gate‑C(Core): array OOB write should fail (file mode) +set -euo pipefail +SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" +ROOT="$(git -C "$SCRIPT_DIR" rev-parse --show-toplevel 2>/dev/null || cd "$SCRIPT_DIR"/../../../../../../../../.. && pwd)" +source "$ROOT/tools/smokes/v2/lib/test_runner.sh" +source "$ROOT/tools/smokes/v2/lib/stageb_helpers.sh" +require_env || exit 2 + +code='box Main { static method main() { local a=[1,2]; a[5]=9; return 0; } }' +json=$(stageb_compile_to_json "$code") || { echo "[FAIL] stageb emit failed" >&2; exit 1; } +if [ ! -s "$json" ]; then echo "[FAIL] stageb json empty" >&2; exit 1; fi +set +e +HAKO_OOB_STRICT=1 HAKO_OOB_STRICT_FAIL=1 NYASH_QUIET=1 HAKO_QUIET=1 NYASH_CLI_VERBOSE=0 \ + "$NYASH_BIN" --json-file "$json" >/dev/null 2>&1 +rc=$? +set -e +rm -f "$json" +if [ $rc -ne 0 ]; then echo "[PASS] gate_c_oob_write_file_vm"; else echo "[FAIL] gate_c_oob_write_file_vm rc=$rc" >&2; exit 1; fi + diff --git a/tools/smokes/v2/profiles/quick/core/array/gate_c_oob_write_pipe_vm.sh b/tools/smokes/v2/profiles/quick/core/array/gate_c_oob_write_pipe_vm.sh new file mode 100644 index 00000000..80e98d24 --- /dev/null +++ b/tools/smokes/v2/profiles/quick/core/array/gate_c_oob_write_pipe_vm.sh @@ -0,0 +1,20 @@ +#!/bin/bash +# gate_c_oob_write_pipe_vm.sh — Gate‑C(Core): array OOB write should fail (pipe mode) +set -euo pipefail +SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" +ROOT="$(git -C "$SCRIPT_DIR" rev-parse --show-toplevel 2>/dev/null || cd "$SCRIPT_DIR"/../../../../../../../../.. && pwd)" +source "$ROOT/tools/smokes/v2/lib/test_runner.sh" +source "$ROOT/tools/smokes/v2/lib/stageb_helpers.sh" +require_env || exit 2 + +code='box Main { static method main() { local a=[1,2]; a[5]=9; return 0; } }' +json=$(stageb_compile_to_json "$code") || { echo "[FAIL] stageb emit failed" >&2; exit 1; } +if [ ! -s "$json" ]; then echo "[FAIL] stageb json empty" >&2; exit 1; fi +set +e +HAKO_OOB_STRICT=1 HAKO_OOB_STRICT_FAIL=1 NYASH_QUIET=1 HAKO_QUIET=1 NYASH_CLI_VERBOSE=0 \ + "$NYASH_BIN" --ny-parser-pipe < "$json" >/dev/null 2>&1 +rc=$? +set -e +rm -f "$json" +if [ $rc -ne 0 ]; then echo "[PASS] gate_c_oob_write_pipe_vm"; else echo "[FAIL] gate_c_oob_write_pipe_vm rc=$rc" >&2; exit 1; fi + diff --git a/tools/smokes/v2/profiles/quick/core/errors/parse_error_context_vm.sh b/tools/smokes/v2/profiles/quick/core/errors/parse_error_context_vm.sh new file mode 100644 index 00000000..905e62d4 --- /dev/null +++ b/tools/smokes/v2/profiles/quick/core/errors/parse_error_context_vm.sh @@ -0,0 +1,31 @@ +#!/bin/bash +# parse_error_context_vm.sh — Ensure parse errors include filename +set -euo pipefail +SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" +if ROOT_GIT=$(git -C "$SCRIPT_DIR" rev-parse --show-toplevel 2>/dev/null); then + ROOT="$ROOT_GIT" +else + ROOT="$(cd "$SCRIPT_DIR/../../../../../../../../.." && pwd)" +fi +source "$ROOT/tools/smokes/v2/lib/test_runner.sh" +require_env || exit 2 + +tmp="/tmp/ny_parse_err_$$.nyash" +cat >"$tmp" <<'SRC' +box Main { static method main() { local ; } } +SRC +set +e +out=$(NYASH_PARSER_STAGE3=1 NYASH_PARSER_ALLOW_SEMICOLON=1 "$NYASH_BIN" --backend vm "$tmp" 2>&1) +rc=$? +set -e +rm -f "$tmp" + +if [ $rc -eq 0 ]; then + echo "[FAIL] parse_error_context_vm: expected failure" >&2; exit 1 +fi +echo "$out" | grep -q "Parse error in $tmp:" && echo "[PASS] parse_error_context_vm" && exit 0 +echo "[FAIL] parse_error_context_vm: filename not included" >&2 +echo "--- output ---" >&2 +echo "$out" >&2 +exit 1 + diff --git a/tools/smokes/v2/profiles/quick/core/errors/using_error_context_vm.sh b/tools/smokes/v2/profiles/quick/core/errors/using_error_context_vm.sh new file mode 100644 index 00000000..fd395304 --- /dev/null +++ b/tools/smokes/v2/profiles/quick/core/errors/using_error_context_vm.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# using_error_context_vm.sh — Ensure using errors include filename and line +set -euo pipefail +SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" +if ROOT_GIT=$(git -C "$SCRIPT_DIR" rev-parse --show-toplevel 2>/dev/null); then + ROOT="$ROOT_GIT" +else + ROOT="$(cd "$SCRIPT_DIR/../../../../../../../../.." && pwd)" +fi +source "$ROOT/tools/smokes/v2/lib/test_runner.sh" +require_env || exit 2 + +tmp="/tmp/ny_using_err_$$.nyash" +cat >"$tmp" <<'SRC' +using "lang/src/shared/common/string_ops.hako" +box Main { static method main() { return 0 } } +SRC +set +e +out=$(NYASH_PARSER_STAGE3=1 NYASH_PARSER_ALLOW_SEMICOLON=1 \ + NYASH_ALLOW_USING_FILE=0 HAKO_ALLOW_USING_FILE=0 \ + "$NYASH_BIN" --backend vm "$tmp" 2>&1) +rc=$? +set -e +rm -f "$tmp" + +if [ $rc -eq 0 ]; then + echo "[FAIL] using_error_context_vm: expected failure" >&2; exit 1 +fi +echo "$out" | grep -q "${tmp}:1: using: file paths are disallowed" && echo "[PASS] using_error_context_vm" && exit 0 +echo "[FAIL] using_error_context_vm: filename:line not included" >&2 +echo "--- output ---" >&2 +echo "$out" >&2 +exit 1 + diff --git a/tools/smokes/v2/profiles/quick/core/stageb/stageb_array_vm.sh b/tools/smokes/v2/profiles/quick/core/stageb/stageb_array_vm.sh index b13858e0..92baf232 100644 --- a/tools/smokes/v2/profiles/quick/core/stageb/stageb_array_vm.sh +++ b/tools/smokes/v2/profiles/quick/core/stageb/stageb_array_vm.sh @@ -13,11 +13,11 @@ source "$ROOT/tools/smokes/v2/lib/stageb_helpers.sh" require_env || exit 2 code='box Main { static method main() { local a=[1,2,3]; return a.length(); } }' -json=$(stageb_compile_to_json "$code") +HAKO_STAGEB_ALLOW_FALLBACK=1 json=$(stageb_compile_to_json "$code") || { echo "[FAIL] Stage‑B emit failed" >&2; exit 1; } if ! stageb_json_nonempty "$json"; then - echo "[WARN] Stage‑B emit empty; skipping" >&2 + echo "[FAIL] Stage‑B emit empty" >&2 rm -f "$json" - exit 0 + exit 1 fi set +e "$NYASH_BIN" --json-file "$json" >/dev/null 2>&1 diff --git a/tools/smokes/v2/profiles/quick/core/stageb/stageb_binop_vm.sh b/tools/smokes/v2/profiles/quick/core/stageb/stageb_binop_vm.sh index a1a76781..a2e40f26 100644 --- a/tools/smokes/v2/profiles/quick/core/stageb/stageb_binop_vm.sh +++ b/tools/smokes/v2/profiles/quick/core/stageb/stageb_binop_vm.sh @@ -13,11 +13,11 @@ source "$ROOT/tools/smokes/v2/lib/stageb_helpers.sh" require_env || exit 2 code='box Main { static method main() { return 1+2 } }' -json=$(stageb_compile_to_json "$code") +HAKO_STAGEB_ALLOW_FALLBACK=1 json=$(stageb_compile_to_json "$code") || { echo "[FAIL] Stage‑B emit failed" >&2; exit 1; } if ! stageb_json_nonempty "$json"; then - echo "[WARN] Stage‑B emit empty; skipping" >&2 + echo "[FAIL] Stage‑B emit empty" >&2 rm -f "$json" - exit 0 + exit 1 fi set +e "$NYASH_BIN" --json-file "$json" >/dev/null 2>&1 diff --git a/tools/smokes/v2/profiles/quick/core/stageb/stageb_if_vm.sh b/tools/smokes/v2/profiles/quick/core/stageb/stageb_if_vm.sh index 528e0a1c..917ad9f8 100644 --- a/tools/smokes/v2/profiles/quick/core/stageb/stageb_if_vm.sh +++ b/tools/smokes/v2/profiles/quick/core/stageb/stageb_if_vm.sh @@ -13,11 +13,11 @@ source "$ROOT/tools/smokes/v2/lib/stageb_helpers.sh" require_env || exit 2 code='box Main { static method main() { if(5>4){ return 1 } else { return 0 } } }' -json=$(stageb_compile_to_json "$code") +HAKO_STAGEB_ALLOW_FALLBACK=1 json=$(stageb_compile_to_json "$code") || { echo "[FAIL] Stage‑B emit failed" >&2; exit 1; } if ! stageb_json_nonempty "$json"; then - echo "[WARN] Stage‑B emit empty; skipping" >&2 + echo "[FAIL] Stage‑B emit empty" >&2 rm -f "$json" - exit 0 + exit 1 fi set +e "$NYASH_BIN" --json-file "$json" >/dev/null 2>&1 diff --git a/tools/smokes/v2/profiles/quick/core/stageb/stageb_loop_vm.sh b/tools/smokes/v2/profiles/quick/core/stageb/stageb_loop_vm.sh index 58b10f77..0f00a575 100644 --- a/tools/smokes/v2/profiles/quick/core/stageb/stageb_loop_vm.sh +++ b/tools/smokes/v2/profiles/quick/core/stageb/stageb_loop_vm.sh @@ -13,11 +13,11 @@ source "$ROOT/tools/smokes/v2/lib/stageb_helpers.sh" require_env || exit 2 code='box Main { static method main() { local i=1; local s=0; loop(i<=3){ s=s+i; i=i+1; } return s; } }' -json=$(stageb_compile_to_json "$code") +HAKO_STAGEB_ALLOW_FALLBACK=1 json=$(stageb_compile_to_json "$code") || { echo "[FAIL] Stage‑B emit failed" >&2; exit 1; } if ! stageb_json_nonempty "$json"; then - echo "[WARN] Stage‑B emit empty; skipping" >&2 + echo "[FAIL] Stage‑B emit empty" >&2 rm -f "$json" - exit 0 + exit 1 fi set +e "$NYASH_BIN" --json-file "$json" >/dev/null 2>&1 diff --git a/tools/smokes/v2/profiles/quick/core/stageb/stageb_map_vm.sh b/tools/smokes/v2/profiles/quick/core/stageb/stageb_map_vm.sh index d6b9115e..e25251e1 100644 --- a/tools/smokes/v2/profiles/quick/core/stageb/stageb_map_vm.sh +++ b/tools/smokes/v2/profiles/quick/core/stageb/stageb_map_vm.sh @@ -13,11 +13,11 @@ source "$ROOT/tools/smokes/v2/lib/stageb_helpers.sh" require_env || exit 2 code='box Main { static method main() { local m=new MapBox(); m.set("a",1); return m.size(); } }' -json=$(stageb_compile_to_json "$code") +HAKO_STAGEB_ALLOW_FALLBACK=1 json=$(stageb_compile_to_json "$code") || { echo "[FAIL] Stage‑B emit failed" >&2; exit 1; } if ! stageb_json_nonempty "$json"; then - echo "[WARN] Stage‑B emit empty; skipping" >&2 + echo "[FAIL] Stage‑B emit empty" >&2 rm -f "$json" - exit 0 + exit 1 fi set +e "$NYASH_BIN" --json-file "$json" >/dev/null 2>&1 diff --git a/tools/smokes/v2/profiles/quick/core/stageb/stageb_print_vm.sh b/tools/smokes/v2/profiles/quick/core/stageb/stageb_print_vm.sh index c67879ef..ba4bcb05 100644 --- a/tools/smokes/v2/profiles/quick/core/stageb/stageb_print_vm.sh +++ b/tools/smokes/v2/profiles/quick/core/stageb/stageb_print_vm.sh @@ -14,11 +14,11 @@ source "$ROOT/tools/smokes/v2/lib/stageb_helpers.sh" require_env || exit 2 code='box Main { static method main() { print(3); return 0; } }' -json=$(stageb_compile_to_json "$code") || { echo "[WARN] Stage‑B emit failed; skipping" >&2; exit 0; } +HAKO_STAGEB_ALLOW_FALLBACK=1 json=$(stageb_compile_to_json "$code") || { echo "[FAIL] Stage‑B emit failed" >&2; exit 1; } if ! stageb_json_nonempty "$json"; then - echo "[WARN] Stage‑B emit empty; skipping" >&2 + echo "[FAIL] Stage‑B emit empty" >&2 rm -f "$json" - exit 0 + exit 1 fi set +e output=$("$NYASH_BIN" --json-file "$json") diff --git a/tools/smokes/v2/profiles/quick/core/stageb/stageb_string_vm.sh b/tools/smokes/v2/profiles/quick/core/stageb/stageb_string_vm.sh index 2e5a42de..0ac293e6 100644 --- a/tools/smokes/v2/profiles/quick/core/stageb/stageb_string_vm.sh +++ b/tools/smokes/v2/profiles/quick/core/stageb/stageb_string_vm.sh @@ -13,11 +13,11 @@ source "$ROOT/tools/smokes/v2/lib/stageb_helpers.sh" require_env || exit 2 code='box Main { static method main() { local s="ab"; return s.length(); } }' -json=$(stageb_compile_to_json "$code") +HAKO_STAGEB_ALLOW_FALLBACK=1 json=$(stageb_compile_to_json "$code") || { echo "[FAIL] Stage‑B emit failed" >&2; exit 1; } if ! stageb_json_nonempty "$json"; then - echo "[WARN] Stage‑B emit empty; skipping" >&2 + echo "[FAIL] Stage‑B emit empty" >&2 rm -f "$json" - exit 0 + exit 1 fi set +e "$NYASH_BIN" --json-file "$json" >/dev/null 2>&1