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

@@ -8,7 +8,7 @@ use valuescript_compiler::{
};
use valuescript_vm::{
vs_value::{ToVal, Val},
Bytecode, LoadFunctionResult, ValTrait, VirtualMachine,
Bytecode, DecoderMaker, LoadFunctionResult, ValTrait, VirtualMachine,
};
// When the `wee_alloc` feature is enabled, use `wee_alloc` as the global
@@ -130,7 +130,12 @@ fn run_to_result(entry_point: &str, read_file: &js_sys::Function, args: &str) ->
}
};
let vm_result = vm.run(bytecode, None, &val_args);
let vm_result = vm.run(
None,
&mut Val::Undefined,
bytecode.decoder(0).decode_val(&mut vec![]),
val_args,
);
RunResult {
diagnostics: HashMap::default(),