feat: WASMビルド完全対応+finiシステム修正 🎉

## WASMビルド対応
- TimerBox、AudioBox等の問題のあるBoxをWASM環境では条件付きコンパイルで除外
- WebBox (WebDisplayBox, WebConsoleBox, WebCanvasBox) にas_anyメソッド追加
- プラグイン関連コードに#[cfg]ガードを追加
- web-sysフィーチャーを追加(Performance、MouseEvent等)
- projects/nyash-wasmのビルドが完全に通るように!

## finiシステム修正
- フィールド差し替え時の自動fini削除(Nyashの明示的哲学に従う)
- スコープ離脱時のみfini実行(meは除外)
- ドキュメント更新で正しいfiniルールを明記

## その他
- CLAUDE.mdにWASMビルド方法を追記(wasm-pack build --target web)
- 開発サーバー起動方法を記載(python3 -m http.server 8010)
- cargo testで全テスト成功を確認

これでNyashがブラウザで動作可能に!🐱

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Moe Charm
2025-08-20 07:33:18 +09:00
parent 83d3914e46
commit 670615d1de
18 changed files with 209 additions and 78 deletions

View File

@ -223,6 +223,40 @@ cargo build --release -j32 --features wasm-backend
## 🎯 今後の優先事項copilot_issues.txt参照
### 🌐 **WASMブラウザー版ビルド修正**
- **問題**: projects/nyash-wasmのビルドが失敗28個のコンパイルエラー
- **原因と解決策3ステップ**:
#### **Step 1: プラグイン関連の条件コンパイル修正**
- **問題箇所**:
- `src/interpreter/expressions/calls.rs`: `use PluginBoxV2` が無条件
- `src/bid/loader.rs`: `use libloading` が無条件
- **修正内容**:
```rust
#[cfg(all(feature = "plugins", not(target_arch = "wasm32")))]
use crate::runtime::plugin_loader_v2::PluginBoxV2;
```
#### **Step 2: web-sysフィーチャー追加**
- **不足フィーチャー**:
- Performance
- MouseEvent, TouchEvent, KeyboardEvent
- AudioContext, AudioBuffer, GainNode 等
- **修正内容**: Cargo.tomlの`[dependencies.web-sys]`に追加
#### **Step 3: wasm-pack buildコマンド修正**
- **現在**: デフォルトフィーチャーplugins含むでビルド
- **修正**: `wasm-pack build --target web --no-default-features --out-dir projects/nyash-wasm/pkg`
- **または**: WASM専用フィーチャー作成
- **最終確認**: `wasm-pack build`成功 → `nyash_playground.html`で動作確認
### 🚨 **緊急修正: finiシステムの統一**
- **問題**: ビルトインBoxにfiniメソッドがない設計の不統一
- **解決**: 全Box型ビルトイン含むにfiniメソッド追加
- **理由**: スコープ離脱時の統一的リソース管理
- **影響**: StringBox、IntegerBox等16種類のビルトインBox
### Phase 8.4: AST→MIR Lowering完全実装
- MIR命令セット設計済み35命令
- Lowering実装開始準備