vm(hako): add v1 reader/dispatcher (flagged), commonize mir_call handler, share block scan; smokes: add v1 hakovm canary; docs: 20.37/20.38 plans, OOB policy; runner: v1 hakovm toggle; include SKIP summary
This commit is contained in:
@ -42,6 +42,47 @@ pub(crate) fn execute_file_with_backend(runner: &NyashRunner, filename: &str) {
|
||||
|
||||
// Direct v0 bridge when requested via CLI/env
|
||||
let groups = runner.config.as_groups();
|
||||
// Diagnostic/Exec: accept MIR JSON file direct (experimental; default OFF)
|
||||
if let Some(path) = groups.parser.mir_json_file.as_ref() {
|
||||
match std::fs::read_to_string(path) {
|
||||
Ok(text) => {
|
||||
// Try schema v1 first (preferred by emitter)
|
||||
match crate::runner::json_v1_bridge::try_parse_v1_to_module(&text) {
|
||||
Ok(Some(module)) => {
|
||||
crate::cli_v!("[mir-json] schema=v1 executing {} (len={})", path, text.len());
|
||||
let rc = runner.execute_mir_module_quiet_exit(&module);
|
||||
std::process::exit(rc);
|
||||
}
|
||||
Ok(None) => {
|
||||
// Not v1 schema; attempt minimal v0 loader
|
||||
if text.contains("\"functions\"") && text.contains("\"blocks\"") {
|
||||
match crate::runner::mir_json_v0::parse_mir_v0_to_module(&text) {
|
||||
Ok(module) => {
|
||||
crate::cli_v!("[mir-json] schema=v0 executing {} (len={})", path, text.len());
|
||||
let rc = runner.execute_mir_module_quiet_exit(&module);
|
||||
std::process::exit(rc);
|
||||
}
|
||||
Err(e) => {
|
||||
eprintln!("❌ MIR JSON v0 parse error: {}", e);
|
||||
std::process::exit(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
eprintln!("❌ MIR JSON invalid or unsupported shape: {}", path);
|
||||
std::process::exit(1);
|
||||
}
|
||||
Err(e) => {
|
||||
eprintln!("❌ MIR JSON parse error (v1): {}", e);
|
||||
std::process::exit(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
Err(e) => {
|
||||
eprintln!("❌ Error reading MIR JSON {}: {}", path, e);
|
||||
std::process::exit(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
let use_ny_parser = groups.parser.parser_ny
|
||||
|| std::env::var("NYASH_USE_NY_PARSER").ok().as_deref() == Some("1");
|
||||
if use_ny_parser {
|
||||
@ -236,10 +277,13 @@ impl NyashRunner {
|
||||
if let Some(_sb) = result.as_any().downcast_ref::<StringBox>() {
|
||||
return 0; // strings do not define rc semantics yet
|
||||
}
|
||||
0
|
||||
} else {
|
||||
0
|
||||
}
|
||||
// Global fallbacks when signature is missing or imprecise
|
||||
if let Some(ib) = result.as_any().downcast_ref::<IntegerBox>() { return to_rc(ib.value); }
|
||||
if let Some(bb) = result.as_any().downcast_ref::<BoolBox>() { return if bb.value { 1 } else { 0 }; }
|
||||
if let Some(fb) = result.as_any().downcast_ref::<FloatBox>() { return to_rc(fb.value as i64); }
|
||||
if let Some(_sb) = result.as_any().downcast_ref::<StringBox>() { return 0; }
|
||||
0
|
||||
}
|
||||
Err(_) => 1,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user