Files
hakorune/lang
nyash-codex 29e09c1491 feat(phase71-ssa): ParserBox委譲SSA undef完全解消達成!(9件→0件)
**Phase 71-SSA: 全SSA undef完全解消達成!**
- 修正前: trim系 4件 + ParserBox委譲 9件 = 計13件
- 修正後: **0件** (100%解消!)

**修正内容**:
1. ParserBox委譲メソッド削除 (L71-106)
   - 削除: is_digit, is_space, is_alpha, starts_with, index_of
   - 削除: starts_with_kw, i2s, to_int, skip_ws
   - 理由: static box delegation による ValueId mapping 失敗

2. ParserBox内部呼び出し修正 (5箇所)
   - `me.to_int()` → `ParserStringUtilsBox.to_int()`
   - `me.starts_with()` → `ParserStringUtilsBox.starts_with()`
   - L112, L129, L157, L160, L353 を修正

3. compiler_stageb.hako トレース追加 (L1477-1495)
   - Program JSON emit 直前にトレースポイント追加
   - HAKO_STAGEB_TRACE=1 で詳細トレース出力

**根本原因** (Rust MIRビルダーのバグ):
- static box の委譲時に ValueId マッピングが失敗
- 引数の ValueId が undef (未定義) になる
- 例: Copy { dst: ValueId(4), src: ValueId(132) }
  で ValueId(132) が存在しない

**Phase 71-SSA戦略**:
- .hako 層で委譲を廃止 (回避策)
- 直接実装または直接呼び出しに統一
- 根本解決は将来タスク (Rust MIRビルダー修正)

**検証結果**:
```bash
grep -c 'ssa-undef-debug' logs/selfhost/stageb_*.log
# 出力: 0  ← 完全成功!
```

**残存課題**:
- dev verify警告: 1件 (StageBDriverBox birth)
- Program JSON emit: extract_ok=0 (次フェーズで調査)

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-02 11:22:53 +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 は安定版スナップショットという役割分担にする。