feat: comprehensive development progress

- Pattern matching implementation extended in match_expr.rs
- CLI configuration structured with categorized groups (task recommendation completed)
- Python LLVM builder split into function_lower.py (task recommendation completed)
- parse_box_declaration massive function refactored (task recommendation completed)
- Phase 16 Macro Revolution comprehensive planning and documentation
- Archive legacy phase documentation for clean structure
- HTTP message box improvements and performance optimizations
- MIR builder enhancements and control flow improvements

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Selfhosting Dev
2025-09-19 15:11:57 +09:00
parent 3c7a5de900
commit 811e3eb3f8
18 changed files with 739 additions and 250 deletions

View File

@ -54,9 +54,9 @@ impl NyashRunner {
/// Run Nyash based on the configuration
pub fn run(&self) {
let groups = self.config.as_groups();
// Build system (MVP): nyash --build <nyash.toml>
if let Some(cfg_path) = self.config.build_path.clone() {
let groups = self.config.as_groups();
if let Some(cfg_path) = groups.build.path.clone() {
if let Err(e) = self.run_build_mvp(&cfg_path) {
eprintln!("❌ build error: {}", e);
std::process::exit(1);
@ -67,7 +67,7 @@ impl NyashRunner {
let mut using_ctx = self.init_using_context();
let mut pending_using: Vec<(String, Option<String>)> = Vec::new();
// CLI --using SPEC entries (SPEC: 'ns', 'ns as Alias', '"path" as Alias')
for spec in &self.config.cli_usings {
for spec in &groups.input.cli_usings {
let s = spec.trim();
if s.is_empty() {
continue;
@ -133,7 +133,7 @@ impl NyashRunner {
return;
}
// Run named task from nyash.toml (MVP)
if let Some(task) = self.config.run_task.clone() {
if let Some(task) = groups.run_task.clone() {
if let Err(e) = run_named_task(&task) {
eprintln!("❌ Task error: {}", e);
process::exit(1);
@ -141,11 +141,11 @@ impl NyashRunner {
return;
}
// Verbose CLI flag maps to env for downstream helpers/scripts
if self.config.cli_verbose {
if groups.debug.cli_verbose {
std::env::set_var("NYASH_CLI_VERBOSE", "1");
}
// GC mode forwarding: map CLI --gc to NYASH_GC_MODE for downstream runtimes
if let Some(ref m) = self.config.gc_mode {
if let Some(ref m) = groups.gc_mode {
if !m.trim().is_empty() {
std::env::set_var("NYASH_GC_MODE", m);
}
@ -155,7 +155,7 @@ impl NyashRunner {
// // @env KEY=VALUE
// // @jit-debug (preset: exec, threshold=1, events+trace)
// // @plugin-builtins (NYASH_USE_PLUGIN_BUILTINS=1)
if let Some(ref filename) = self.config.file {
if let Some(ref filename) = groups.input.file {
if let Ok(code) = fs::read_to_string(filename) {
// Apply script-level directives and lint
let strict_fields =
@ -163,7 +163,7 @@ impl NyashRunner {
if let Err(e) = cli_directives::apply_cli_directives_from_source(
&code,
strict_fields,
self.config.cli_verbose,
groups.debug.cli_verbose,
) {
eprintln!("❌ Lint/Directive error: {}", e);
std::process::exit(1);
@ -273,7 +273,7 @@ impl NyashRunner {
std::env::set_var("NYASH_PLUGIN_OVERRIDE_TYPES", override_types.join(","));
// Opt-in: load Ny script plugins listed in nyash.toml [ny_plugins]
if self.config.load_ny_plugins
if groups.load_ny_plugins
|| std::env::var("NYASH_LOAD_NY_PLUGINS").ok().as_deref() == Some("1")
{
if let Ok(text) = std::fs::read_to_string("nyash.toml") {
@ -406,7 +406,7 @@ impl NyashRunner {
}
// Architectural pivot: JIT is compiler-only (EXE/AOT). Ensure VM runtime does not dispatch to JIT
// unless explicitly requested via independent JIT mode, or when emitting AOT objects.
if !self.config.compile_native && !self.config.jit_direct {
if !groups.compile_native && !groups.backend.jit.direct {
// When AOT object emission is requested, allow JIT to run for object generation
let aot_obj = std::env::var("NYASH_AOT_OBJECT_OUT").ok();
if aot_obj.is_none() || aot_obj.as_deref() == Some("") {
@ -415,10 +415,10 @@ impl NyashRunner {
}
}
// Benchmark mode - can run without a file
if self.config.benchmark {
if groups.benchmark {
println!("📊 Nyash Performance Benchmark Suite");
println!("====================================");
println!("Running {} iterations per test...", self.config.iterations);
println!("Running {} iterations per test...", groups.iterations);
println!();
#[cfg(feature = "vm-legacy")]
{
@ -434,9 +434,9 @@ impl NyashRunner {
}
}
if let Some(ref filename) = self.config.file {
if let Some(ref filename) = groups.input.file {
// Independent JIT direct mode (no VM execute path)
if self.config.jit_direct {
if groups.backend.jit.direct {
self.run_file_jit_direct(filename);
return;
}

View File

@ -6,7 +6,8 @@ impl NyashRunner {
/// Execute AOT compilation mode (split)
#[cfg(feature = "cranelift-jit")]
pub(crate) fn execute_aot_mode(&self, filename: &str) {
let output = self.config.output_file.as_deref().unwrap_or("app");
let groups = self.config.as_groups();
let output = groups.output_file.as_deref().unwrap_or("app");
// Prefer using provided helper scripts to ensure link flags and runtime integration
let status = if cfg!(target_os = "windows") {
// Use PowerShell helper; falls back to bash if available inside the script

View File

@ -6,9 +6,10 @@ use nyash_rust::{
impl NyashRunner {
/// Execute benchmark mode (split)
pub(crate) fn execute_benchmark_mode(&self) {
let groups = self.config.as_groups();
println!(
"🏁 Running benchmark mode with {} iterations",
self.config.iterations
groups.iterations
);
// Tests: some run on all backends, some are JIT+f64 only
// Third element indicates JIT+f64 only (skip VM/Interpreter)
@ -72,16 +73,16 @@ impl NyashRunner {
"(JIT+f64 only) Skipping VM/Interpreter; requires --features cranelift-jit"
);
// Warmup JIT
let warmup = (self.config.iterations / 10).max(1);
let warmup = (groups.iterations / 10).max(1);
self.bench_jit(code, warmup);
// Measured
let jit_time = self.bench_jit(code, self.config.iterations);
let jit_time = self.bench_jit(code, groups.iterations);
println!("\n📊 Performance Summary [{}]:", name);
println!(
" JIT f64 ops: {} iters in {:?} ({:.2} ops/sec)",
self.config.iterations,
groups.iterations,
jit_time,
self.config.iterations as f64 / jit_time.as_secs_f64()
groups.iterations as f64 / jit_time.as_secs_f64()
);
} else {
// Quick correctness check across modes (golden): Interpreter vs VM vs VM+JIT
@ -91,15 +92,15 @@ impl NyashRunner {
println!("✅ Outputs match across Interpreter/VM/JIT");
}
// Warmup (not measured)
let warmup = (self.config.iterations / 10).max(1);
let warmup = (groups.iterations / 10).max(1);
self.bench_interpreter(code, warmup);
self.bench_vm(code, warmup);
self.bench_jit(code, warmup);
// Measured runs
let interpreter_time = self.bench_interpreter(code, self.config.iterations);
let vm_time = self.bench_vm(code, self.config.iterations);
let jit_time = self.bench_jit(code, self.config.iterations);
let interpreter_time = self.bench_interpreter(code, groups.iterations);
let vm_time = self.bench_vm(code, groups.iterations);
let jit_time = self.bench_jit(code, groups.iterations);
// Summary
let vm_vs_interp = interpreter_time.as_secs_f64() / vm_time.as_secs_f64();

View File

@ -110,7 +110,8 @@ impl NyashRunner {
_ => {
if cli_verbose() {
println!("🦀 Nyash Rust Implementation - Executing file: {} 🦀", filename);
if let Some(fuel) = self.config.debug_fuel {
let groups = self.config.as_groups();
if let Some(fuel) = groups.debug.debug_fuel {
println!("🔥 Debug fuel limit: {} iterations", fuel);
} else {
println!("🔥 Debug fuel limit: unlimited");
@ -498,8 +499,9 @@ impl NyashRunner {
}
// Parse the code with debug fuel limit
eprintln!("🔍 DEBUG: Starting parse with fuel: {:?}...", self.config.debug_fuel);
let ast = match NyashParser::parse_from_string_with_fuel(code_ref, self.config.debug_fuel) {
let groups = self.config.as_groups();
eprintln!("🔍 DEBUG: Starting parse with fuel: {:?}...", groups.debug.debug_fuel);
let ast = match NyashParser::parse_from_string_with_fuel(code_ref, groups.debug.debug_fuel) {
Ok(ast) => { eprintln!("🔍 DEBUG: Parse completed, AST created"); ast },
Err(e) => { eprintln!("❌ Parse error: {}", e); process::exit(1); }
};

View File

@ -35,7 +35,8 @@ impl NyashRunner {
};
// Determine output file
let output = self.config.output_file.as_deref().unwrap_or_else(|| {
let groups = self.config.as_groups();
let output = groups.output_file.as_deref().unwrap_or_else(|| {
if filename.ends_with(".nyash") { filename.strip_suffix(".nyash").unwrap_or(filename) } else { filename }
});
let output_file = format!("{}.wat", output);
@ -46,4 +47,3 @@ impl NyashRunner {
}
}
}