Files
hakorune/src/mir/builder/calls/mod.rs

41 lines
1.6 KiB
Rust
Raw Normal View History

refactor(builder): 箱理論リファクタリング Phase 1完了 🎯 builder_calls.rs (982行) を箱理論で責務別にモジュール分割 ## 成果 ✅ builder_calls.rs: 982行 → 766行(-216行、22%削減) ✅ calls/lowering.rs: 354行(新規、箱理論6段階パターン) ✅ calls/utils.rs: 45行(新規、ユーティリティ統一) ✅ ビルド・テスト完全成功(0エラー) ## 箱理論の実装 1. 責務ごとに箱に分離: - lowering: 関数lowering専用 - utils: ユーティリティ統一 - emit/build: Phase 2で実装予定 2. 境界を明確に: - mod.rs で公開インターフェース定義 - pub(in crate::mir::builder) で適切な可視性制御 3. いつでも戻せる: - 段階的移行、各ステップでビルド確認 - 既存API完全保持(互換性100%) 4. 巨大関数は分割: - lower_static_method_as_function: 125行 → 6段階に分解 - lower_method_as_function: 80行 → 6段階に分解 ## 箱理論6段階パターン 1. prepare_lowering_context - Context準備 2. create_function_skeleton - 関数スケルトン作成 3. setup_function_params - パラメータ設定 4. lower_function_body - 本体lowering 5. finalize_function - 関数finalize 6. restore_lowering_context - Context復元 ## ファイル構成 src/mir/builder/ ├── calls/ │ ├── mod.rs # 公開インターフェース │ ├── lowering.rs # 関数lowering(354行) │ └── utils.rs # ユーティリティ(45行) └── builder_calls.rs # 削減版(766行) ## 次のステップ Phase 2: emit.rs 作成(~500行移行) Phase 3: build.rs 作成(~350行移行) 最終目標: builder_calls.rs を200行以内に 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> Co-Authored-By: Task先生 <task@anthropic.com>
2025-11-17 17:02:01 +09:00
//! 🎯 箱理論: Call系処理のモジュール分離
//!
//! 責務別に明確に分離された「箱」の集合:
//! - lowering: 関数loweringstatic/instance method → MIR function
//! - utils: ユーティリティresolve/parse/extract
refactor(builder): 箱理論リファクタリング Phase 2完了 - 驚異的94%削減達成! 🎯 目標75%削減を大幅に超える94%削減を達成! ## Phase 2 成果 ✅ builder_calls.rs: 766行 → 60行(706行削減、92%削減) ✅ calls/emit.rs: 415行(新規、Call命令発行専用) ✅ calls/build.rs: 505行(新規、Call構築専用) ✅ ビルド・テスト成功(0エラー) ## 累積削減効果 Phase 1: 982行 → 766行(216行削減、22%削減) Phase 2: 766行 → 60行(706行削減、92%削減) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 合計: 982行 → 60行(922行削減、94%削減達成!) ## 箱理論実装詳細 ### 1. 責務ごとに箱に分離 - emit.rs: Call命令発行専用 - emit_unified_call, emit_legacy_call等 - 統一Call/LegacyCallの明確な分離 - build.rs: Call構築専用 - build_function_call, build_method_call等 - 関数Call/メソッドCallの段階的構築 - lowering.rs: 関数lowering専用(Phase 1) - utils.rs: ユーティリティ専用(Phase 1) ### 2. 境界を明確に - 各モジュールで公開インターフェース明確化 - calls/mod.rs で統一的にre-export - 内部関数は適切に隠蔽 ### 3. いつでも戻せる - builder_calls.rs で既存API完全保持 - re-exportによる完全な後方互換性 - 段階的移行で各ステップでビルド確認 ### 4. 巨大関数は分割 **emit.rs**: - emit_unified_call (元231行) → 複数の小関数に分割 - try_global_fallback_handlers (~50行) - materialize_receiver_in_callee (~30行) - emit_global_unified (~20行) **build.rs**: - build_function_call (元134行) → 7つの小関数に分割 - try_build_typeop_function (~25行) - try_handle_math_function (~60行) - build_call_args (~7行) - 各関数30-60行に収まる - build_method_call (元107行) → 5つの小関数に分割 - try_build_static_method_call (~10行) - try_build_me_method_call (~35行) - 各関数が単一の明確な責務 ## ファイル構成 src/mir/builder/ ├── calls/ │ ├── mod.rs # 公開インターフェース │ ├── lowering.rs # 関数lowering(354行) │ ├── emit.rs # Call発行(415行)✨ NEW │ ├── build.rs # Call構築(505行)✨ NEW │ └── utils.rs # ユーティリティ(45行) └── builder_calls.rs # 最小限(60行、94%削減!) ## 技術的成果 - 可読性向上: 100行超 → 30-60行の小関数 - 保守性向上: 責務分離で影響範囲最小化 - 再利用性向上: 明確なIF定義で安全使用 - テスト容易性: 小さな単位でテスト可能 ## 次のステップ候補 - Phase 3: handlers.rs 作成(オプション) - さらなる細分化(emit/unified.rs 等) - ValueId(6)エラーの根本原因調査 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> Co-Authored-By: Task先生 <task@anthropic.com>
2025-11-17 17:11:21 +09:00
//! - emit: Call命令発行統一Call/Legacy Call ✅ Phase 2完了
//! - build: Call構築function call/method call ✅ Phase 2完了
refactor(builder): 箱化 - CalleeGuardBox抽出(構造ガード専用箱) 🎯 箱理論の実践: 単一責務の箱を作る ## 箱化内容 ✅ CalleeGuardBox(約150行、テスト込み約200行) - 責務: 構造ガード専任(静的Box/ランタイムBox混線防止) - 状態: value_typesのみ保持(最小化) - ピュア関数的: Callee入力 → 検証・変換 → Callee出力 ## 実装 - src/mir/builder/calls/guard.rs: 新ファイル - CalleeGuardBox::apply_static_runtime_guard() - CalleeGuardBox::is_me_call() - CalleeGuardBox::get_box_type() - 単体テスト3件追加(me-call検出、正規化) - src/mir/builder/calls/emit.rs: 箱化移行 - emit_unified_call_impl内でCalleeGuardBox使用 - 古いapply_static_runtime_guardメソッド削除(約50行削減) - src/mir/builder/calls/mod.rs: モジュール追加 - pub mod guard;(Phase 25.1d完了マーク) ## 箱理論原則 ✅ 箱にする: 構造ガード機能を1箱に集約 ✅ 境界を作る: MirBuilderから分離、独立した責務 ✅ 戻せる: 独立箱なので切り離し・差し替え可能 ✅ テスト容易: 単体テスト3件で検証済み ## 効果 - コード整理: emit.rs 約50行削減 - 保守性向上: 構造ガードロジックが1ファイルに集約 - テスト品質: 単体テストで挙動保証 - 拡張容易: 将来の構造ガード追加が容易 ## テスト結果 - ✅ CalleeGuardBox単体テスト 3件パス - ✅ 既存テスト mir_stageb_like系 パス - ✅ ビルド成功(0エラー) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-17 23:21:36 +09:00
//! - guard: 構造ガード静的Box/ランタイムBox混線防止 ✅ Phase 25.1d完了
refactor(builder): 箱理論リファクタリング Phase 1完了 🎯 builder_calls.rs (982行) を箱理論で責務別にモジュール分割 ## 成果 ✅ builder_calls.rs: 982行 → 766行(-216行、22%削減) ✅ calls/lowering.rs: 354行(新規、箱理論6段階パターン) ✅ calls/utils.rs: 45行(新規、ユーティリティ統一) ✅ ビルド・テスト完全成功(0エラー) ## 箱理論の実装 1. 責務ごとに箱に分離: - lowering: 関数lowering専用 - utils: ユーティリティ統一 - emit/build: Phase 2で実装予定 2. 境界を明確に: - mod.rs で公開インターフェース定義 - pub(in crate::mir::builder) で適切な可視性制御 3. いつでも戻せる: - 段階的移行、各ステップでビルド確認 - 既存API完全保持(互換性100%) 4. 巨大関数は分割: - lower_static_method_as_function: 125行 → 6段階に分解 - lower_method_as_function: 80行 → 6段階に分解 ## 箱理論6段階パターン 1. prepare_lowering_context - Context準備 2. create_function_skeleton - 関数スケルトン作成 3. setup_function_params - パラメータ設定 4. lower_function_body - 本体lowering 5. finalize_function - 関数finalize 6. restore_lowering_context - Context復元 ## ファイル構成 src/mir/builder/ ├── calls/ │ ├── mod.rs # 公開インターフェース │ ├── lowering.rs # 関数lowering(354行) │ └── utils.rs # ユーティリティ(45行) └── builder_calls.rs # 削減版(766行) ## 次のステップ Phase 2: emit.rs 作成(~500行移行) Phase 3: build.rs 作成(~350行移行) 最終目標: builder_calls.rs を200行以内に 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> Co-Authored-By: Task先生 <task@anthropic.com>
2025-11-17 17:02:01 +09:00
// Existing modules (already implemented elsewhere)
pub mod annotation;
pub mod call_target;
refactor(builder): 箱理論リファクタリング Phase 1完了 🎯 builder_calls.rs (982行) を箱理論で責務別にモジュール分割 ## 成果 ✅ builder_calls.rs: 982行 → 766行(-216行、22%削減) ✅ calls/lowering.rs: 354行(新規、箱理論6段階パターン) ✅ calls/utils.rs: 45行(新規、ユーティリティ統一) ✅ ビルド・テスト完全成功(0エラー) ## 箱理論の実装 1. 責務ごとに箱に分離: - lowering: 関数lowering専用 - utils: ユーティリティ統一 - emit/build: Phase 2で実装予定 2. 境界を明確に: - mod.rs で公開インターフェース定義 - pub(in crate::mir::builder) で適切な可視性制御 3. いつでも戻せる: - 段階的移行、各ステップでビルド確認 - 既存API完全保持(互換性100%) 4. 巨大関数は分割: - lower_static_method_as_function: 125行 → 6段階に分解 - lower_method_as_function: 80行 → 6段階に分解 ## 箱理論6段階パターン 1. prepare_lowering_context - Context準備 2. create_function_skeleton - 関数スケルトン作成 3. setup_function_params - パラメータ設定 4. lower_function_body - 本体lowering 5. finalize_function - 関数finalize 6. restore_lowering_context - Context復元 ## ファイル構成 src/mir/builder/ ├── calls/ │ ├── mod.rs # 公開インターフェース │ ├── lowering.rs # 関数lowering(354行) │ └── utils.rs # ユーティリティ(45行) └── builder_calls.rs # 削減版(766行) ## 次のステップ Phase 2: emit.rs 作成(~500行移行) Phase 3: build.rs 作成(~350行移行) 最終目標: builder_calls.rs を200行以内に 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> Co-Authored-By: Task先生 <task@anthropic.com>
2025-11-17 17:02:01 +09:00
pub mod call_unified;
pub mod extern_calls;
pub mod function_lowering;
refactor(builder): 箱理論リファクタリング Phase 1完了 🎯 builder_calls.rs (982行) を箱理論で責務別にモジュール分割 ## 成果 ✅ builder_calls.rs: 982行 → 766行(-216行、22%削減) ✅ calls/lowering.rs: 354行(新規、箱理論6段階パターン) ✅ calls/utils.rs: 45行(新規、ユーティリティ統一) ✅ ビルド・テスト完全成功(0エラー) ## 箱理論の実装 1. 責務ごとに箱に分離: - lowering: 関数lowering専用 - utils: ユーティリティ統一 - emit/build: Phase 2で実装予定 2. 境界を明確に: - mod.rs で公開インターフェース定義 - pub(in crate::mir::builder) で適切な可視性制御 3. いつでも戻せる: - 段階的移行、各ステップでビルド確認 - 既存API完全保持(互換性100%) 4. 巨大関数は分割: - lower_static_method_as_function: 125行 → 6段階に分解 - lower_method_as_function: 80行 → 6段階に分解 ## 箱理論6段階パターン 1. prepare_lowering_context - Context準備 2. create_function_skeleton - 関数スケルトン作成 3. setup_function_params - パラメータ設定 4. lower_function_body - 本体lowering 5. finalize_function - 関数finalize 6. restore_lowering_context - Context復元 ## ファイル構成 src/mir/builder/ ├── calls/ │ ├── mod.rs # 公開インターフェース │ ├── lowering.rs # 関数lowering(354行) │ └── utils.rs # ユーティリティ(45行) └── builder_calls.rs # 削減版(766行) ## 次のステップ Phase 2: emit.rs 作成(~500行移行) Phase 3: build.rs 作成(~350行移行) 最終目標: builder_calls.rs を200行以内に 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> Co-Authored-By: Task先生 <task@anthropic.com>
2025-11-17 17:02:01 +09:00
pub mod method_resolution;
pub mod special_handlers;
refactor(builder): Phase 3-A - UnifiedCallEmitterBox実装完了 箱理論の実践:統一Call発行ロジックを独立した箱に集約 - 単一責務:統一Call発行のみ(Legacy Callは別モジュール) - 状態レス:MirBuilderを引数で受け取る設計 - ピュア関数的:入力CallTarget → 解決・発行 → MirCall命令 実装内容: 1. 新規ファイル作成 - src/mir/builder/calls/unified_emitter.rs (~250行) - UnifiedCallEmitterBox構造体 - 4つの主要メソッド: * emit_unified_call (公開API) * emit_unified_call_impl (コア実装) * emit_global_unified (Global関数呼び出し) * emit_value_unified (第一級関数呼び出し) 2. emit.rs からロジック移動 - emit_unified_call → 委譲に変更(1行) - emit_unified_call_impl → 削除(~150行削減) - emit_global_unified → 削除(委譲に変更) - emit_value_unified → 削除(委譲に変更) - try_global_fallback_handlers → pub(super)に変更 - materialize_receiver_in_callee → pub(super)に変更 3. mod.rs更新 - unified_emitter モジュール追加 箱化効果(Phase 3-A単独): - emit.rs: 467行 → 261行(-206行、44%削減!) - unified_emitter.rs: 250行(新規、Unified専用箱) - 読みやすさ大幅向上:統一Call発行ロジックが独立 - 責務分離明確化:Legacy/Unifiedの完全分離 Phase 3 進捗: - Phase 3-A: UnifiedCallEmitterBox ✅ 完了(本コミット) - Phase 3-B: EffectsAnalyzerBox ⏳ 次の目標 - Phase 3-C: CallMaterializerBox ⏳ 最終目標 ビルド・テスト: - cargo build --release: ✅ 成功 - 既存機能互換性: ✅ 完全保持
2025-11-17 23:49:18 +09:00
// New refactored modules (Box Theory Phase 1 & 2 & 25.1d & Phase 3)
pub mod build; // Phase 2: Call building
refactor(builder): Phase 3-B,C完了 - 読みやすさ革命達成! 箱理論の完全実践:Call系処理を9個の専用箱で完全分離 - Phase 3-B: EffectsAnalyzerBox(エフェクト解析専用) - Phase 3-C: CallMaterializerBox(Call前処理専用) 実装内容: 【Phase 3-B: EffectsAnalyzerBox】 1. 新規ファイル作成 - src/mir/builder/calls/effects_analyzer.rs (~155行) - compute_call_effects: Calleeから副作用マスクを計算 - is_pure_method: Pureメソッド判定 - 5つのユニットテスト ✅ 2. call_unified.rs整理 - compute_call_effects → 委譲に変更 - is_pure_method → 削除 - ~50行削減 【Phase 3-C: CallMaterializerBox】 1. 新規ファイル作成 - src/mir/builder/calls/materializer.rs (~151行) - try_global_fallback_handlers: Global関数フォールバック - materialize_receiver_in_callee: Receiver実体化 - Call前処理全般を集約 2. emit.rs整理 - 2つの大きな関数を委譲に変更 - ~115行削減 3. unified_emitter.rs更新 - CallMaterializerBox経由に変更 箱化効果(Phase 3全体): 【劇的な削減】 - emit.rs: 467行 → 164行(-303行、65%削減!) - call_unified.rs: 144行 → 98行(-46行、32%削減!) 【新規箱(責務明確・読みやすい)】 - unified_emitter.rs: 250行(統一Call発行専用) - effects_analyzer.rs: 155行(エフェクト解析専用) - materializer.rs: 151行(Call前処理専用) 【読みやすさ革命】 - ✅ 500行超えファイル根絶(最大489行まで) - ✅ 責務分離完璧(各ファイルが単一責務) - ✅ 9個の専用箱で管理(guard/resolver/emitter/effects/materializer) - ✅ テスト容易性劇的向上(独立した箱で簡単テスト) Phase 3 最終状態: - Phase 3-A: UnifiedCallEmitterBox ✅ - Phase 3-B: EffectsAnalyzerBox ✅ - Phase 3-C: CallMaterializerBox ✅ - 読みやすさ革命 ✅ 完全達成! ビルド・テスト: - cargo build --release: ✅ 成功 - effects_analyzer tests (5): ✅ all passed - 既存機能互換性: ✅ 完全保持
2025-11-17 23:57:04 +09:00
pub mod effects_analyzer; // Phase 3-B: Effects analyzer (エフェクト解析専用箱)
pub mod emit; // Phase 2: Call emission
pub mod guard; // Phase 25.1d: Structural guard (static/runtime box separation)
pub mod lowering;
pub mod materializer;
pub mod resolver; // Phase 25.1d: Callee resolution (CallTarget → Callee)
pub mod unified_emitter; // Phase 3-A: Unified call emitter (統一Call発行専用箱)
pub mod utils; // Phase 3-C: Call materializer (Call前処理・準備専用箱)
refactor(builder): 箱理論リファクタリング Phase 1完了 🎯 builder_calls.rs (982行) を箱理論で責務別にモジュール分割 ## 成果 ✅ builder_calls.rs: 982行 → 766行(-216行、22%削減) ✅ calls/lowering.rs: 354行(新規、箱理論6段階パターン) ✅ calls/utils.rs: 45行(新規、ユーティリティ統一) ✅ ビルド・テスト完全成功(0エラー) ## 箱理論の実装 1. 責務ごとに箱に分離: - lowering: 関数lowering専用 - utils: ユーティリティ統一 - emit/build: Phase 2で実装予定 2. 境界を明確に: - mod.rs で公開インターフェース定義 - pub(in crate::mir::builder) で適切な可視性制御 3. いつでも戻せる: - 段階的移行、各ステップでビルド確認 - 既存API完全保持(互換性100%) 4. 巨大関数は分割: - lower_static_method_as_function: 125行 → 6段階に分解 - lower_method_as_function: 80行 → 6段階に分解 ## 箱理論6段階パターン 1. prepare_lowering_context - Context準備 2. create_function_skeleton - 関数スケルトン作成 3. setup_function_params - パラメータ設定 4. lower_function_body - 本体lowering 5. finalize_function - 関数finalize 6. restore_lowering_context - Context復元 ## ファイル構成 src/mir/builder/ ├── calls/ │ ├── mod.rs # 公開インターフェース │ ├── lowering.rs # 関数lowering(354行) │ └── utils.rs # ユーティリティ(45行) └── builder_calls.rs # 削減版(766行) ## 次のステップ Phase 2: emit.rs 作成(~500行移行) Phase 3: build.rs 作成(~350行移行) 最終目標: builder_calls.rs を200行以内に 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> Co-Authored-By: Task先生 <task@anthropic.com>
2025-11-17 17:02:01 +09:00
// Re-export public interfaces
#[allow(unused_imports)]
pub use build::*;
#[allow(unused_imports)]
refactor(builder): 箱理論リファクタリング Phase 1完了 🎯 builder_calls.rs (982行) を箱理論で責務別にモジュール分割 ## 成果 ✅ builder_calls.rs: 982行 → 766行(-216行、22%削減) ✅ calls/lowering.rs: 354行(新規、箱理論6段階パターン) ✅ calls/utils.rs: 45行(新規、ユーティリティ統一) ✅ ビルド・テスト完全成功(0エラー) ## 箱理論の実装 1. 責務ごとに箱に分離: - lowering: 関数lowering専用 - utils: ユーティリティ統一 - emit/build: Phase 2で実装予定 2. 境界を明確に: - mod.rs で公開インターフェース定義 - pub(in crate::mir::builder) で適切な可視性制御 3. いつでも戻せる: - 段階的移行、各ステップでビルド確認 - 既存API完全保持(互換性100%) 4. 巨大関数は分割: - lower_static_method_as_function: 125行 → 6段階に分解 - lower_method_as_function: 80行 → 6段階に分解 ## 箱理論6段階パターン 1. prepare_lowering_context - Context準備 2. create_function_skeleton - 関数スケルトン作成 3. setup_function_params - パラメータ設定 4. lower_function_body - 本体lowering 5. finalize_function - 関数finalize 6. restore_lowering_context - Context復元 ## ファイル構成 src/mir/builder/ ├── calls/ │ ├── mod.rs # 公開インターフェース │ ├── lowering.rs # 関数lowering(354行) │ └── utils.rs # ユーティリティ(45行) └── builder_calls.rs # 削減版(766行) ## 次のステップ Phase 2: emit.rs 作成(~500行移行) Phase 3: build.rs 作成(~350行移行) 最終目標: builder_calls.rs を200行以内に 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> Co-Authored-By: Task先生 <task@anthropic.com>
2025-11-17 17:02:01 +09:00
pub use call_target::CallTarget;
#[allow(unused_imports)]
pub use emit::*;
#[allow(unused_imports)]
refactor(builder): 箱理論リファクタリング Phase 1完了 🎯 builder_calls.rs (982行) を箱理論で責務別にモジュール分割 ## 成果 ✅ builder_calls.rs: 982行 → 766行(-216行、22%削減) ✅ calls/lowering.rs: 354行(新規、箱理論6段階パターン) ✅ calls/utils.rs: 45行(新規、ユーティリティ統一) ✅ ビルド・テスト完全成功(0エラー) ## 箱理論の実装 1. 責務ごとに箱に分離: - lowering: 関数lowering専用 - utils: ユーティリティ統一 - emit/build: Phase 2で実装予定 2. 境界を明確に: - mod.rs で公開インターフェース定義 - pub(in crate::mir::builder) で適切な可視性制御 3. いつでも戻せる: - 段階的移行、各ステップでビルド確認 - 既存API完全保持(互換性100%) 4. 巨大関数は分割: - lower_static_method_as_function: 125行 → 6段階に分解 - lower_method_as_function: 80行 → 6段階に分解 ## 箱理論6段階パターン 1. prepare_lowering_context - Context準備 2. create_function_skeleton - 関数スケルトン作成 3. setup_function_params - パラメータ設定 4. lower_function_body - 本体lowering 5. finalize_function - 関数finalize 6. restore_lowering_context - Context復元 ## ファイル構成 src/mir/builder/ ├── calls/ │ ├── mod.rs # 公開インターフェース │ ├── lowering.rs # 関数lowering(354行) │ └── utils.rs # ユーティリティ(45行) └── builder_calls.rs # 削減版(766行) ## 次のステップ Phase 2: emit.rs 作成(~500行移行) Phase 3: build.rs 作成(~350行移行) 最終目標: builder_calls.rs を200行以内に 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> Co-Authored-By: Task先生 <task@anthropic.com>
2025-11-17 17:02:01 +09:00
pub use lowering::*;
#[allow(unused_imports)]
refactor(builder): 箱理論リファクタリング Phase 1完了 🎯 builder_calls.rs (982行) を箱理論で責務別にモジュール分割 ## 成果 ✅ builder_calls.rs: 982行 → 766行(-216行、22%削減) ✅ calls/lowering.rs: 354行(新規、箱理論6段階パターン) ✅ calls/utils.rs: 45行(新規、ユーティリティ統一) ✅ ビルド・テスト完全成功(0エラー) ## 箱理論の実装 1. 責務ごとに箱に分離: - lowering: 関数lowering専用 - utils: ユーティリティ統一 - emit/build: Phase 2で実装予定 2. 境界を明確に: - mod.rs で公開インターフェース定義 - pub(in crate::mir::builder) で適切な可視性制御 3. いつでも戻せる: - 段階的移行、各ステップでビルド確認 - 既存API完全保持(互換性100%) 4. 巨大関数は分割: - lower_static_method_as_function: 125行 → 6段階に分解 - lower_method_as_function: 80行 → 6段階に分解 ## 箱理論6段階パターン 1. prepare_lowering_context - Context準備 2. create_function_skeleton - 関数スケルトン作成 3. setup_function_params - パラメータ設定 4. lower_function_body - 本体lowering 5. finalize_function - 関数finalize 6. restore_lowering_context - Context復元 ## ファイル構成 src/mir/builder/ ├── calls/ │ ├── mod.rs # 公開インターフェース │ ├── lowering.rs # 関数lowering(354行) │ └── utils.rs # ユーティリティ(45行) └── builder_calls.rs # 削減版(766行) ## 次のステップ Phase 2: emit.rs 作成(~500行移行) Phase 3: build.rs 作成(~350行移行) 最終目標: builder_calls.rs を200行以内に 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> Co-Authored-By: Task先生 <task@anthropic.com>
2025-11-17 17:02:01 +09:00
pub use utils::*;