Files
hakorune/apps/tests/ssa_static_delegation_enhanced.hako
nyash-codex 573c9e90b6 docs(phase80/81): Phase 80/81 完了状態をドキュメントに反映
Phase 80/81 Implementation Summary:
- Phase 80 (c61f4bc7): JoinIR 本線統一(代表 if/loop)
  - should_try_joinir_mainline() 等の SSOT ヘルパー実装
  - NYASH_JOINIR_CORE=1 で JoinIR→MIR が既定に
- Phase 81 (a9e10d2a): selfhost Strict + Fail-Fast
  - selfhost_build.sh に --core/--strict オプション追加
  - 環境変数自動伝播(NYASH_JOINIR_CORE/STRICT)
- Phase 82 (93f51e40): JOINIR_TARGETS SSOT 化
  - is_loop_lowered_function() テーブル参照統一

Documentation Updates:
- docs/private/roadmap2/phases/phase-80-joinir-mainline/README.md
  - Section 80-2: 実装完了マーク追加
  - Section 80-5: commit hash 付きメモ更新
- docs/private/roadmap2/phases/phase-81-joinir-strict/README.md
  - Section 81-4: Done/TODO チェックボックス更新
  - Section 81-4-A: selfhost_build.sh 統合実装詳細追加
- CURRENT_TASK.md
  - Phase 80/81 完了マーク追加(今後の優先タスク順)
  - Phase 82 次の焦点として明記

Next Focus:
- Phase 82-if-phi-retire: if_phi.rs 削除準備開始
2025-12-02 14:07:19 +09:00

93 lines
2.0 KiB
Plaintext

// Phase 74-SSA: Enhanced reproduction - closer to ParserBox pattern
// Goal: Reproduce ValueId undef with more realistic conditions
//
// Added features:
// 1. State fields (like ParserBox.gpos, usings_json)
// 2. using statement (like ParserBox uses sh_core)
// 3. Multiple methods (not just one delegation)
// 4. Method with loop (like ParserBox.trim)
static box TargetBox {
is_digit(ch) {
if ch >= "0" && ch <= "9" { return 1 }
return 0
}
skip_ws(str, i) {
local n = str.length()
loop(i < n) {
local ch = str.substring(i, i + 1)
if ch == " " || ch == "\t" || ch == "\n" { i = i + 1 } else { break }
}
return i
}
trim(s) {
if s == null { return "" }
local str = "" + s
local n = str.length()
local b = TargetBox.skip_ws(str, 0)
if b >= n { return "" }
local e = n
loop(e > b) {
local ch = str.substring(e - 1, e)
if ch == " " || ch == "\t" { e = e - 1 } else { break }
}
if e > b { return str.substring(b, e) }
return ""
}
}
box DelegateBox {
// State fields (like ParserBox)
gpos
data
birth() {
me.gpos = 0
me.data = ""
return 0
}
// Method with loop + delegation (like ParserBox.trim)
trim(s) {
// Phase 74-SSA: This delegation pattern should cause SSA undef
return TargetBox.trim(s)
}
// Simple delegation (like ParserBox.is_digit)
is_digit(ch) {
return TargetBox.is_digit(ch)
}
// Method that uses state + delegation
process(text) {
local t = me.trim(text)
me.data = t
return t
}
}
box Main {
main() {
local delegate = new DelegateBox()
// Test delegation through instance
local text = " hello "
local trimmed = delegate.trim(text)
// Test is_digit delegation
local ch = "7"
local d = delegate.is_digit(ch)
// Test combined (state + delegation)
local result = delegate.process(" world ")
// Use results to avoid dead code elimination
if trimmed.length() > 0 && d == 1 && result.length() > 0 {
return 0
}
return 1
}
}