feat(joinir): Phase 246-EX Part 1 - FromHost carrier infrastructure

Extends Phase 247-EX dual-value architecture for _atoi NumberAccumulation
support. Implements FromHost carrier handling throughout JoinIR pipeline.

## Problem Analysis

_atoi requires `result = result * 10 + digit_pos` where:
- digit_pos is promoted to dual carriers: is_digit_pos (bool) + digit_value (int)
- digit_value is used in NumberAccumulation but NOT updated itself
- Existing infrastructure filtered out carriers without updates

## Implementation

### 1. Carrier Filtering (pattern2_with_break.rs:507-514)
**Added FromHost retention**:
```rust
carrier_updates.contains_key(&carrier.name)
    || carrier.role == CarrierRole::ConditionOnly
    || carrier.init == CarrierInit::FromHost  // Phase 247-EX
```

**Effect**: Keeps digit_value carrier despite no update expression

### 2. Carrier Update Passthrough (loop_with_break_minimal.rs:411-426)
**Added FromHost passthrough**:
- FromHost carriers without updates pass through from env
- Similar to Phase 227 ConditionOnly handling
- Logged as `[loop/carrier_update] Phase 247-EX: FromHost carrier passthrough`

### 3. Exit Bindings Collection (meta_collector.rs:156-172)
**Added FromHost exit_bindings inclusion**:
```rust
Some((CarrierRole::LoopState, CarrierInit::FromHost)) => {
    // Include in exit_bindings for latch incoming
    // Not for exit PHI or variable_map
}
```

**Effect**: digit_value gets latch incoming for header PHI

## Test Results

- **Before**: 931 tests PASS
- **After**: 931 tests PASS (0 regressions)

## Verification

**Phase 247-EX UpdateEnv working**:
```
[update_env/phase247ex] Resolved promoted 'digit_pos' → 'digit_value' (integer carrier): ValueId(111)
```

**NumberAccumulation MIR generated**:
```
%39 = %14 Mul %38    ← result * 10
%40 = %39 Add %9     ← tmp + digit_value
```

## Status

-  Pattern2 classification
-  NumberAccumulation detection
-  dual-value carrier resolution
-  FromHost carrier handling
- ⚠️ RC:0 issue (runtime value problem, Part 2)

## Related

- Phase 247-EX: DigitPos dual-value architecture (commit 8900a3cc)
- Phase 227: ConditionOnly carrier handling
- Phase 228-8: ConditionOnly exit_bindings

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

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
nyash-codex
2025-12-11 15:28:36 +09:00
parent 8900a3cc44
commit e356524b0a
4 changed files with 104 additions and 26 deletions

View File

@ -503,10 +503,14 @@ impl MirBuilder {
//
// Phase 227: Keep ConditionOnly carriers even if they don't have updates
// (they're used in loop/break conditions, not updated)
// Phase 247-EX: Keep FromHost carriers (e.g., digit_value) even if they don't have updates
// (they're initialized from loop body and used in update expressions)
let original_carrier_count = carrier_info.carriers.len();
carrier_info.carriers.retain(|carrier| {
use crate::mir::join_ir::lowering::carrier_info::CarrierRole;
carrier_updates.contains_key(&carrier.name) || carrier.role == CarrierRole::ConditionOnly
use crate::mir::join_ir::lowering::carrier_info::{CarrierRole, CarrierInit};
carrier_updates.contains_key(&carrier.name)
|| carrier.role == CarrierRole::ConditionOnly
|| carrier.init == CarrierInit::FromHost // Phase 247-EX
});
eprintln!(