Files
hakorune/lang
nyash-codex 4b3eb6b3a9 feat(phase71-ssa): SSA undef 完全解消達成!(4件→0件)
## Phase 71-SSA SSA undef 削減 完全達成!

### 🎉 成果
- **SSA undef**: 4件 → **0件** (100%解消!)
- **所要時間**: 約2時間 (Task先生調査 + 実装 + 検証)
- **修正ファイル**: 3ファイル (.hako実装のみ、MIR/SSAビルダー不変)

### 🔍 根本原因 (Task先生による徹底分析)
**ValueId(272) = StringHelpers.starts_with_kw/3 の戻り値**
- static boxの委譲でValueIdマッピング失敗
- 引数パラメータ設定ログが一切出力されず
- 別関数の戻り値ValueIdが誤って引数として参照される

### 🛠️ 修正内容

**修正1: ParserStringUtilsBox.trim (Quick Win)**
- L76: `StringHelpers.skip_ws` → `ParserStringUtilsBox.skip_ws`
- 効果: SSA undef 4件 → 2件
- 副次効果: Main._parse_number/ParserBox.parse_block2 消滅

**修正2: ParserCommonUtilsBox.trim (修正案A)**
- L50-69: 委譲を廃止、直接実装に変更
- FuncScannerBox.trimの成功パターンを適用

**修正3: ParserBox.trim (修正案A)**
- L81-98: 委譲を廃止、直接実装に変更
- 効果: 残り2件のSSA undef完全解消

###  検証結果
```bash
grep -c 'ssa-undef-debug' logs/selfhost/stageb_20251202_111409_2674670.log
# 出力: 0 ← 🎉 完全解消!
```

### 📊 SSA undef 推移
| フェーズ | 件数 | 詳細 |
|---------|------|------|
| Phase 71初回 | 4件 | trim×2, _parse_number, parse_block2 |
| Quick Win後 | 2件 | trim×2 (予想外: 他2件消滅) |
| 修正案A後 | **0件** | 🎉 **完全解消!** |

### 🎯 残存課題 (次フェーズ)
1. dev verify警告: 1件 (StageBDriverBox birth)
2. Program JSON未出力: extract_ok=0 (rc=0だが行なし)

### 💡 重要な教訓
- static boxの委譲は危険 (ValueIdマッピング失敗)
- 静的呼び出し (BoxName.method) が SSA-friendly
- 成功パターン (FuncScannerBox.trim) の積極活用

### 📝 ドキュメント
- 詳細レポート: phase71-ssa-trim-fix-20251202.md
- Task先生分析: ValueId(272)特定、修正案A-C提案

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-02 11:16:01 +09:00
..

Hakorune Lang Line — Rust-less Kernel (C ABI)

Scope

  • This lang/ tree hosts the script-driven C ABI kernel artifacts for Phase 20.9+.
  • Goal: keep the runtime data plane callable without Rust on the hot path (Hakorune → LLVM → C ABI).

Principles

  • Separation: do not mix Rust crates or cargo-specific layout under this tree.
  • Ownership & ABI:
    • Any char* returned across the ABI is owned by the callee and must be freed via hako_mem_free().
    • Do not mix CRT free() across boundaries.
  • FailFast: no silent fallbacks. Missing symbols must be observable via short diagnostics.

Layout (initial)

  • c-abi/ — C shim(s) and headers for the minimal kernel surface
    • README.md — responsibilities, build notes, platform caveats
    • include/ — public headers (mirrored or thin wrappers)
    • shims/ — libc-backed shim(s) for canaries and local testing

Build & Link (dev)

  • C shim: build a shared library to satisfy symbols for the LLVM line canaries.
  • Link flags example:
    • Linux: -L$(pwd)/target/release -Wl,-rpath,$(pwd)/target/release -lhako_kernel_shim

NonGoals

  • Plugin loader, HostBridge router, Box/Type system — kept in Rust.

Selfhost Launcher (AOT)

Dev line (Stage1 core experimental)

  • Dev build: tools/selfhost/build_stage1.sh → produces target/selfhost/hakorune
  • Role:
    • Fast iteration用の Stage1 selfhost バイナリNy Executor / CLI 実験など)。
    • new CLI/runner 機能はまずこちらで開発・検証する。

Stable line (lang bin snapshot)

  • Stable binary: lang/bin/hakorune
  • Build (pure-lang launcher, legacy bring-up):
    • lang/build/build_runner.sh → produces lang/bin/hakorune
    • Requirements: LLVM 18 dev (llvm-config-18)
  • PolicyPhase 25.1 以降の想定):
    • target/selfhost/hakorune で十分に安定したら、その成果物を lang/bin/hakorune に昇格させる(手動コピー or 専用スクリプト)。
    • lang/bin/hakorune は「last known good」の Stage1 コア EXE として扱い、配布や外部からの参照時は原則こちらを基準にする。

Notes

  • lang/ 以下は「最終的に 1 つの Stage1 コア EXEhakoruneを構成するソース群」という前提で整理する。
  • target/selfhost/hakorune は開発中の最新版、lang/bin/hakorune は安定版スナップショットという役割分担にする。