refactor: 大規模ファイル分割とプラグインリファクタリング

## 🎯 プラグイン整理
-  **nyash-json-plugin**: プロバイダー抽象化、NodeRep統一
-  **nyash-string-plugin**: TLVヘルパー整理
-  **nyash-net-plugin**: HTTPヘルパー分離、ソケット管理改善
-  **nyash-counter-plugin/fixture-plugin**: 基本構造整理

## 📂 mir_interpreter分割
-  **mir_interpreter.rs → mir_interpreter/ディレクトリ**
  - mod.rs: メイン構造体定義
  - execution.rs: 実行エンジン
  - memory.rs: メモリ管理
  - instructions/: 命令別実装

## 🔧 その他の改善
- テストファイル群の最適化
- LLVMコンパイラのメイン関数整理
- 不要なインポート削除

1000行超のファイルを適切なモジュール構造に分割完了!

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

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Selfhosting Dev
2025-09-25 01:09:48 +09:00
parent d052f9dc97
commit 824ca600ea
27 changed files with 1605 additions and 1060 deletions

View File

@ -0,0 +1,100 @@
use super::*;
impl MirInterpreter {
pub(super) fn handle_extern_call(
&mut self,
dst: Option<ValueId>,
iface: &str,
method: &str,
args: &[ValueId],
) -> Result<(), VMError> {
match (iface, method) {
("env.console", "log") => {
if let Some(a0) = args.get(0) {
let v = self.reg_load(*a0)?;
println!("{}", v.to_string());
}
if let Some(d) = dst {
self.regs.insert(d, VMValue::Void);
}
Ok(())
}
("env.future", "new") => {
let fut = crate::boxes::future::NyashFutureBox::new();
if let Some(a0) = args.get(0) {
let v = self.reg_load(*a0)?;
fut.set_result(v.to_nyash_box());
}
if let Some(d) = dst {
self.regs.insert(d, VMValue::Future(fut));
}
Ok(())
}
("env.future", "set") => {
if args.len() >= 2 {
let f = self.reg_load(args[0])?;
let v = self.reg_load(args[1])?;
if let VMValue::Future(fut) = f {
fut.set_result(v.to_nyash_box());
} else {
return Err(VMError::TypeError("env.future.set expects Future".into()));
}
}
if let Some(d) = dst {
self.regs.insert(d, VMValue::Void);
}
Ok(())
}
("env.future", "await") => {
if let Some(a0) = args.get(0) {
let f = self.reg_load(*a0)?;
match f {
VMValue::Future(fut) => {
let v = fut.get();
if let Some(d) = dst {
self.regs.insert(d, VMValue::from_nyash_box(v));
}
}
_ => {
return Err(VMError::TypeError("await expects Future".into()));
}
}
}
Ok(())
}
("env.runtime", "checkpoint") => {
crate::runtime::global_hooks::safepoint_and_poll();
if let Some(d) = dst {
self.regs.insert(d, VMValue::Void);
}
Ok(())
}
("env.modules", "set") => {
if args.len() >= 2 {
let k = self.reg_load(args[0])?.to_string();
let v = self.reg_load(args[1])?.to_nyash_box();
crate::runtime::modules_registry::set(k, v);
}
if let Some(d) = dst {
self.regs.insert(d, VMValue::Void);
}
Ok(())
}
("env.modules", "get") => {
if let Some(a0) = args.get(0) {
let k = self.reg_load(*a0)?.to_string();
let vb = crate::runtime::modules_registry::get(&k)
.unwrap_or_else(|| Box::new(crate::box_trait::VoidBox::new()));
if let Some(d) = dst {
self.regs.insert(d, VMValue::from_nyash_box(vb));
}
}
Ok(())
}
_ => Err(VMError::InvalidInstruction(format!(
"ExternCall {}.{} not supported",
iface, method
))),
}
}
}