hv1: early-exit at main (no plugin init); tokenizer: Stage-3 single-quote + full escapes (\/ \b \f \' \r fix); builder: route BinOp via SSOT emit_binop_to_dst; hv1 verify canary route (builder→Core); docs: phase-20.39 updates

This commit is contained in:
nyash-codex
2025-11-04 20:46:43 +09:00
parent 31ce798341
commit 44a5158a14
53 changed files with 2237 additions and 179 deletions

View File

@ -15,32 +15,8 @@ use std::{fs, process};
impl NyashRunner {
/// Execute VM mode (split)
pub(crate) fn execute_vm_mode(&self, filename: &str) {
// Fast-path: hv1 verify direct (bypass NyashParser)
// If NYASH_VERIFY_JSON is present and hv1 route is requested, parse JSON v1 → MIR and run Core interpreter.
// This avoids generating/compiling Hako inline drivers and stabilizes -c/inline verify flows.
let want_hv1_direct = {
let has_json = std::env::var("NYASH_VERIFY_JSON").is_ok();
let route = std::env::var("HAKO_ROUTE_HAKOVM").ok().as_deref() == Some("1")
|| std::env::var("HAKO_VERIFY_PRIMARY").ok().as_deref() == Some("hakovm");
has_json && route
};
if want_hv1_direct {
if let Ok(j) = std::env::var("NYASH_VERIFY_JSON") {
// Try v1 schema first, then v0 for compatibility
if let Ok(Some(module)) = crate::runner::json_v1_bridge::try_parse_v1_to_module(&j) {
let rc = self.execute_mir_module_quiet_exit(&module);
println!("{}", rc);
std::process::exit(rc);
}
if let Ok(module) = crate::runner::mir_json_v0::parse_mir_v0_to_module(&j) {
let rc = self.execute_mir_module_quiet_exit(&module);
println!("{}", rc);
std::process::exit(rc);
}
eprintln!("❌ hv1-direct: invalid JSON for MIR (v1/v0)");
std::process::exit(1);
}
}
// Note: hv1 direct route is now handled at main.rs entry point (before plugin initialization).
// This function is only called after plugin initialization has already occurred.
// Quiet mode for child pipelines (e.g., selfhost compiler JSON emit)
let quiet_pipe = std::env::var("NYASH_JSON_ONLY").ok().as_deref() == Some("1");

View File

@ -15,6 +15,9 @@ impl NyashRunner {
/// - Respects using preprocessing done earlier in the pipeline
/// - Relies on global plugin host initialized by runner
pub(crate) fn execute_vm_fallback_interpreter(&self, filename: &str) {
// Note: hv1 direct route is now handled at main.rs entry point (before plugin initialization).
// This function is only called after plugin initialization has already occurred.
// Read source
let code = match fs::read_to_string(filename) {
Ok(s) => s,