Merge selfhosting-dev into main (Core-13 pure CI/tests + LLVM bridge) (#126)

* WIP: sync before merging origin/main

* fix: unify using/module + build CLI; add missing helper in runner; build passes; core smokes green; jit any.len string now returns 3

* Apply local changes after merging main; keep docs/phase-15 removed per main; add phase-15.1 docs and tests

* Remove legacy docs/phase-15/README.md to align with main

* integration: add Core-13 pure CI, tests, and minimal LLVM execute bridge (no docs) (#125)

Co-authored-by: Tomoaki <tomoaki@example.com>

---------

Co-authored-by: Selfhosting Dev <selfhost@example.invalid>
Co-authored-by: Tomoaki <tomoaki@example.com>
This commit is contained in:
moe-charm
2025-09-07 07:36:15 +09:00
committed by GitHub
parent 07350c5dd9
commit b8bdb867d8
70 changed files with 2010 additions and 57 deletions

View File

@ -34,6 +34,9 @@ static EXTERNS: Lazy<Vec<ExternSpec>> = Lazy::new(|| vec![
ExternSpec { iface: "env.future", method: "birth", min_arity: 1, max_arity: 1, slot: Some(20) },
ExternSpec { iface: "env.future", method: "set", min_arity: 2, max_arity: 2, slot: Some(21) },
ExternSpec { iface: "env.future", method: "await", min_arity: 1, max_arity: 1, slot: Some(22) },
// modules (minimal registry)
ExternSpec { iface: "env.modules", method: "set", min_arity: 2, max_arity: 2, slot: None },
ExternSpec { iface: "env.modules", method: "get", min_arity: 1, max_arity: 1, slot: None },
]);
pub fn resolve(iface: &str, method: &str) -> Option<ExternSpec> {

View File

@ -22,6 +22,7 @@ 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.*) 登録・診断用レジストリ
pub mod modules_registry; // env.modules minimal registry
#[cfg(test)]
mod tests;

View File

@ -0,0 +1,26 @@
//! Minimal global registry for env.modules (Phase 15 P0b)
use std::collections::HashMap;
use std::sync::Mutex;
use once_cell::sync::Lazy;
use crate::box_trait::NyashBox;
static REGISTRY: Lazy<Mutex<HashMap<String, Box<dyn NyashBox>>>> = Lazy::new(|| Mutex::new(HashMap::new()));
pub fn set(name: String, value: Box<dyn NyashBox>) {
if let Ok(mut map) = REGISTRY.lock() {
map.insert(name, value);
}
}
pub fn get(name: &str) -> Option<Box<dyn NyashBox>> {
if let Ok(mut map) = REGISTRY.lock() {
if let Some(b) = map.get_mut(name) {
// clone_box to hand out an owned copy
return Some(b.clone_box());
}
}
None
}

View File

@ -190,6 +190,21 @@ impl PluginLoaderV2 {
pub fn extern_call(&self, iface_name: &str, method_name: &str, args: &[Box<dyn NyashBox>]) -> BidResult<Option<Box<dyn NyashBox>>> {
match (iface_name, method_name) {
("env.console", "log") => { for a in args { println!("{}", a.to_string_box().value); } Ok(None) }
("env.modules", "set") => {
if args.len() >= 2 {
let key = args[0].to_string_box().value;
let val = args[1].clone_box();
crate::runtime::modules_registry::set(key, val);
}
Ok(None)
}
("env.modules", "get") => {
if let Some(k) = args.get(0) {
let key = k.to_string_box().value;
if let Some(v) = crate::runtime::modules_registry::get(&key) { return Ok(Some(v)); }
}
Ok(Some(Box::new(crate::box_trait::VoidBox::new())))
}
("env.task", "cancelCurrent") => { let tok = crate::runtime::global_hooks::current_group_token(); tok.cancel(); Ok(None) }
("env.task", "currentToken") => { let tok = crate::runtime::global_hooks::current_group_token(); let tb = crate::boxes::token_box::TokenBox::from_token(tok); Ok(Some(Box::new(tb))) }
("env.debug", "trace") => { if std::env::var("NYASH_DEBUG_TRACE").ok().as_deref() == Some("1") { for a in args { eprintln!("[debug.trace] {}", a.to_string_box().value); } } Ok(None) }