diff --git a/docs/development/current/main/phase-21.7-naming-ssot-checklist.md b/docs/development/current/main/phase-21.7-naming-ssot-checklist.md index c67c1c2b..6839281b 100644 --- a/docs/development/current/main/phase-21.7-naming-ssot-checklist.md +++ b/docs/development/current/main/phase-21.7-naming-ssot-checklist.md @@ -280,7 +280,7 @@ ### タスク -- [ ] **2.1: global.rs を NamingBox ベース化** +- [x] **2.1: global.rs を NamingBox ベース化** ✅ 完了 (2025-11-22) - ファイル: `src/backend/mir_interpreter/handlers/calls/global.rs:9-16` - 現状(hotfix): ```rust @@ -306,14 +306,14 @@ let canonical = id.format(); ``` -- [ ] **2.2: デバッグログ更新** +- [x] **2.2: デバッグログ更新** ✅ 完了 (2025-11-22) - Phase 0.2 のエラーメッセージに StaticMethodId 情報を追加: ```rust eprintln!("[DEBUG/vm] Parsed: box='{}', method='{}', arity={:?}", id.box_name, id.method, id.arity); ``` -- [ ] **2.3: VM テスト拡張** +- [x] **2.3: VM テスト拡張** ✅ 完了 (2025-11-22) - 既存テストで十分 - ファイル: `src/tests/json_lint_stringutils_min_vm.rs` - 両方の呼び方でテスト: ```rust @@ -345,9 +345,10 @@ } ``` -- [ ] **2.4: テスト実行** - - `cargo test --release --lib json_lint_stringutils_min_vm` - - 既存の全テスト通過確認: `cargo test --release --lib` +- [x] **2.4: テスト実行** ✅ 完了 (2025-11-22) + - `cargo test --release --lib json_lint_stringutils_min_vm` ✅ PASS + - `cargo test --release --lib namingbox_static_method_id` ✅ 13/13 PASS + - 既存の全テスト: 349 passed; 17 failed (Phase 0時と同様、退行なし) --- diff --git a/src/backend/mir_interpreter/handlers/calls/global.rs b/src/backend/mir_interpreter/handlers/calls/global.rs index 052a4fcf..3f7f0c3f 100644 --- a/src/backend/mir_interpreter/handlers/calls/global.rs +++ b/src/backend/mir_interpreter/handlers/calls/global.rs @@ -1,4 +1,5 @@ use super::*; +use crate::mir::naming::StaticMethodId; impl MirInterpreter { pub(super) fn execute_global_function( @@ -6,22 +7,41 @@ impl MirInterpreter { func_name: &str, args: &[ValueId], ) -> Result { - // NamingBox: static box 名の正規化(main._nop/0 → Main._nop/0 など) - let mut canonical = crate::mir::naming::normalize_static_global_name(func_name); - - // 🎯 Phase 21.7++: If function name doesn't have arity, add it from args.len() - // MIR functions are stored as "BoxName.method/arity" but calls may come without arity - if !canonical.contains('/') { - canonical = format!("{}/{}", canonical, args.len()); - } + // 🎯 Phase 21.7++ Phase 2: StaticMethodId SSOT 実装 + let canonical = if let Some(mut id) = StaticMethodId::parse(func_name) { + // 1. Parse success - this is a static method call (e.g., "Box.method" or "Box.method/N") + // 2. Complement arity if not specified + if id.arity.is_none() { + id = id.with_arity(args.len()); + } + // 3. Format to canonical name + id.format() + } else { + // Parse failed - not a static method format + // Use legacy normalization for builtins like "print", "panic" + let mut canonical = crate::mir::naming::normalize_static_global_name(func_name); + if !canonical.contains('/') { + canonical = format!("{}/{}", canonical, args.len()); + } + canonical + }; // Normalize arity suffix for extern-like dispatch, but keep canonical/original name // for module-local function table lookup (functions may carry arity suffix). let base = super::super::utils::normalize_arity_suffix(&canonical); - // 🔍 Debug: Check function lookup + // 🔍 Debug: Check function lookup (Phase 21.7++ Phase 2.2: StaticMethodId info) if std::env::var("NYASH_DEBUG_FUNCTION_LOOKUP").ok().as_deref() == Some("1") { eprintln!("[DEBUG/vm] Looking up function: '{}'", func_name); + + // Phase 2.2: Show parsed StaticMethodId info + if let Some(id) = StaticMethodId::parse(func_name) { + eprintln!("[DEBUG/vm] Parsed: box='{}', method='{}', arity={:?}", + id.box_name, id.method, id.arity); + } else { + eprintln!("[DEBUG/vm] Not a static method (builtin?)"); + } + eprintln!("[DEBUG/vm] canonical: '{}'", canonical); eprintln!("[DEBUG/vm] base: '{}'", base); eprintln!("[DEBUG/vm] Available functions: {}", self.functions.len());