From ea4c164daed33ff71fb061c0d47d6d477bceb7fd Mon Sep 17 00:00:00 2001 From: nyash-codex Date: Wed, 3 Dec 2025 14:25:28 +0900 Subject: [PATCH] =?UTF-8?q?refactor(runner):=20Phase=20105.5=20Console?= =?UTF-8?q?=E5=87=BA=E5=8A=9B=E3=81=AEmacro=E7=B5=B1=E4=B8=80=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Replace direct console.println() calls with console_println! macro - Simplify error handling in vm.rs (RC output) - Simplify success logging in selfhost.rs (PluginHost init) - Remove redundant nested if-let structures for Option handling - Macro already handles all fallback scenarios (eprintln!) This reduces code duplication and improves consistency. The macro centralizes the fallback logic, making it easier to maintain. Files modified: - src/runner/modes/vm.rs (simplified RC output) - src/runner/selfhost.rs (simplified PluginHost init message) Line reduction: ~13 lines (nested if-let structures removed) --- src/runner/modes/vm.rs | 13 ++----------- src/runner/selfhost.rs | 10 +++------- 2 files changed, 5 insertions(+), 18 deletions(-) diff --git a/src/runner/modes/vm.rs b/src/runner/modes/vm.rs index 84f6e27c..656f4f3a 100644 --- a/src/runner/modes/vm.rs +++ b/src/runner/modes/vm.rs @@ -586,17 +586,8 @@ impl NyashRunner { // Quiet mode: suppress "RC:" output for JSON-only pipelines if !quiet_pipe { - // Phase 98: ConsoleService if available, otherwise eprintln - // Phase 103: Handle Option> - if let Some(host) = crate::runtime::try_get_core_plugin_host() { - if let Some(ref console) = host.core.console { - console.println(&format!("RC: {}", exit_code)); - } else { - println!("RC: {}", exit_code); - } - } else { - println!("RC: {}", exit_code); - } + // Phase 105.5: Unified console output via macro + crate::console_println!("RC: {}", exit_code); } if std::env::var("NYASH_EMIT_MIR_TRACE") .ok() diff --git a/src/runner/selfhost.rs b/src/runner/selfhost.rs index 392afd89..a5b08684 100644 --- a/src/runner/selfhost.rs +++ b/src/runner/selfhost.rs @@ -48,15 +48,11 @@ impl NyashRunner { let ring0 = crate::runtime::ring0::get_global_ring0(); match crate::runtime::initialize_runtime(ring0) { Ok(()) => { - // Phase 95: ConsoleService 経由でログ出力(代表パス) - // Phase 103: Handle Option> - let host = crate::runtime::get_core_plugin_host(); - if let Some(ref console) = host.core.console { - console.println("[selfhost] PluginHost initialized successfully"); - } + // Phase 105.5: Unified console output via macro + crate::console_println!("[selfhost] PluginHost initialized successfully"); } Err(e) => { - // Phase 100: ConsoleService 経由でエラー出力 + // Phase 105.5: Unified console output via macro crate::console_println!("[selfhost] CoreInitError: {}", e); return false; }