selfhost: implement script args passthrough (argv after -- → NYASH_SCRIPT_ARGS_JSON → Main.main(args)); interpreter: support ArrayBox.of and inject args; runner: prefer child compiler with --read-tmp

This commit is contained in:
Selfhosting Dev
2025-09-17 01:55:08 +09:00
parent d3103cead8
commit f2ffa30645
6 changed files with 181 additions and 69 deletions

View File

@ -16,6 +16,16 @@ impl NyashInterpreter {
pub(in crate::interpreter) fn execute_array_method(&mut self, array_box: &ArrayBox, method: &str, arguments: &[ASTNode])
-> Result<Box<dyn NyashBox>, RuntimeError> {
match method {
"of" => {
// Build a new ArrayBox from provided arguments
let mut elems: Vec<Box<dyn NyashBox>> = Vec::with_capacity(arguments.len());
for arg in arguments {
let v = self.execute_expression(arg)?;
elems.push(v);
}
let arr = ArrayBox::new_with_elements(elems);
return Ok(Box::new(arr));
}
"push" => {
if arguments.len() != 1 {
return Err(RuntimeError::InvalidOperation {
@ -300,4 +310,4 @@ impl NyashInterpreter {
}
}
}
}
}