Phase 12: extern registry + diagnostics, JIT host-bridge PoC by-slot, vtable Map.set + VT/PIC tracing, and tests

This commit is contained in:
Moe Charm
2025-09-03 05:56:57 +09:00
parent 0722b410a1
commit 294b45b9f4
8 changed files with 234 additions and 4 deletions

View File

@ -0,0 +1,37 @@
//! Extern interface registry (env.*) for diagnostics and optional slotting
//!
//! 目的: ExternCallの未登録/未対応時に候補提示やSTRICT診断を改善する。
use once_cell::sync::Lazy;
#[derive(Clone, Copy, Debug)]
pub struct ExternSpec { pub iface: &'static str, pub method: &'static str, pub min_arity: u8, pub max_arity: u8 }
static EXTERNS: Lazy<Vec<ExternSpec>> = Lazy::new(|| vec![
// console
ExternSpec { iface: "env.console", method: "log", min_arity: 1, max_arity: 1 },
// debug
ExternSpec { iface: "env.debug", method: "trace", min_arity: 1, max_arity: 255 },
// runtime
ExternSpec { iface: "env.runtime", method: "checkpoint", min_arity: 0, max_arity: 0 },
// future (scaffold)
ExternSpec { iface: "env.future", method: "new", min_arity: 1, max_arity: 1 },
ExternSpec { iface: "env.future", method: "birth", min_arity: 1, max_arity: 1 },
ExternSpec { iface: "env.future", method: "set", min_arity: 2, max_arity: 2 },
ExternSpec { iface: "env.future", method: "await", min_arity: 1, max_arity: 1 },
]);
pub fn resolve(iface: &str, method: &str) -> Option<ExternSpec> {
EXTERNS.iter().copied().find(|e| e.iface == iface && e.method == method)
}
pub fn known_for_iface(iface: &str) -> Vec<&'static str> {
let mut v: Vec<&'static str> = EXTERNS.iter().filter(|e| e.iface == iface).map(|e| e.method).collect();
v.sort(); v.dedup(); v
}
pub fn all_ifaces() -> Vec<&'static str> {
let mut v: Vec<&'static str> = EXTERNS.iter().map(|e| e.iface).collect();
v.sort(); v.dedup(); v
}

View File

@ -21,6 +21,7 @@ pub mod type_box_abi; // Phase 12: Nyash ABI (vtable) 雛形
pub mod type_registry; // Phase 12: TypeId→TypeBox 解決(雛形)
pub mod host_handles; // C ABI(TLV) 向け HostHandle レジストリ(ユーザー/内蔵Box受け渡し
pub mod host_api; // C ABI: plugins -> host 逆呼び出しAPITLSでVMに橋渡し
pub mod extern_registry; // ExternCall (env.*) 登録・診断用レジストリ
#[cfg(test)]
mod tests;