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:
@ -1,6 +1,8 @@
|
||||
// Expression lowering split from builder.rs to keep files lean
|
||||
use super::{MirInstruction, ValueId};
|
||||
use crate::ast::{ASTNode, AssignStmt, ReturnStmt, BinaryExpr, CallExpr, MethodCallExpr, FieldAccessExpr};
|
||||
use crate::ast::{
|
||||
ASTNode, AssignStmt, BinaryExpr, CallExpr, FieldAccessExpr, MethodCallExpr, ReturnStmt,
|
||||
};
|
||||
|
||||
impl super::MirBuilder {
|
||||
// Main expression dispatcher
|
||||
@ -16,9 +18,7 @@ impl super::MirBuilder {
|
||||
// Sequentially lower statements and return last value (or Void)
|
||||
self.cf_block(statements)
|
||||
}
|
||||
ASTNode::Print { expression, .. } => {
|
||||
self.build_print_statement(*expression)
|
||||
}
|
||||
ASTNode::Print { expression, .. } => self.build_print_statement(*expression),
|
||||
ASTNode::If {
|
||||
condition,
|
||||
then_body,
|
||||
@ -36,13 +36,17 @@ impl super::MirBuilder {
|
||||
});
|
||||
self.cf_if(*condition, then_node, else_node)
|
||||
}
|
||||
ASTNode::Loop { condition, body, .. } => {
|
||||
ASTNode::Loop {
|
||||
condition, body, ..
|
||||
} => {
|
||||
if std::env::var("NYASH_LOOPFORM_DEBUG").is_ok() {
|
||||
eprintln!("[exprs.rs:35] FIRST Loop pattern matched");
|
||||
}
|
||||
self.cf_loop(*condition, body)
|
||||
}
|
||||
ASTNode::While { condition, body, .. } => {
|
||||
ASTNode::While {
|
||||
condition, body, ..
|
||||
} => {
|
||||
// Desugar Stage-3 while into legacy loop(condition) { body }
|
||||
self.cf_loop(*condition, body)
|
||||
}
|
||||
@ -85,8 +89,17 @@ impl super::MirBuilder {
|
||||
let obj_val = self.build_expression_impl(*m.object.clone())?;
|
||||
let ty = Self::parse_type_name_to_mir(&type_name);
|
||||
let dst = self.next_value_id();
|
||||
let op = if m.method == "is" { crate::mir::TypeOpKind::Check } else { crate::mir::TypeOpKind::Cast };
|
||||
self.emit_instruction(MirInstruction::TypeOp { dst, op, value: obj_val, ty })?;
|
||||
let op = if m.method == "is" {
|
||||
crate::mir::TypeOpKind::Check
|
||||
} else {
|
||||
crate::mir::TypeOpKind::Cast
|
||||
};
|
||||
self.emit_instruction(MirInstruction::TypeOp {
|
||||
dst,
|
||||
op,
|
||||
value: obj_val,
|
||||
ty,
|
||||
})?;
|
||||
return Ok(dst);
|
||||
}
|
||||
}
|
||||
@ -106,7 +119,11 @@ impl super::MirBuilder {
|
||||
if let ASTNode::FieldAccess { object, field, .. } = stmt.target.as_ref() {
|
||||
self.build_field_assignment(*object.clone(), field.clone(), *stmt.value.clone())
|
||||
} else if let ASTNode::Index { target, index, .. } = stmt.target.as_ref() {
|
||||
self.build_index_assignment(*target.clone(), *index.clone(), *stmt.value.clone())
|
||||
self.build_index_assignment(
|
||||
*target.clone(),
|
||||
*index.clone(),
|
||||
*stmt.value.clone(),
|
||||
)
|
||||
} else if let ASTNode::Variable { name, .. } = stmt.target.as_ref() {
|
||||
self.build_assignment(name.clone(), *stmt.value.clone())
|
||||
} else {
|
||||
@ -280,8 +297,7 @@ impl super::MirBuilder {
|
||||
})?;
|
||||
self.value_origin_newbox
|
||||
.insert(arr_id, "ArrayBox".to_string());
|
||||
self
|
||||
.value_types
|
||||
self.value_types
|
||||
.insert(arr_id, super::MirType::Box("ArrayBox".to_string()));
|
||||
for e in elements {
|
||||
let v = self.build_expression_impl(e)?;
|
||||
@ -312,11 +328,9 @@ impl super::MirBuilder {
|
||||
args: vec![],
|
||||
effects: super::EffectMask::MUT,
|
||||
})?;
|
||||
self
|
||||
.value_origin_newbox
|
||||
self.value_origin_newbox
|
||||
.insert(map_id, "MapBox".to_string());
|
||||
self
|
||||
.value_types
|
||||
self.value_types
|
||||
.insert(map_id, super::MirType::Box("MapBox".to_string()));
|
||||
for (k, expr) in entries {
|
||||
// const string key
|
||||
|
||||
Reference in New Issue
Block a user