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:
@ -28,26 +28,34 @@ impl super::MirBuilder {
|
||||
self.current_static_box = Some(box_name.clone());
|
||||
// Look for the main() method
|
||||
let out = if let Some(main_method) = methods.get("main") {
|
||||
if let ASTNode::FunctionDeclaration { params, body, .. } = main_method {
|
||||
// Optional: materialize a callable function entry "BoxName.main/N" for harness/PyVM.
|
||||
// This static entryは通常の VM 実行では使用されず、過去の Hotfix 4 絡みの loop/control-flow
|
||||
// バグの温床になっていたため、Phase 25.1m では明示トグルが立っている場合だけ生成する。
|
||||
if std::env::var("NYASH_BUILD_STATIC_MAIN_ENTRY")
|
||||
.ok()
|
||||
.as_deref()
|
||||
== Some("1")
|
||||
{
|
||||
let func_name = format!("{}.{}", box_name, "main");
|
||||
eprintln!("[DEBUG] build_static_main_box: Before lower_static_method_as_function");
|
||||
eprintln!("[DEBUG] params.len() = {}", params.len());
|
||||
eprintln!("[DEBUG] body.len() = {}", body.len());
|
||||
eprintln!("[DEBUG] variable_map = {:?}", self.variable_map);
|
||||
// Note: Metadata clearing is now handled by BoxCompilationContext (箱理論)
|
||||
// See lifecycle.rs and builder_calls.rs for context swap implementation
|
||||
let _ = self.lower_static_method_as_function(func_name, params.clone(), body.clone());
|
||||
eprintln!("[DEBUG] build_static_main_box: After lower_static_method_as_function");
|
||||
eprintln!("[DEBUG] variable_map = {:?}", self.variable_map);
|
||||
}
|
||||
if let ASTNode::FunctionDeclaration { params, body, .. } = main_method {
|
||||
// Optional: materialize a callable function entry "BoxName.main/N" for harness/PyVM.
|
||||
// This static entryは通常の VM 実行では使用されず、過去の Hotfix 4 絡みの loop/control-flow
|
||||
// バグの温床になっていたため、Phase 25.1m では明示トグルが立っている場合だけ生成する。
|
||||
if std::env::var("NYASH_BUILD_STATIC_MAIN_ENTRY")
|
||||
.ok()
|
||||
.as_deref()
|
||||
== Some("1")
|
||||
{
|
||||
let func_name = format!("{}.{}", box_name, "main");
|
||||
eprintln!(
|
||||
"[DEBUG] build_static_main_box: Before lower_static_method_as_function"
|
||||
);
|
||||
eprintln!("[DEBUG] params.len() = {}", params.len());
|
||||
eprintln!("[DEBUG] body.len() = {}", body.len());
|
||||
eprintln!("[DEBUG] variable_map = {:?}", self.variable_map);
|
||||
// Note: Metadata clearing is now handled by BoxCompilationContext (箱理論)
|
||||
// See lifecycle.rs and builder_calls.rs for context swap implementation
|
||||
let _ = self.lower_static_method_as_function(
|
||||
func_name,
|
||||
params.clone(),
|
||||
body.clone(),
|
||||
);
|
||||
eprintln!(
|
||||
"[DEBUG] build_static_main_box: After lower_static_method_as_function"
|
||||
);
|
||||
eprintln!("[DEBUG] variable_map = {:?}", self.variable_map);
|
||||
}
|
||||
// Initialize local variables for Main.main() parameters
|
||||
// Note: These are local variables in the wrapper main() function, NOT parameters
|
||||
let saved_var_map = std::mem::take(&mut self.variable_map);
|
||||
@ -63,10 +71,8 @@ impl super::MirBuilder {
|
||||
box_type: "ArrayBox".to_string(),
|
||||
args: vec![],
|
||||
})?;
|
||||
self.value_origin_newbox
|
||||
.insert(pid, "ArrayBox".to_string());
|
||||
self
|
||||
.value_types
|
||||
self.value_origin_newbox.insert(pid, "ArrayBox".to_string());
|
||||
self.value_types
|
||||
.insert(pid, super::MirType::Box("ArrayBox".to_string()));
|
||||
// Explicitly call birth() to initialize internal state
|
||||
self.emit_instruction(MirInstruction::BoxCall {
|
||||
@ -79,7 +85,10 @@ impl super::MirBuilder {
|
||||
})?;
|
||||
if let Some(args) = script_args.as_ref() {
|
||||
for arg in args {
|
||||
let val = crate::mir::builder::emission::constant::emit_string(self, arg.clone());
|
||||
let val = crate::mir::builder::emission::constant::emit_string(
|
||||
self,
|
||||
arg.clone(),
|
||||
);
|
||||
self.emit_instruction(MirInstruction::BoxCall {
|
||||
dst: None,
|
||||
box_val: pid,
|
||||
@ -131,7 +140,10 @@ impl super::MirBuilder {
|
||||
|
||||
// Emit field metadata markers
|
||||
for field in fields {
|
||||
let _field_id = crate::mir::builder::emission::constant::emit_string(self, format!("__field_{}_{}", name, field));
|
||||
let _field_id = crate::mir::builder::emission::constant::emit_string(
|
||||
self,
|
||||
format!("__field_{}_{}", name, field),
|
||||
);
|
||||
}
|
||||
|
||||
// Record weak fields for this box
|
||||
@ -161,17 +173,21 @@ impl super::MirBuilder {
|
||||
// Emit markers for declared methods (kept as metadata hints)
|
||||
for (method_name, method_ast) in methods {
|
||||
if let ASTNode::FunctionDeclaration { .. } = method_ast {
|
||||
let _method_id = crate::mir::builder::emission::constant::emit_string(self, format!("__method_{}_{}", name, method_name));
|
||||
let _method_id = crate::mir::builder::emission::constant::emit_string(
|
||||
self,
|
||||
format!("__method_{}_{}", name, method_name),
|
||||
);
|
||||
// Track unified member getters: __get_<prop> | __get_once_<prop> | __get_birth_<prop>
|
||||
let kind_and_prop: Option<(super::PropertyKind, String)> = if let Some(rest) = method_name.strip_prefix("__get_once_") {
|
||||
Some((super::PropertyKind::Once, rest.to_string()))
|
||||
} else if let Some(rest) = method_name.strip_prefix("__get_birth_") {
|
||||
Some((super::PropertyKind::BirthOnce, rest.to_string()))
|
||||
} else if let Some(rest) = method_name.strip_prefix("__get_") {
|
||||
Some((super::PropertyKind::Computed, rest.to_string()))
|
||||
} else {
|
||||
None
|
||||
};
|
||||
let kind_and_prop: Option<(super::PropertyKind, String)> =
|
||||
if let Some(rest) = method_name.strip_prefix("__get_once_") {
|
||||
Some((super::PropertyKind::Once, rest.to_string()))
|
||||
} else if let Some(rest) = method_name.strip_prefix("__get_birth_") {
|
||||
Some((super::PropertyKind::BirthOnce, rest.to_string()))
|
||||
} else if let Some(rest) = method_name.strip_prefix("__get_") {
|
||||
Some((super::PropertyKind::Computed, rest.to_string()))
|
||||
} else {
|
||||
None
|
||||
};
|
||||
if let Some((k, prop)) = kind_and_prop {
|
||||
use std::collections::HashMap;
|
||||
let entry: &mut HashMap<String, super::PropertyKind> = self
|
||||
|
||||
Reference in New Issue
Block a user