## LLVM Codegen Refactoring (by ChatGPT5) - Split massive boxcall.rs into focused submodules: - strings.rs: String method optimizations (concat, length) - arrays.rs: Array operations (get, set, push, length) - maps.rs: Map operations (get, set, has, size) - fields.rs: getField/setField handling - invoke.rs: Tagged invoke implementation - marshal.rs: Helper functions for marshaling - Improved code organization and maintainability - No functional changes, pure refactoring ## Phase 15 Documentation Cleanup - Restructured phase-15 folder: - implementation/: Technical implementation docs - planning/: Planning and sequence docs - archive/: Redundant/old content - Removed duplicate content (80k→20k line reduction mentioned 5 times) - Converted all .txt files to .md for consistency - Fixed broken links in README.md - Removed redundant INDEX.md ## Phase 21: Database-Driven Development (New) - Revolutionary concept: Source code in SQLite instead of files - Instant refactoring with SQL transactions - Structured management of boxes, methods, dependencies - Technical design with security considerations - Vision: World's first DB-driven programming language 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
3.7 KiB
3.7 KiB
Phase 15 自己ホスティング準備メモ - 箱積み上げ戦略
Date: 2025-09-03
Author: Claude + にゃ
基本理念:箱を下にして積み重ねる
- フォールバック不要、Rust依存なし(EXEライブラリのみ)
- 一度置いた箱は動かさない
- 下の箱が安定なら、上も安定
- 複雑さは敵、シンプルさは友
基礎Box群の階層構造
第1層(最下層):これがないと何も始まらない
- MemoryBox: メモリ管理
- StringBox: 文字列処理
- ArrayBox: 配列操作
- MapBox: 連想配列
- ErrorBox: エラー処理
第2層:言語処理の基礎
- TokenBox: 字句解析
- ASTBox: 構文木
- SymbolBox: シンボルテーブル
- ScopeBox: スコープ管理
第3層:コンパイラコア
- ParserBox: パーサー
- MIRBox: 中間表現(13命令)
- OptimizerBox: 最適化
- GeneratorBox: コード生成
第4層:実行系
- InterpreterBox: インタープリター
- VMBox: 仮想マシン
- JITBox: JITコンパイラ(Cranelift)
- LinkerBox: リンカー(lld)
準備期間の研究項目
1. 依存関係マップ作成
- 何が何に依存?
- 最小限の依存で最大の効果
- 循環依存の排除
2. インターフェース設計
- 全Boxの共通プロトコル
- 入力/出力の標準化
- エラー処理の統一
3. ビルド順序の科学
- Day 1: 基礎Box群
- Day 2: 言語処理層
- Day 3: コンパイラ層
- 完成まで一直線
4. 最小ブートストラップセット
- 自分自身をコンパイルできる最小構成
- 必須機能の特定
- 段階的な機能追加
箱の品質保証原則
- 単体で完結 - 他に依存しすぎない
- 明確な責務 - 1つの箱は1つの仕事
- テスト可能 - 単独で動作確認
- 不変インターフェース - 一度決めたら変更なし
実装戦略
- Rust実装の機能分解(Box単位)
- 各Boxの仕様書作成
- テストケースの移植計画
- Box間プロトコル設計
- 最小実装から始める
- 増分的に機能追加
成功の鍵
- 準備こそすべて
- 急いで実装より、じっくり設計
- 箱を積み重ねれば必ず頂上に到達
- フォールバックなし、後戻りなし、前進あるのみ
革新的アイデア
1. BoxDNA設計書
- 各Boxの入力/出力/依存を明文化
- 遺伝子のように継承・組み合わせ
2. 増分コンパイル対応
- 変更部分だけ再コンパイル
- 開発効率の向上
3. 可視化ツール
- 進捗の見える化
- 依存関係の図示
数値目標
- 80,000行 → 20,000行(75%削減)
- MIR13命令で全機能実現
- ビルド時間:1分以内
- テストカバレッジ:90%以上
コンテキスト圧縮対策
1. ANCP活用(Phase 12.7)
- 90%圧縮でAIコンテキスト節約
- ANCP仕様書
2. モジュール分割開発
- 各Boxを独立して開発
- 統合は最後に実施
3. AI協調開発
- Claude:実装担当
- ChatGPT5:リファクタリング
- Gemini:レビュー
- Codex:デバッグ支援
関連ドキュメント
次のアクション
- このメモをベースに詳細設計
- Box依存関係グラフの作成
- 最小実装セットの確定
- 各Boxの仕様書ドラフト
「箱を積み上げて、世界一美しいコンパイラを作るにゃ!」