Files
hakorune/docs/archive/roadmap/phases/phase-22/README.md
nyash-codex d4f90976da refactor(joinir): Phase 244 - ConditionLoweringBox trait unification
Unify condition lowering logic across Pattern 2/4 with trait-based API.

New infrastructure:
- condition_lowering_box.rs: ConditionLoweringBox trait + ConditionContext (293 lines)
- ExprLowerer implements ConditionLoweringBox trait (+51 lines)

Pattern migrations:
- Pattern 2 (loop_with_break_minimal.rs): Use trait API
- Pattern 4 (loop_with_continue_minimal.rs): Use trait API

Benefits:
- Unified condition lowering interface
- Extensible for future lowering strategies
- Clean API boundary between patterns and lowering logic
- Zero code duplication

Test results: 911/911 PASS (+2 new tests)

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

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-11 02:35:31 +09:00

2.5 KiB
Raw Blame History

Status: Historical

Phase 22: Nyash LLVM Compiler - コンパイラもBoxの世界へ

📋 概要

LLVMコンパイラ自体をNyashで実装する革命的アプローチ。 C++で最小限のグルー層20-30関数を作り、コンパイラロジックの大部分をNyashで記述。 究極の目標2,500行のRust実装を100-200行のNyashで置き換える。

🎯 フェーズの目的

  1. 開発サイクルの革命: ビルド時間5-7分 → 即座の変更反映
  2. 究極のシンプルさ: Everything is Boxでコンパイラも簡潔に
  3. セルフホスティング深化: NyashでNyashをコンパイルする真の実現
  4. 保守性の劇的向上: 誰でも読める100行のコンパイラ

🤔 なぜこのアプローチか?

現在の課題2025-09-11

  • Rust + LLVM (inkwell): 複雑で長いビルド時間
  • 2,500行のコード: 理解と保守が困難
  • 依存地獄: inkwellのバージョン管理

ユーザーの洞察

「MIR解釈して出力するだけなのに、メモリーリークの心配なんてあるんだろうか」 → その通り短命なバッチ処理にRustの複雑さは過剰。

📐 設計概要

// 究極のシンプルなLLVMコンパイラ
box LLVMCompiler {
    context: LLVMContextBox
    module: LLVMModuleBox
    
    compileMir(mirJson) {
        local mir = JsonBox.parse(mirJson)
        mir.functions.forEach(me.compileFunction)
        return me.module.emitObject()
    }
}

🔗 関連ドキュメント

📅 実施時期

  • 開始条件: Phase 15 LLVMバックエンド完成後
  • 推定開始: 2026年後半
  • 推定期間: 3-4ヶ月PoCは数週間

💡 期待される成果

  1. ビルド時間: 5-7分 → ゼロ(スクリプト実行のみ)
  2. コード量: 2,500行 → 100-200行95%削減!)
  3. 理解容易性: 週末どころか1時間で理解可能
  4. 開発効率: 即座に変更・テスト可能

🌟 夢の実現

「コンパイラもBox、Everything is Box」 「2,500行→100行、これこそ革命」

最小限のC++グルーとNyashの表現力で、世界一シンプルなLLVMコンパイラへ。