nyash-codex
024a09c15b
feat(core): Phase 122 ConsoleBox.println / log unification
## Phase 122: ConsoleBox.println / log の統一 (完了)
### 概要
ConsoleBox.printlnをlogのエイリアスとしてVM/TypeRegistryレベルで統一。
Phase 120で発見されたesc_dirname_smoke.hakoの「Unknown method 'println'」
エラーを完全解消。
### 完了タスク
- ✅ TypeRegistry修正: printlnをlogのエイリアス(slot 400)として追加
- ✅ ConsoleBox実装: printlnメソッドのラッパ追加
- ✅ VM Method Dispatch: ConsoleBox専用ハンドラ追加
- ✅ Plugin設定: nyash.tomlにprintln (method_id 2)追加
- ✅ ドキュメント更新: 3ファイル(hako_logging/logging_policy/core_boxes)
### 実装詳細
#### 1. TypeRegistry (src/runtime/type_registry.rs)
```rust
const CONSOLE_METHODS: &[MethodEntry] = &[
MethodEntry { name: "log", arity: 1, slot: 400 },
MethodEntry { name: "warn", arity: 1, slot: 401 },
MethodEntry { name: "error", arity: 1, slot: 402 },
MethodEntry { name: "clear", arity: 0, slot: 403 },
// Phase 122: println は log のエイリアス
MethodEntry { name: "println", arity: 1, slot: 400 },
];
```
#### 2. ConsoleBox (src/boxes/console_box.rs)
- WASM/非WASM両方にprintln()メソッド追加
- 内部的にlog()に委譲
#### 3. VM Method Dispatch (src/backend/mir_interpreter/handlers/calls/method.rs)
- ConsoleBox専用ハンドラ追加
- log/println/warn/error/clearをサポート
- args配列の正しい処理(len > 1時はargs[1]を使用)
#### 4. Plugin設定 (nyash.toml)
- ConsoleBox.methodsにprintln追加(method_id=2)
- method_id整合性: log=1, println=2
### テスト結果
- ✅ esc_dirname_smoke.hako実行成功
- 旧エラー: "Unknown method 'println'" ← **完全解消**
- 新出力: `[Console LOG] dir1/dir2`
### Phase 120問題解決
**Phase 120ベースラインでの課題**:
- ❌ esc_dirname_smoke.hako: ConsoleBox.println未実装
**Phase 122での解決**:
- ✅ TypeRegistryレベルでprintln→log正規化
- ✅ 全経路(JSON v0/selfhost/通常VM)で一貫性保証
### ファイル構成
**新規作成**:
- docs/development/current/main/phase122_consolebox_println_unification.md
**修正**:
- src/runtime/type_registry.rs (+5行)
- src/boxes/console_box.rs (+14行, WASM/非WASM両対応)
- src/backend/mir_interpreter/handlers/calls/method.rs (+60行)
- nyash.toml (+1メソッド定義)
- docs/development/current/main/hako_logging_design.md (+40行)
- docs/development/current/main/logging_policy.md (+30行)
- docs/development/current/main/core_boxes_design.md (+20行)
### 技術的成果
- **Alias First原則**: VM/TypeRegistryレベルで正規化
- **Phase 120連携**: ベースライン確立→問題発見→根本解決
- **全経路統一**: selfhost/JSON v0/通常VMすべてで動作
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-04 05:16:06 +09:00
..
2025-12-03 13:42:05 +09:00
2025-09-17 10:58:12 +09:00
2025-09-17 10:58:12 +09:00
2025-09-17 10:58:12 +09:00
2025-12-04 04:13:15 +09:00
2025-12-04 05:16:06 +09:00
2025-12-03 13:59:06 +09:00
2025-12-02 21:52:18 +09:00
2025-12-04 04:42:32 +09:00
2025-12-04 05:16:06 +09:00
2025-12-03 14:33:04 +09:00
2025-12-04 05:16:06 +09:00
2025-11-27 17:05:46 +09:00
2025-11-27 17:05:46 +09:00
2025-11-29 15:57:14 +09:00
2025-11-29 15:57:14 +09:00
2025-11-29 15:57:14 +09:00
2025-11-30 08:54:18 +09:00
2025-12-02 09:45:54 +09:00
2025-11-30 10:10:45 +09:00
2025-12-02 10:19:07 +09:00
2025-12-02 11:16:01 +09:00
2025-12-02 12:36:28 +09:00
2025-12-02 19:37:01 +09:00
2025-12-02 19:37:01 +09:00
2025-12-02 19:37:01 +09:00
2025-12-02 19:37:01 +09:00
2025-12-02 20:18:13 +09:00
2025-12-02 20:18:13 +09:00
2025-12-02 20:18:13 +09:00
2025-12-02 20:30:22 +09:00
2025-12-02 20:18:13 +09:00
2025-12-02 19:37:01 +09:00
2025-12-02 19:37:01 +09:00
2025-12-02 21:09:15 +09:00
2025-12-02 21:09:15 +09:00
2025-12-03 18:16:49 +09:00
2025-12-03 19:37:32 +09:00
2025-12-03 19:37:32 +09:00
2025-12-03 19:22:55 +09:00
2025-12-03 21:32:14 +09:00
2025-12-03 21:12:37 +09:00
2025-12-03 22:03:16 +09:00
2025-12-04 03:35:25 +09:00
2025-12-04 03:58:02 +09:00
2025-12-04 04:30:30 +09:00
2025-12-04 04:30:30 +09:00
2025-12-04 04:42:32 +09:00
2025-12-04 04:42:32 +09:00
2025-12-04 04:42:32 +09:00
2025-12-04 04:42:32 +09:00
2025-12-04 05:16:06 +09:00
2025-11-23 05:53:27 +09:00
2025-12-04 03:58:02 +09:00
2025-12-04 04:30:30 +09:00
2025-11-21 07:00:05 +09:00
2025-11-21 08:03:03 +09:00
2025-11-21 08:03:03 +09:00
2025-11-20 17:10:03 +09:00
2025-11-20 17:10:03 +09:00
2025-11-20 17:10:03 +09:00