chore: Phase 25.1 完了 - LoopForm v2/Stage1 CLI/環境変数削減 + Phase 26-D からの変更

Phase 25.1 完了成果:
-  LoopForm v2 テスト・ドキュメント・コメント完備
  - 4ケース(A/B/C/D)完全テストカバレッジ
  - 最小再現ケース作成(SSAバグ調査用)
  - SSOT文書作成(loopform_ssot.md)
  - 全ソースに [LoopForm] コメントタグ追加

-  Stage-1 CLI デバッグ環境構築
  - stage1_cli.hako 実装
  - stage1_bridge.rs ブリッジ実装
  - デバッグツール作成(stage1_debug.sh/stage1_minimal.sh)
  - アーキテクチャ改善提案文書

-  環境変数削減計画策定
  - 25変数の完全調査・分類
  - 6段階削減ロードマップ(25→5、80%削減)
  - 即時削除可能変数特定(NYASH_CONFIG/NYASH_DEBUG)

Phase 26-D からの累積変更:
- PHI実装改善(ExitPhiBuilder/HeaderPhiBuilder等)
- MIRビルダーリファクタリング
- 型伝播・最適化パス改善
- その他約300ファイルの累積変更

🎯 技術的成果:
- SSAバグ根本原因特定(条件分岐内loop変数変更)
- Region+next_iパターン適用完了(UsingCollectorBox等)
- LoopFormパターン文書化・テスト化完了
- セルフホスティング基盤強化

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: ChatGPT <noreply@openai.com>
Co-Authored-By: Task Assistant <task@anthropic.com>
This commit is contained in:
nyash-codex
2025-11-21 06:25:17 +09:00
parent baf028a94f
commit f9d100ce01
366 changed files with 14322 additions and 5236 deletions

View File

