Files
hakorune/apps/tests/phase246ex_atoi_mini.hako

36 lines
847 B
Plaintext
Raw Normal View History

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>
2025-12-11 15:28:36 +09:00
// Phase 246-EX: Minimal _atoi test
// Tests NumberAccumulation pattern: result = result * 10 + digit_pos
// Prints "result = N" to stdout, returns 0 on success (42), 1 on failure.
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>
2025-12-11 15:28:36 +09:00
static box Phase246ExAtoiMini {
main() {
local s = "42"
local len = 2
local result = me.atoi(s, len)
// Expected: 42
print("result = " + result)
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>
2025-12-11 15:28:36 +09:00
if result == 42 {
return 0
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>
2025-12-11 15:28:36 +09:00
} else {
return 1
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>
2025-12-11 15:28:36 +09:00
}
}
method atoi(s, len) {
local result = 0
local digits = "0123456789"
local i = 0
loop(i < len) {
local ch = s.substring(i, i + 1)
local digit_pos = digits.indexOf(ch)
if digit_pos < 0 { break }
result = result * 10 + digit_pos
i = i + 1
}
return result
}
}