Simplify vm.run

This commit is contained in:
Andrew Morris
2023-11-02 11:36:25 +11:00
parent a5e76355f7
commit 32358b2dd6
9 changed files with 132 additions and 68 deletions

View File

@@ -1,8 +1,8 @@
use std::process::exit;
use std::rc::Rc;
use valuescript_vm::vs_value::Val;
use valuescript_vm::VirtualMachine;
use valuescript_vm::{vs_value::Val, DecoderMaker};
use crate::to_bytecode::{format_from_path, to_bytecode, RunFormat};
@@ -41,7 +41,12 @@ pub fn run_command(args: &Vec<String>) {
.map(|a| Val::String(Rc::from(a.clone())))
.collect();
match vm.run(bytecode, None, &val_args) {
match vm.run(
None,
&mut Val::Undefined,
bytecode.decoder(0).decode_val(&mut vec![]),
val_args,
) {
Ok(Val::Undefined) => {}
Ok(result) => {
println!("{}", result.pretty());