feat(plugins): migrate Python family to TypeBox v2; complete first‑party v2 set (Regex/Net/Path/Math/Time/File)\n\nfeat(smoke): add Net round‑trip sample and wire to plugin v2 smoke\n\nfeat(cli): add --emit-mir-json and runner emit+exit path\n\nchore(config): register Python v2 boxes in nyash.toml\n\nchore(loader): improve v2 diagnostics and ensure v2 shim dispatch\n\nchore(build): integrate ny-llvmc env gate in build_llvm.sh\n\nchore(tasks): update CURRENT_TASK with v2 Python/Net/emit flag
This commit is contained in:
10
src/cli.rs
10
src/cli.rs
@ -69,6 +69,8 @@ pub struct CliConfig {
|
||||
pub build_target: Option<String>,
|
||||
// Using (CLI)
|
||||
pub cli_usings: Vec<String>,
|
||||
// Emit MIR JSON to a file and exit (bridge mode)
|
||||
pub emit_mir_json: Option<String>,
|
||||
}
|
||||
|
||||
impl CliConfig {
|
||||
@ -131,6 +133,12 @@ impl CliConfig {
|
||||
.value_name("FILE")
|
||||
.help("Read Ny JSON IR v0 from a file and execute via MIR Interpreter")
|
||||
)
|
||||
.arg(
|
||||
Arg::new("emit-mir-json")
|
||||
.long("emit-mir-json")
|
||||
.value_name("FILE")
|
||||
.help("Emit MIR JSON v0 to file (validation-friendly) and exit")
|
||||
)
|
||||
.arg(
|
||||
Arg::new("stage3")
|
||||
.long("stage3")
|
||||
@ -482,6 +490,7 @@ impl CliConfig {
|
||||
.get_many::<String>("using")
|
||||
.map(|v| v.cloned().collect())
|
||||
.unwrap_or_else(|| Vec::new()),
|
||||
emit_mir_json: matches.get_one::<String>("emit-mir-json").cloned(),
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -536,6 +545,7 @@ impl Default for CliConfig {
|
||||
build_profile: None,
|
||||
build_target: None,
|
||||
cli_usings: Vec::new(),
|
||||
emit_mir_json: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -171,6 +171,16 @@ pub(crate) fn execute_file_with_backend(runner: &NyashRunner, filename: &str) {
|
||||
|
||||
impl NyashRunner {
|
||||
pub(crate) fn execute_mir_module(&self, module: &crate::mir::MirModule) {
|
||||
// If CLI requested MIR JSON emit, write to file and exit immediately.
|
||||
if let Some(path) = self.config.emit_mir_json.as_ref() {
|
||||
let p = std::path::Path::new(path);
|
||||
if let Err(e) = crate::runner::mir_json_emit::emit_mir_json_for_harness_bin(module, p) {
|
||||
eprintln!("❌ MIR JSON emit error: {}", e);
|
||||
std::process::exit(1);
|
||||
}
|
||||
println!("MIR JSON written: {}", p.display());
|
||||
std::process::exit(0);
|
||||
}
|
||||
use crate::backend::MirInterpreter;
|
||||
use crate::box_trait::{BoolBox, IntegerBox, StringBox};
|
||||
use crate::boxes::FloatBox;
|
||||
|
||||
@ -159,6 +159,16 @@ impl PluginLoaderV2 {
|
||||
let abi_ok = st.abi_tag == 0x5459_4258
|
||||
&& st.struct_size as usize >= std::mem::size_of::<NyashTypeBoxFfi>();
|
||||
if !abi_ok {
|
||||
if dbg_on() {
|
||||
eprintln!(
|
||||
"[PluginLoaderV2] WARN: invalid TypeBox ABI for {}.{} (abi_tag=0x{:08x} size={} need>={})",
|
||||
lib_name,
|
||||
box_type,
|
||||
st.abi_tag,
|
||||
st.struct_size,
|
||||
std::mem::size_of::<NyashTypeBoxFfi>()
|
||||
);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
// Remember invoke_id in box_specs for (lib_name, box_type)
|
||||
@ -172,7 +182,19 @@ impl PluginLoaderV2 {
|
||||
invoke_id: None,
|
||||
});
|
||||
entry.invoke_id = Some(invoke_id);
|
||||
} else if dbg_on() {
|
||||
eprintln!(
|
||||
"[PluginLoaderV2] WARN: TypeBox present but no invoke_id for {}.{} — plugin should export per-Box invoke",
|
||||
lib_name, box_type
|
||||
);
|
||||
}
|
||||
} else if dbg_on() {
|
||||
eprintln!(
|
||||
"[PluginLoaderV2] NOTE: TypeBox symbol not found for {}.{} (symbol='{}'). Migrate plugin to Nyash ABI v2 to enable per-Box dispatch.",
|
||||
lib_name,
|
||||
box_type,
|
||||
sym_name.trim_end_matches('\0')
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -228,8 +250,24 @@ impl PluginLoaderV2 {
|
||||
let (lib_name, box_type) = self.find_box_by_type_id(config, &toml_value, type_id)?;
|
||||
let key = (lib_name.to_string(), box_type.to_string());
|
||||
let map = self.box_specs.read().ok()?;
|
||||
let spec = map.get(&key)?;
|
||||
spec.invoke_id
|
||||
let spec = map.get(&key);
|
||||
if let Some(s) = spec {
|
||||
if s.invoke_id.is_none() && dbg_on() {
|
||||
eprintln!(
|
||||
"[PluginLoaderV2] WARN: no per-Box invoke for {}.{} (type_id={}). Calls will fail with E_PLUGIN (-5) until plugin migrates to v2.",
|
||||
lib_name, box_type, type_id
|
||||
);
|
||||
}
|
||||
s.invoke_id
|
||||
} else {
|
||||
if dbg_on() {
|
||||
eprintln!(
|
||||
"[PluginLoaderV2] INFO: no TypeBox spec loaded for {}.{} (type_id={}).",
|
||||
lib_name, box_type, type_id
|
||||
);
|
||||
}
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
pub fn metadata_for_type_id(&self, type_id: u32) -> Option<PluginBoxMetadata> {
|
||||
|
||||
@ -25,7 +25,6 @@ pub fn box_invoke_for_type_id(type_id: u32) -> Option<super::enabled::host_bridg
|
||||
}
|
||||
|
||||
/// Library-level shim to dispatch a v2 per-Box invoke function using type_id
|
||||
#[no_mangle]
|
||||
pub extern "C" fn nyash_plugin_invoke_v2_shim(
|
||||
type_id: u32,
|
||||
method_id: u32,
|
||||
|
||||
Reference in New Issue
Block a user