feat(joinir): Phase 79 Activation - BindingId wiring operational (dev-only)
Phase 79 の最終段階:BindingId を ExprLowerer に配線し、end-to-end で動作確認。 Key changes: - ExprLowerer wiring: - scope_resolution.rs: build_condition_env_from_scope_with_binding() (BindingId-aware) - expr_lowerer.rs: lower_condition() uses BindingId priority lookup - ConditionEnv extension: - register_loop_var_binding(): Loop var BindingId→ValueId registration - register_condition_binding(): Condition-only carrier BindingId→ValueId registration - Pattern2 integration: - pattern2_with_break.rs: Loop var registration (Line 116-128) - pattern2_with_break.rs: Carrier role-based registration (Line 381-425) - Debug logging: [phase79] tags for registration, [binding_pilot/hit] for lookup success - E2E tests (normalized_joinir_min.rs, debug-only): - test_phase79_digitpos_bindingid_lookup_works(): DigitPos pattern verification - test_phase79_trim_bindingid_lookup_works(): Trim pattern verification Result: BindingId lookup actually works end-to-end - Promoted carriers resolve via BindingId, not string hacks - Debug: NYASH_JOINIR_DEBUG=1 shows [phase79] Registered loop var BindingId, [binding_pilot/hit] BindingId(1) -> ValueId(100) Tests: 1025/1025 lib PASS Design: dev-only feature-gated, dual-path maintained (BindingId priority + name fallback) Phase 74-79 complete: BindingId migration fully operational - Infrastructure (74-76): BindingId type, binding_map, 3-tier lookup, promoted_bindings map - Implementation (77): DigitPos/Trim populate, legacy deprecate - Refactoring (78-79 Refactoring): PromotedBindingRecorder, Detector/Recorder split - Activation (80 Foundation + 79 Activation): CarrierBindingAssigner + ExprLowerer wiring
This commit is contained in:
@ -75,6 +75,11 @@ impl ConditionEnvBuilder {
|
||||
let loop_var_join_id = space.alloc_param();
|
||||
env.insert(loop_var_name.to_string(), loop_var_join_id);
|
||||
|
||||
// Phase 79-2: Register loop variable BindingId (dev-only)
|
||||
// NOTE: We don't have access to builder.binding_map here, so this registration
|
||||
// needs to happen at the call site (in pattern2_with_break.rs, pattern3_with_if_phi.rs, etc.)
|
||||
// This comment serves as a reminder for future developers.
|
||||
|
||||
// For each condition variable, allocate JoinIR-local ValueId and build binding
|
||||
for var_name in &condition_var_names {
|
||||
let host_id = variable_map.get(var_name).copied().ok_or_else(|| {
|
||||
|
||||
@ -104,7 +104,7 @@ fn prepare_pattern2_inputs(
|
||||
|
||||
// Value space + condition env
|
||||
let mut join_value_space = JoinValueSpace::new();
|
||||
let (mut env, mut condition_bindings, _loop_var_join_id) =
|
||||
let (mut env, mut condition_bindings, loop_var_join_id) =
|
||||
ConditionEnvBuilder::build_for_break_condition_v2(
|
||||
condition,
|
||||
&loop_var_name,
|
||||
@ -113,6 +113,20 @@ fn prepare_pattern2_inputs(
|
||||
&mut join_value_space,
|
||||
)?;
|
||||
|
||||
// Phase 79-2: Register loop variable BindingId (dev-only)
|
||||
#[cfg(feature = "normalized_dev")]
|
||||
if let Some(loop_var_bid) = builder.binding_map.get(&loop_var_name).copied() {
|
||||
env.register_loop_var_binding(loop_var_bid, loop_var_join_id);
|
||||
log_pattern2(
|
||||
verbose,
|
||||
"phase79",
|
||||
format!(
|
||||
"Registered loop var BindingId: '{}' BindingId({}) → ValueId({})",
|
||||
loop_var_name, loop_var_bid.0, loop_var_join_id.0
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
log_pattern2(
|
||||
verbose,
|
||||
"phase201",
|
||||
@ -369,9 +383,36 @@ fn promote_and_prepare_carriers(
|
||||
carrier.join_id = Some(carrier_join_id);
|
||||
#[cfg(feature = "normalized_dev")]
|
||||
if let Some(binding_id) = carrier.binding_id {
|
||||
inputs
|
||||
.env
|
||||
.register_carrier_binding(binding_id, carrier_join_id);
|
||||
// Phase 79-2: Use role-specific registration method
|
||||
use crate::mir::join_ir::lowering::carrier_info::CarrierRole;
|
||||
match carrier.role {
|
||||
CarrierRole::ConditionOnly => {
|
||||
inputs
|
||||
.env
|
||||
.register_condition_binding(binding_id, carrier_join_id);
|
||||
log_pattern2(
|
||||
verbose,
|
||||
"phase79",
|
||||
format!(
|
||||
"Registered condition-only carrier '{}' BindingId({}) → ValueId({})",
|
||||
carrier.name, binding_id.0, carrier_join_id.0
|
||||
),
|
||||
);
|
||||
}
|
||||
CarrierRole::LoopState => {
|
||||
inputs
|
||||
.env
|
||||
.register_carrier_binding(binding_id, carrier_join_id);
|
||||
log_pattern2(
|
||||
verbose,
|
||||
"phase79",
|
||||
format!(
|
||||
"Registered loop-state carrier '{}' BindingId({}) → ValueId({})",
|
||||
carrier.name, binding_id.0, carrier_join_id.0
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
log_pattern2(
|
||||
verbose,
|
||||
|
||||
Reference in New Issue
Block a user