@ -43,13 +43,7 @@ pub fn format_instruction(
}
MirInstruction::Compare { dst, op, lhs, rhs } => {
format!(
"{} icmp {:?} {}, {}",
format_dst(dst, types),
op,
lhs,
rhs
)
format!("{} icmp {:?} {}, {}", format_dst(dst, types), op, lhs, rhs)
}
MirInstruction::Load { dst, ptr } => {
@ -79,7 +73,13 @@ pub fn format_instruction(
super::Callee::Global(name) => {
format!("call_global {}({})", name, args_str)
}
super::Callee::Method { box_name, method, receiver, certainty, .. } => {
super::Callee::Method {
box_name,
method,
receiver,
certainty,
..
} => {
if let Some(recv) = receiver {
format!(
"call_method {}.{}({}) [recv: {}] [{}]",
@ -87,7 +87,12 @@ pub fn format_instruction(
method,
args_str,
recv,
match certainty { crate::mir::definitions::call_unified::TypeCertainty::Known => "Known", crate::mir::definitions::call_unified::TypeCertainty::Union => "Union" }
match certainty {
crate::mir::definitions::call_unified::TypeCertainty::Known =>
"Known",
crate::mir::definitions::call_unified::TypeCertainty::Union =>
"Union",
}
)
} else {
format!(
@ -95,22 +100,34 @@ pub fn format_instruction(
box_name,
method,
args_str,
match certainty { crate::mir::definitions::call_unified::TypeCertainty::Known => "Known", crate::mir::definitions::call_unified::TypeCertainty::Union => "Union" }
match certainty {
crate::mir::definitions::call_unified::TypeCertainty::Known =>
"Known",
crate::mir::definitions::call_unified::TypeCertainty::Union =>
"Union",
}
)
}
}
super::Callee::Constructor { box_type } => {
format!("call_constructor {}({})", box_type, args_str)
}
super::Callee::Closure { params, captures, me_capture } => {
super::Callee::Closure {
params,
captures,
me_capture,
} => {
let params_str = params.join(", ");
let captures_str = captures.iter()
let captures_str = captures
.iter()
.map(|(name, val)| format!("{}={}", name, val))
.collect::<Vec<_>>()
.join(", ");
let me_str = me_capture.map_or(String::new(), |v| format!(" [me={}]", v));
format!("call_closure ({}) [captures: {}]{}",
params_str, captures_str, me_str)
format!(
"call_closure ({}) [captures: {}]{}",
params_str, captures_str, me_str
)
}
super::Callee::Value(func_val) => {
format!("call_value {}({})", func_val, args_str)
@ -144,7 +161,11 @@ pub fn format_instruction(
.collect::<Vec<_>>()
.join(", ");
let me_s = me.map(|m| format!(" me={}", m)).unwrap_or_default();
let cap_s = if c.is_empty() { String::new() } else { format!(" [{}]", c) };
let cap_s = if c.is_empty() {
String::new()
} else {
format!(" [{}]", c)
};
format!(
"{} new_closure ({}) {{...{}}}{}{}",
format_dst(dst, types),
@ -236,22 +257,25 @@ pub fn format_instruction(
format!("{} phi {}", format_dst(dst, types), inputs_str)
}
MirInstruction::NewBox { dst, box_type, args } => {
MirInstruction::NewBox {
dst,
box_type,
args,
} => {
let args_str = args
.iter()
.map(|v| format!("{}", v))
.collect::<Vec<_>>()
.join(", ");
format!(
"{} new {}({})",
format_dst(dst, types),
box_type,
args_str
)
format!("{} new {}({})", format_dst(dst, types), box_type, args_str)
}
// Legacy -> Unified print: TypeCheck as TypeOp(check)
MirInstruction::TypeCheck { dst, value, expected_type } => {
MirInstruction::TypeCheck {
dst,
value,
expected_type,
} => {
format!(
"{} typeop check {} {}",
format_dst(dst, types),
@ -269,7 +293,11 @@ pub fn format_instruction(
s
}
MirInstruction::Cast { dst, value, target_type } => {
MirInstruction::Cast {
dst,
value,
target_type,
} => {
format!(
"{} cast {} to {:?}",
format_dst(dst, types),
@ -296,7 +324,11 @@ pub fn format_instruction(
format!("{} {}[{}]", format_dst(dst, types), array, index)
}
MirInstruction::ArraySet { array, index, value } => {
MirInstruction::ArraySet {
array,
index,
value,
} => {
format!("{}[{}] = {}", array, index, value)
}
@ -315,11 +347,18 @@ pub fn format_instruction(
MirInstruction::Nop => "nop".to_string(),
// Phase 5: Control flow & exception handling
MirInstruction::Throw { exception, effects: _ } => {
MirInstruction::Throw {
exception,
effects: _,
} => {
format!("throw {}", exception)
}
MirInstruction::Catch { exception_type, exception_value, handler_bb } => {
MirInstruction::Catch {
exception_type,
exception_value,
handler_bb,
} => {
if let Some(ref exc_type) = exception_type {
format!("catch {} {} -> {}", exc_type, exception_value, handler_bb)
} else {
@ -334,16 +373,19 @@ pub fn format_instruction(
format!("{} ref_new {}", format_dst(dst, types), box_val)
}
MirInstruction::RefGet { dst, reference, field } => {
format!(
"{} ref_get {}.{}",
format_dst(dst, types),
reference,
field
)
MirInstruction::RefGet {
dst,
reference,
field,
} => {
format!("{} ref_get {}.{}", format_dst(dst, types), reference, field)
}
MirInstruction::RefSet { reference, field, value } => {
MirInstruction::RefSet {
reference,
field,
value,
} => {
format!("ref_set {}.{} = {}", reference, field, value)
}
@ -367,12 +409,7 @@ pub fn format_instruction(
super::WeakRefOp::New => "new",
super::WeakRefOp::Load => "load",
};
format!(
"{} weakref {} {}",
format_dst(dst, types),
op_str,
value
)
format!("{} weakref {} {}", format_dst(dst, types), op_str, value)
}
MirInstruction::Barrier { op, ptr } => {
@ -397,7 +434,13 @@ pub fn format_instruction(
}
// Phase 9.7: External Function Calls
MirInstruction::ExternCall { dst, iface_name, method_name, args, effects } => {
MirInstruction::ExternCall {
dst,
iface_name,
method_name,
args,
effects,
} => {
let args_str = args
.iter()
.map(|v| format!("{}", v))