feat(joinir): Phase 213-2 Step 2-2 & 2-3 Data structure extensions

Extended PatternPipelineContext and CarrierUpdateInfo for Pattern 3 AST-based generalization.

Changes:
1. PatternPipelineContext:
   - Added loop_condition: Option<ASTNode>
   - Added loop_body: Option<Vec<ASTNode>>
   - Added loop_update_summary: Option<LoopUpdateSummary>
   - Updated build_pattern_context() for Pattern 3

2. CarrierUpdateInfo:
   - Added then_expr: Option<ASTNode>
   - Added else_expr: Option<ASTNode>
   - Updated analyze_loop_updates() with None defaults

Status: Phase 213-2 Steps 2-2 & 2-3 complete
Next: Create Pattern3IfAnalyzer to extract if statement and populate update summary
This commit is contained in:
nyash-codex
2025-12-10 00:01:53 +09:00
parent 577b5b01d5
commit d7805e5974
138 changed files with 3529 additions and 378 deletions

View File

@ -135,7 +135,8 @@ impl CapturedEnv {
/// # Returns
///
/// `CapturedEnv` containing all captured variables
pub fn analyze_captured_vars(
#[allow(dead_code)]
pub(crate) fn analyze_captured_vars(
fn_body: &[ASTNode],
loop_ast: &ASTNode,
scope: &LoopScopeShape,
@ -264,7 +265,8 @@ pub fn analyze_captured_vars(
/// # Returns
///
/// `CapturedEnv` containing all captured variables
pub fn analyze_captured_vars_v2(
#[allow(dead_code)]
pub(crate) fn analyze_captured_vars_v2(
fn_body: &[ASTNode],
loop_condition: &ASTNode,
loop_body: &[ASTNode],
@ -379,6 +381,7 @@ pub fn analyze_captured_vars_v2(
/// Find the index of a loop statement in the function body
///
/// Returns Some(index) if found, None otherwise.
#[allow(dead_code)]
fn find_stmt_index(fn_body: &[ASTNode], loop_ast: &ASTNode) -> Option<usize> {
// Compare by pointer address (same AST node instance)
fn_body.iter().position(|stmt| {
@ -545,6 +548,7 @@ fn is_reassigned_in_fn(fn_body: &[ASTNode], name: &str) -> bool {
/// Check if variable is referenced in loop condition or body
///
/// Returns true if the variable name appears anywhere in the loop AST.
#[allow(dead_code)]
fn is_used_in_loop(loop_ast: &ASTNode, name: &str) -> bool {
fn check_usage(node: &ASTNode, name: &str) -> bool {
match node {

View File

@ -27,6 +27,7 @@ use crate::mir::loop_pattern_detection::loop_condition_scope::LoopConditionScope
/// 昇格リクエスト
pub struct PromotionRequest<'a> {
/// ループのスコープ情報
#[allow(dead_code)]
pub(crate) scope: &'a LoopScopeShape,
/// 条件変数のスコープ分類
pub cond_scope: &'a LoopConditionScope,