pyvm: split op handlers into ops_core/ops_box/ops_ctrl; add ops_flow + intrinsic; delegate vm.py without behavior change
net-plugin: modularize constants (consts.rs) and sockets (sockets.rs); remove legacy commented socket code; fix unused imports mir: move instruction unit tests to tests/mir_instruction_unit.rs (file lean-up); no semantic changes runner/pyvm: ensure using pre-strip; misc docs updates Build: cargo build ok; legacy cfg warnings remain as before
This commit is contained in:
@ -14,21 +14,37 @@ pub fn run_pyvm_harness(module: &crate::mir::MirModule, tag: &str) -> Result<i32
|
||||
crate::runner::mir_json_emit::emit_mir_json_for_harness_bin(module, &mir_json_path)
|
||||
.map_err(|e| format!("PyVM MIR JSON emit error: {}", e))?;
|
||||
crate::cli_v!("[ny-compiler] using PyVM ({} ) → {}", tag, mir_json_path.display());
|
||||
// Determine entry function hint (prefer Main.main if present)
|
||||
// Determine entry function (prefer Main.main; top-level main only if allowed)
|
||||
let allow_top = crate::config::env::entry_allow_toplevel_main();
|
||||
let entry = if module.functions.contains_key("Main.main") {
|
||||
"Main.main"
|
||||
} else if allow_top && module.functions.contains_key("main") {
|
||||
"main"
|
||||
} else if module.functions.contains_key("main") {
|
||||
eprintln!("[entry] Warning: using top-level 'main' without explicit allow; set NYASH_ENTRY_ALLOW_TOPLEVEL_MAIN=1 to silence.");
|
||||
"main"
|
||||
} else {
|
||||
"Main.main"
|
||||
};
|
||||
let status = std::process::Command::new(py3)
|
||||
// Optional: Mini‑VM stdin loader — when enabled, read entire stdin and pass as argv[0]
|
||||
let mut cmd = std::process::Command::new(py3);
|
||||
if std::env::var("NYASH_MINIVM_READ_STDIN").ok().as_deref() == Some("1") {
|
||||
use std::io::Read;
|
||||
let mut buf = String::new();
|
||||
let _ = std::io::stdin().read_to_string(&mut buf);
|
||||
// Wrap as argv JSON array [string]
|
||||
let arg_json = serde_json::json!([buf]).to_string();
|
||||
cmd.env("NYASH_SCRIPT_ARGS_JSON", arg_json);
|
||||
}
|
||||
let status = cmd
|
||||
.args([
|
||||
runner.to_string_lossy().as_ref(),
|
||||
"--in",
|
||||
&mir_json_path.display().to_string(),
|
||||
"--entry",
|
||||
entry,
|
||||
"--args-env",
|
||||
"NYASH_SCRIPT_ARGS_JSON",
|
||||
])
|
||||
.status()
|
||||
.map_err(|e| format!("spawn pyvm: {}", e))?;
|
||||
@ -53,21 +69,35 @@ pub fn run_pyvm_harness_lib(module: &nyash_rust::mir::MirModule, tag: &str) -> R
|
||||
crate::runner::mir_json_emit::emit_mir_json_for_harness(module, &mir_json_path)
|
||||
.map_err(|e| format!("PyVM MIR JSON emit error: {}", e))?;
|
||||
crate::cli_v!("[Runner] using PyVM ({} ) → {}", tag, mir_json_path.display());
|
||||
// Determine entry function hint (prefer Main.main if present)
|
||||
// Determine entry function (prefer Main.main; top-level main only if allowed)
|
||||
let allow_top = crate::config::env::entry_allow_toplevel_main();
|
||||
let entry = if module.functions.contains_key("Main.main") {
|
||||
"Main.main"
|
||||
} else if allow_top && module.functions.contains_key("main") {
|
||||
"main"
|
||||
} else if module.functions.contains_key("main") {
|
||||
eprintln!("[entry] Warning: using top-level 'main' without explicit allow; set NYASH_ENTRY_ALLOW_TOPLEVEL_MAIN=1 to silence.");
|
||||
"main"
|
||||
} else {
|
||||
"Main.main"
|
||||
};
|
||||
let status = std::process::Command::new(py3)
|
||||
let mut cmd = std::process::Command::new(py3);
|
||||
if std::env::var("NYASH_MINIVM_READ_STDIN").ok().as_deref() == Some("1") {
|
||||
use std::io::Read;
|
||||
let mut buf = String::new();
|
||||
let _ = std::io::stdin().read_to_string(&mut buf);
|
||||
let arg_json = serde_json::json!([buf]).to_string();
|
||||
cmd.env("NYASH_SCRIPT_ARGS_JSON", arg_json);
|
||||
}
|
||||
let status = cmd
|
||||
.args([
|
||||
runner.to_string_lossy().as_ref(),
|
||||
"--in",
|
||||
&mir_json_path.display().to_string(),
|
||||
"--entry",
|
||||
entry,
|
||||
"--args-env",
|
||||
"NYASH_SCRIPT_ARGS_JSON",
|
||||
])
|
||||
.status()
|
||||
.map_err(|e| format!("spawn pyvm: {}", e))?;
|
||||
|
||||
Reference in New Issue
Block a user