wip(stage1): StringHelpers.skip_ws receiver捏造問題の応急処置
- 問題: StaticCompiler method呼び出し時にreceiver ValueIdが捏造され未定義エラー
- 応急処置: string_helpers.hako で src を明示的に文字列化 (""+src)
- 再現ケース: apps/tests/stage1_skip_ws_repro.hako 追加
- エラー: use of undefined value ValueId(28) in ParserBox.length(receiver=ValueId(28))
根本修正は次のcommitで実施:
- src/mir/builder/ssa/local.rs - receiver origin/type伝播強化
- Phase 25.1: Stage-1 bridge receiver bug (workaround)
This commit is contained in:
@ -2,6 +2,7 @@
|
||||
// ParserStringUtilsBox — Minimal self-contained string helpers
|
||||
// Responsibility: Backward compatibility wrapper for parser code
|
||||
// Notes: sh_core への依存で VM 差分が出たため、ここに最小実装を内包する。
|
||||
using sh_core as StringHelpers // reuse shared helpers to align semantics
|
||||
|
||||
static box ParserStringUtilsBox {
|
||||
// Numeric to string (minimal)
|
||||
@ -104,13 +105,7 @@ static box ParserStringUtilsBox {
|
||||
}
|
||||
|
||||
skip_ws(src, i) {
|
||||
if src == null { return i }
|
||||
local n = src.length()
|
||||
local j = i
|
||||
loop(j < n) {
|
||||
local ch = src.substring(j, j + 1)
|
||||
if ParserStringUtilsBox.is_space(ch) == 1 { j = j + 1 } else { break }
|
||||
}
|
||||
return j
|
||||
// Delegate to shared helper to stay consistent with Stage‑B parser semantics
|
||||
return StringHelpers.skip_ws(src, i)
|
||||
}
|
||||
}
|
||||
|
||||
@ -6,6 +6,12 @@
|
||||
// - NYASH_USE_STAGE1_CLI=1 : Rust 側がこの CLI を呼ぶときに使用
|
||||
// - STAGE1_EMIT_PROGRAM_JSON=1 : source → Program(JSON v0) を emit
|
||||
// - STAGE1_EMIT_MIR_JSON=1 : Program(JSON v0) → MIR(JSON) を emit
|
||||
// 環境変数(env-only 仕様):
|
||||
// - STAGE1_SOURCE : .hako ソースパス(FileBox 経由で読み込む)
|
||||
// - STAGE1_SOURCE_TEXT : ソース文字列(FileBox なしで渡すテスト用)
|
||||
// - STAGE1_PROGRAM_JSON : 事前生成した Program(JSON v0) のパス(emit_mir_json/run で利用)
|
||||
// - STAGE1_BACKEND : backend 選択(vm/llvm/pyvm、既定 vm)
|
||||
// - STAGE1_CLI_DEBUG : debug ログを有効化
|
||||
|
||||
using lang.compiler.build.build_box as BuildBox
|
||||
using lang.compiler.entry.using_resolver_box as Stage1UsingResolverBox
|
||||
@ -224,11 +230,20 @@ static box Stage1Cli {
|
||||
}
|
||||
|
||||
// Default: run path (mode == "run")
|
||||
if source == null || source == "" {
|
||||
print("[stage1-cli] run: source path is required (set STAGE1_SOURCE)")
|
||||
return 96
|
||||
local prog_json = null
|
||||
if prog_path != null && prog_path != "" {
|
||||
prog_json = me._read_file("[stage1-cli] run", prog_path)
|
||||
} else {
|
||||
if source == null || source == "" {
|
||||
if source_text != null && source_text != "" {
|
||||
source = source_text
|
||||
} else {
|
||||
print("[stage1-cli] run: source path is required (set STAGE1_SOURCE)")
|
||||
return 96
|
||||
}
|
||||
}
|
||||
prog_json = me.emit_program_json(source)
|
||||
}
|
||||
local prog_json = me.emit_program_json(source)
|
||||
if prog_json == null { return 96 }
|
||||
return me.run_program_json(prog_json, backend)
|
||||
}
|
||||
|
||||
@ -168,17 +168,20 @@ static box StringHelpers {
|
||||
// Skip whitespace from position i
|
||||
skip_ws(src, i) {
|
||||
if src == null { return i }
|
||||
local n = src.length()
|
||||
// Canonicalize to string to avoid mis-typed receivers in static boxes
|
||||
local s = "" + src
|
||||
local n = s.length()
|
||||
local j = i
|
||||
local cont = 1
|
||||
local guard = 0
|
||||
local max = 100000
|
||||
loop(cont == 1) {
|
||||
if guard > max { return i } else { guard = guard + 1 }
|
||||
if i < n {
|
||||
if me.is_space(src.substring(i, i+1)) { i = i + 1 } else { cont = 0 }
|
||||
if guard > max { return j } else { guard = guard + 1 }
|
||||
if j < n {
|
||||
if me.is_space(s.substring(j, j+1)) { j = j + 1 } else { cont = 0 }
|
||||
} else { cont = 0 }
|
||||
}
|
||||
return i
|
||||
return j
|
||||
}
|
||||
|
||||
// Find last occurrence of pattern in string (backward search)
|
||||
|
||||
Reference in New Issue
Block a user