|
|
c722dc3bf6
|
feat(joinir): Phase 57 - OwnershipAnalyzer implementation (dev-only)
AST/ProgramJSON から OwnershipPlan を生成する解析箱を実装。
Key changes:
- New analyzer.rs (632 lines):
- OwnershipAnalyzer: Main analysis engine
- ScopeKind: Function/Loop/Block/If scope types
- ScopeInfo: Internal scope representation with reads/writes tracking
Algorithm:
1. Build scope tree (Function/Loop/Block/If hierarchy)
2. Collect reads/writes/condition_reads per scope
3. Apply body-local ownership rule (if/block locals → enclosing Loop/Function)
4. Generate OwnershipPlan: owned_vars, relay_writes, captures, condition_captures
Core invariants enforced:
- Ownership Uniqueness: Each variable has exactly one owner
- Carrier Locality: carriers = writes ∩ owned
- Relay Propagation: writes to ancestor-owned → relay up
- Capture Read-Only: captures have no PHI at this scope
Tests: 7 ownership unit tests + 946 existing (0 regressions)
- test_simple_loop_ownership: relay writes to function
- test_loop_local_carrier: owned AND written = carrier
- test_capture_read_only: read-only captures
- test_nested_loop_relay: relay chains through nested loops
Design: "読むのは自由、管理は直下だけ"
Phase 57 is dev-only - not yet connected to lowering.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
|
2025-12-12 17:51:53 +09:00 |
|
|
|
2d10c5ce3f
|
docs(joinir): Phase 56 - Ownership-Relay Design + interface skeleton
「読むのは自由、管理は直下 owned だけ」アーキテクチャの設計文書と型定義。
Key changes:
- Design doc: phase56-ownership-relay-design.md
- Core definitions: owned/carriers/captures/relay
- Invariants: Ownership Uniqueness, Carrier Locality, Relay Propagation
- Shadowing rules, multi-writer merge semantics
- JoinIR mapping from current system to new system
- Implementation phases roadmap (56-61)
- New module: src/mir/join_ir/ownership/
- types.rs: ScopeId, ScopeOwnedVar, RelayVar, CapturedVar, OwnershipPlan
- mod.rs: Module documentation with responsibility boundaries
- README.md: Usage guide and examples
- API methods:
- OwnershipPlan::carriers() - owned AND written variables
- OwnershipPlan::condition_only_carriers() - condition-only carriers
- OwnershipPlan::verify_invariants() - invariant checking
Tests: 942/942 PASS (+3 unit tests)
Zero behavioral change - analysis module skeleton only.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
|
2025-12-12 17:39:59 +09:00 |
|