runner(cli): adopt CliConfig::as_groups across runner modules (dispatch/common/pipe_io/mir/bench). llvm-builder: extract ny_main wrapper to builders.entry; add optional env-gated function_lower delegation; keep default behavior unchanged
This commit is contained in:
@ -176,10 +176,11 @@ impl NyashRunner {
|
||||
// Force JIT mode for this run
|
||||
std::env::set_var("NYASH_JIT_EXEC", "1");
|
||||
std::env::set_var("NYASH_JIT_THRESHOLD", "1");
|
||||
if self.config.jit_stats {
|
||||
let groups = self.config.as_groups();
|
||||
if groups.backend.jit.stats {
|
||||
std::env::set_var("NYASH_JIT_STATS", "1");
|
||||
}
|
||||
if self.config.jit_stats_json {
|
||||
if groups.backend.jit.stats_json {
|
||||
std::env::set_var("NYASH_JIT_STATS_JSON", "1");
|
||||
}
|
||||
let start = std::time::Instant::now();
|
||||
|
||||
@ -27,7 +27,8 @@ impl NyashRunner {
|
||||
}
|
||||
}
|
||||
// Direct v0 bridge when requested via CLI/env
|
||||
let use_ny_parser = self.config.parser_ny || std::env::var("NYASH_USE_NY_PARSER").ok().as_deref() == Some("1");
|
||||
let groups = self.config.as_groups();
|
||||
let use_ny_parser = groups.parser.parser_ny || std::env::var("NYASH_USE_NY_PARSER").ok().as_deref() == Some("1");
|
||||
if use_ny_parser {
|
||||
let code = match fs::read_to_string(filename) {
|
||||
Ok(content) => content,
|
||||
@ -45,7 +46,7 @@ impl NyashRunner {
|
||||
}
|
||||
}
|
||||
// AST dump mode
|
||||
if self.config.dump_ast {
|
||||
if groups.debug.dump_ast {
|
||||
println!("🧠 Nyash AST Dump - Processing file: {}", filename);
|
||||
let code = match fs::read_to_string(filename) {
|
||||
Ok(content) => content,
|
||||
@ -60,20 +61,20 @@ impl NyashRunner {
|
||||
}
|
||||
|
||||
// MIR dump/verify
|
||||
if self.config.dump_mir || self.config.verify_mir {
|
||||
if groups.debug.dump_mir || groups.debug.verify_mir {
|
||||
crate::cli_v!("🚀 Nyash MIR Compiler - Processing file: {} 🚀", filename);
|
||||
self.execute_mir_mode(filename);
|
||||
return;
|
||||
}
|
||||
|
||||
// WASM / AOT (feature-gated)
|
||||
if self.config.compile_wasm {
|
||||
if groups.compile_wasm {
|
||||
#[cfg(feature = "wasm-backend")]
|
||||
{ self.execute_wasm_mode(filename); return; }
|
||||
#[cfg(not(feature = "wasm-backend"))]
|
||||
{ eprintln!("❌ WASM backend not available. Please rebuild with: cargo build --features wasm-backend"); process::exit(1); }
|
||||
}
|
||||
if self.config.compile_native {
|
||||
if groups.compile_native {
|
||||
#[cfg(feature = "cranelift-jit")]
|
||||
{ self.execute_aot_mode(filename); return; }
|
||||
#[cfg(not(feature = "cranelift-jit"))]
|
||||
@ -81,7 +82,7 @@ impl NyashRunner {
|
||||
}
|
||||
|
||||
// Backend selection
|
||||
match self.config.backend.as_str() {
|
||||
match groups.backend.backend.as_str() {
|
||||
"mir" => {
|
||||
crate::cli_v!("🚀 Nyash MIR Interpreter - Executing file: {} 🚀", filename);
|
||||
self.execute_mir_interpreter_mode(filename);
|
||||
|
||||
@ -36,8 +36,9 @@ impl NyashRunner {
|
||||
}
|
||||
};
|
||||
|
||||
let groups = self.config.as_groups();
|
||||
// Verify MIR if requested
|
||||
if self.config.verify_mir {
|
||||
if groups.debug.verify_mir {
|
||||
println!("🔍 Verifying MIR...");
|
||||
match &compile_result.verification_result {
|
||||
Ok(()) => println!("✅ MIR verification passed!"),
|
||||
@ -52,13 +53,13 @@ impl NyashRunner {
|
||||
}
|
||||
|
||||
// Dump MIR if requested
|
||||
if self.config.dump_mir {
|
||||
let mut printer = if self.config.mir_verbose {
|
||||
if groups.debug.dump_mir {
|
||||
let mut printer = if groups.debug.mir_verbose {
|
||||
MirPrinter::verbose()
|
||||
} else {
|
||||
MirPrinter::new()
|
||||
};
|
||||
if self.config.mir_verbose_effects {
|
||||
if groups.debug.mir_verbose_effects {
|
||||
printer.set_show_effects_inline(true);
|
||||
}
|
||||
println!("🚀 MIR Output for {}:", filename);
|
||||
@ -66,7 +67,7 @@ impl NyashRunner {
|
||||
}
|
||||
|
||||
// Emit MIR JSON if requested and exit
|
||||
if let Some(path) = self.config.emit_mir_json.as_ref() {
|
||||
if let Some(path) = groups.emit.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(&compile_result.module, p) {
|
||||
eprintln!("❌ MIR JSON emit error: {}", e);
|
||||
@ -77,12 +78,12 @@ impl NyashRunner {
|
||||
}
|
||||
|
||||
// Emit native executable via ny-llvmc (crate) and exit
|
||||
if let Some(exe_out) = self.config.emit_exe.as_ref() {
|
||||
if let Some(exe_out) = groups.emit.emit_exe.as_ref() {
|
||||
if let Err(e) = crate::runner::modes::common_util::exec::ny_llvmc_emit_exe_lib(
|
||||
&compile_result.module,
|
||||
exe_out,
|
||||
self.config.emit_exe_nyrt.as_deref(),
|
||||
self.config.emit_exe_libs.as_deref(),
|
||||
groups.emit.emit_exe_nyrt.as_deref(),
|
||||
groups.emit.emit_exe_libs.as_deref(),
|
||||
) {
|
||||
eprintln!("❌ {}", e);
|
||||
std::process::exit(1);
|
||||
|
||||
Reference in New Issue
Block a user