e404746612
refactor(mir): Phase 139-P3-B - RoutingDecision を enum 対応 + レガシー削除
...
- RoutingDecision の missing_caps を Vec<CapabilityTag> に変更(型安全化)
- error_tags は to_tag() メソッドで自動生成
- 全 callsite を enum variant に修正
- capability_tags モジュール(文字列定数群)を完全削除
- 全テスト PASS(型安全性向上を確認)
- フォーマット適用
2025-12-16 07:02:14 +09:00
9170f0a85d
refactor(mir): Remove VariableContext legacy fields (Phase 2-6/7)
...
完全移行→削除の安全順序(Option C)に従い、VariableContext の
deprecated フィールドと sync helpers を完全削除。
## Changes
- Migrated all 66+ access sites to variable_ctx.variable_map
- Removed 1 deprecated field (variable_map) from MirBuilder
- Removed 2 sync helpers (sync_variable_ctx_to_legacy, sync_legacy_to_variable_ctx)
- Fixed BoxCompilationContext.variable_map references (kept as-is, different scope)
- Fixed ExitBindingBuilder.variable_map references (kept as-is, local field)
- Updated observer.rs to use variable_map() accessor method
## JoinIR Integration Verified
- CarrierInfo::from_variable_map() works correctly
- ExitLine contract maintained (Phase 132-135)
- NYASH_TRACE_VARMAP debug support preserved
- Pattern 1-5 lowering all functional
## Tests
- cargo test --release --lib: 1033 passed, 0 failed
- phase135_trim_mir_verify.sh: PASS (MIR SSA/ValueId OK)
- cargo build --release: SUCCESS
- Deprecation warnings: reduced (86 remaining, from other contexts)
## Statistics
- 27 files changed
- 146 insertions(+), 174 deletions(-)
- Net: -28 lines
Phase 2 Progress: 6/7 contexts complete (86%)
- ✅ MetadataContext
- ✅ CoreContext
- ✅ TypeContext
- ✅ ScopeContext
- ✅ BindingContext
- ✅ VariableContext (this commit)
- ⏳ CompilationContext (Phase 2-7 next)
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com >
2025-12-16 03:48:44 +09:00
b92f85f993
refactor(mir): Remove TypeContext legacy fields (Phase 2-3/7)
...
完全移行→削除の安全順序(Option C)に従い、TypeContext の
deprecated フィールドと sync helpers を完全削除。
⚠️ 危険ゾーン: TypeFactsBox 等の同名フィールドと混同しないよう、
ファイル単位で手作業移行を実施。
## Changes
- Migrated all MirBuilder access sites to type_ctx.* (manual, 40+ files)
- Removed 3 deprecated fields (value_types, value_kinds, value_origin_newbox)
- Removed 2 sync helpers (sync_type_ctx_to_legacy, sync_legacy_to_type_ctx)
- Verified TypeFactsBox, CalleeGuardBox unchanged (no false positives)
## Tests
- cargo test --release --lib: 1029/1033 PASS
- TypeFactsBox integration: PASS (borrowed references unchanged)
- Deprecation warnings: 456 → 255 (-201, -44%)
## Safety Verification
✅ TypeFactsBox unchanged (still uses &'a BTreeMap borrowed references)
✅ CalleeGuardBox unchanged
✅ CalleeResolverBox unchanged
✅ BoxCompilationContext unchanged
Phase 2 Progress: 3/7 contexts complete (43%)
- ✅ MetadataContext
- ✅ CoreContext
- ✅ TypeContext (this commit)
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com >
2025-12-15 23:27:24 +09:00
466e636af6
Span trace utilities and runner source hint
2025-11-24 14:17:02 +09:00
4565f7476d
wip(mir): StaticCompiler receiver正規化の部分的修正 - 将来の根治に向けた基盤整備
...
【修正内容】
1. src/mir/builder/calls/guard.rs
- receiver型情報がない場合のpass-through処理追加
- ME-CALL として後段処理に委譲
2. src/mir/builder/ssa/local.rs
- receiver kind で型情報がない場合、origin から型を推論
- value_types への伝播を強化
【現状】
- 完全な根治には至っていない(MIR builder設計レベルの複雑な依存関係)
- .hako側workaround (51d53c29 ) が実用的な解決策として機能中
【根本原因】
- value_origin_newbox に ParserBox が保持される
- value_types に実際の型(String等)が欠落
- receiver に型情報がないまま StaticCompiler Method に解決される問題
【今後の方向性】
- MIR builder の型伝播システム全体の見直しが必要
- Phase 25.1: Stage-1 bridge receiver bug (partial fix)
2025-11-21 13:28:35 +09:00
f9d100ce01
chore: Phase 25.1 完了 - LoopForm v2/Stage1 CLI/環境変数削減 + Phase 26-D からの変更
...
Phase 25.1 完了成果:
- ✅ LoopForm v2 テスト・ドキュメント・コメント完備
- 4ケース(A/B/C/D)完全テストカバレッジ
- 最小再現ケース作成(SSAバグ調査用)
- SSOT文書作成(loopform_ssot.md)
- 全ソースに [LoopForm] コメントタグ追加
- ✅ Stage-1 CLI デバッグ環境構築
- stage1_cli.hako 実装
- stage1_bridge.rs ブリッジ実装
- デバッグツール作成(stage1_debug.sh/stage1_minimal.sh)
- アーキテクチャ改善提案文書
- ✅ 環境変数削減計画策定
- 25変数の完全調査・分類
- 6段階削減ロードマップ(25→5、80%削減)
- 即時削除可能変数特定(NYASH_CONFIG/NYASH_DEBUG)
Phase 26-D からの累積変更:
- PHI実装改善(ExitPhiBuilder/HeaderPhiBuilder等)
- MIRビルダーリファクタリング
- 型伝播・最適化パス改善
- その他約300ファイルの累積変更
🎯 技術的成果:
- SSAバグ根本原因特定(条件分岐内loop変数変更)
- Region+next_iパターン適用完了(UsingCollectorBox等)
- LoopFormパターン文書化・テスト化完了
- セルフホスティング基盤強化
Co-Authored-By: Claude <noreply@anthropic.com >
Co-Authored-By: ChatGPT <noreply@openai.com >
Co-Authored-By: Task Assistant <task@anthropic.com >
2025-11-21 06:25:17 +09:00
39f5256c18
📊 Phase 25.1l: Region観測レイヤー骨格 + スコープ契約設計理解
...
**Region Box統一理論の実装開始**
新規追加:
- src/mir/region/mod.rs: Region/RefSlotKind型定義
- src/mir/region/observer.rs: Region観測レイヤー
- docs/development/roadmap/phases/phase-25.1l/: 設計ドキュメント
主要概念:
- Region Box = Function/Loop/If の統一箱
- RefSlotKind = GC管理用スロット種別(Strong/Weak/Borrowed/NonRef)
- 観測専用(NYASH_REGION_TRACE=1で動作、挙動変更なし)
設計理解の深化:
- ValueId(40)問題 = LoopForm v2スコープ契約違反の症状
- 根本解決 = Region観測で無名一時値のスコープまたぎを検出
- 箱理論3原則: 境界明確化/差し替え可能/段階的移行
関連議論:
- ChatGPT提案: Region統一理論でGC/寿命管理の基盤構築
- SlotRegistry: 変数の単一真実源(SSOT)
- 階層構造: FunctionRegion → LoopRegion → IfRegion
次のステップ:
- Phase 1: Region観測(現在)- 非破壊的追加
- Phase 2: メタデータ出力(MIR JSON拡張)
- Phase 3: GC統合(retain/release挿入)
テスト追加:
- lang/src/compiler/tests/stageb_mini_driver.hako
- tools/test_loopssa_breakfinder_slot.sh
Build: ✅ 全警告は既存のもの
Tests: 既存テスト全て緑維持
2025-11-19 02:44:40 +09:00
f7d218190e
fix(mir/builder): improve LocalSSA error handling and add Copy/Call traces
...
Changes:
- src/mir/builder/ssa/local.rs:
- Fix LocalSSA::ensure() to check emit_instruction() errors
- Return original value instead of undefined ValueId on failure
- Add NYASH_LOCAL_SSA_TRACE logging for failures
- src/mir/builder.rs:
- Add Copy instruction trace with NYASH_LOCAL_SSA_TRACE=1
- Add Call instruction trace for Method calls
- Helps debug receiver materialization issues
- src/mir/builder/builder_calls.rs:
- Remove duplicate receiver materialization (moved to builder.rs)
- Rely on emit_instruction for final receiver handling
Related to Stage-B ValueId(21) undefined error investigation.
Next: Fix Nyash MirBuilder receiver handling in basic_lower_box.hako
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude <noreply@anthropic.com >
2025-11-17 08:41:50 +09:00
06159da58b
wip(recv): emit_unified_call で最終LocalSSA試行(未完)
...
- builder_calls.rs の emit_unified_call 末尾で recv 再materialize
- しかし MIR に Copy が反映されない問題が残る
- 次: emit_instruction 側に責務を移す構造的修正へ
2025-11-17 07:58:44 +09:00
82b6c4e834
Phase 25.1b: VM undefined-value diagnostics and builder SSA helpers
2025-11-17 03:19:03 +09:00
eadde8d1dd
fix(mir/builder): use function-local ValueId throughout MIR builder
...
Phase 25.1b: Complete SSA fix - eliminate all global ValueId usage in function contexts.
Root cause: ~75 locations throughout MIR builder were using global value
generator (self.value_gen.next()) instead of function-local allocator
(f.next_value_id()), causing SSA verification failures and runtime
"use of undefined value" errors.
Solution:
- Added next_value_id() helper that automatically chooses correct allocator
- Fixed 19 files with ~75 occurrences of ValueId allocation
- All function-context allocations now use function-local IDs
Files modified:
- src/mir/builder/utils.rs: Added next_value_id() helper, fixed 8 locations
- src/mir/builder/builder_calls.rs: 17 fixes
- src/mir/builder/ops.rs: 8 fixes
- src/mir/builder/stmts.rs: 7 fixes
- src/mir/builder/emission/constant.rs: 6 fixes
- src/mir/builder/rewrite/*.rs: 10 fixes
- + 13 other files
Verification:
- cargo build --release: SUCCESS
- Simple tests with NYASH_VM_VERIFY_MIR=1: Zero undefined errors
- Multi-parameter static methods: All working
Known remaining: ValueId(22) in Stage-B (separate issue to investigate)
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude <noreply@anthropic.com >
2025-11-17 00:48:18 +09:00
dda65b94b7
Phase 21.7 normalization: optimization pre-work + bench harness expansion
...
- Add opt-in optimizations (defaults OFF)
- Ret purity verifier: NYASH_VERIFY_RET_PURITY=1
- strlen FAST enhancement for const handles
- FAST_INT gate for same-BB SSA optimization
- length cache for string literals in llvmlite
- Expand bench harness (tools/perf/microbench.sh)
- Add branch/call/stringchain/arraymap/chip8/kilo cases
- Auto-calculate ratio vs C reference
- Document in benchmarks/README.md
- Compiler health improvements
- Unify PHI insertion to insert_phi_at_head()
- Add NYASH_LLVM_SKIP_BUILD=1 for build reuse
- Runtime & safety enhancements
- Clarify Rust/Hako ownership boundaries
- Strengthen receiver localization (LocalSSA/pin/after-PHIs)
- Stop excessive PluginInvoke→BoxCall rewrites
- Update CURRENT_TASK.md, docs, and canaries
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude <noreply@anthropic.com >
2025-11-13 16:40:58 +09:00
dd65cf7e4c
builder+vm: unify method calls via emit_unified_call; add RouterPolicy trace; finalize LocalSSA/BlockSchedule guards; docs + selfhost quickstart
...
- Unify standard method calls to emit_unified_call; route via RouterPolicy and apply rewrite::{special,known} at a single entry.\n- Stabilize emit-time invariants: LocalSSA finalize + BlockSchedule PHI→Copy→Call ordering; metadata propagation on copies.\n- Known rewrite default ON (userbox only, strict guards) with opt-out flag NYASH_REWRITE_KNOWN_DEFAULT=0.\n- Expand TypeAnnotation whitelist (is_digit_char/is_hex_digit_char/is_alpha_char/Map.has).\n- Docs: unified-method-resolution design note; Quick Reference normalization note; selfhosting/quickstart.\n- Tools: add tools/selfhost_smoke.sh (dev-only).\n- Keep behavior unchanged for Unknown/core/user-instance via BoxCall fallback; all tests green (quick/integration).
2025-09-28 20:38:09 +09:00