BID-FFI integration:\n- Add plugin-tester io subcommand and TLV helpers; E2E open/write/read/close\n- Implement FileBox plugin invoke (birth/open/read/write/close) with BID-1 two-pass\n- Add BID loader/registry/plugin_box modules; prefer plugin-backed FileBox in interpreter\n- Introduce PluginFileBox with minimal read/write/close dispatch\n- Update runner debug paths; add local simple tests\n- Docs: plugin-tester guide and FileBox Nyash↔BID mapping; CURRENT_TASK updated

This commit is contained in:
Moe Charm
2025-08-18 11:07:03 +09:00
parent ea40437d4d
commit 0441608db3
21 changed files with 1209 additions and 123 deletions

View File

@ -95,15 +95,26 @@ impl NyashInterpreter {
});
}
let path_value = self.execute_expression(&arguments[0])?;
if let Some(path_str) = path_value.as_any().downcast_ref::<StringBox>() {
let file_box = Box::new(FileBox::new(&path_str.value)) as Box<dyn NyashBox>;
// 🌍 革命的実装Environment tracking廃止
return Ok(file_box);
let path_str = if let Some(s) = path_value.as_any().downcast_ref::<StringBox>() {
s.value.clone()
} else {
return Err(RuntimeError::TypeError {
message: "FileBox constructor requires string path argument".to_string(),
});
return Err(RuntimeError::TypeError { message: "FileBox constructor requires string path argument".to_string() });
};
// プラグイン優先nyash.tomlに設定がある場合
if let Some(reg) = crate::bid::registry::global() {
if let Some(plugin) = reg.get_by_name("FileBox") {
if let Ok(p) = crate::bid::plugin_box::PluginFileBox::new(plugin, path_str.clone()) {
return Ok(Box::new(p) as Box<dyn NyashBox>);
}
}
}
// フォールバック: ビルトインFileBox
return match crate::boxes::file::FileBox::open(&path_str) {
Ok(fb) => Ok(Box::new(fb) as Box<dyn NyashBox>),
Err(e) => Err(RuntimeError::InvalidOperation { message: format!("Failed to open file '{}': {}", path_str, e) }),
};
}
"ResultBox" => {
// ResultBoxは引数1個成功値で作成
@ -1102,4 +1113,4 @@ impl NyashInterpreter {
// 現在はシンプルにコピー
fields.to_vec()
}
}
}