From 4e77747ae67e0ef27f9841111058599c8e916a2f Mon Sep 17 00:00:00 2001 From: Andrew Morris Date: Fri, 10 Mar 2023 13:10:48 +1100 Subject: [PATCH] Add valuescript_program_embed --- Cargo.lock | 7 ++++++ Cargo.toml | 1 + valuescript_program_embed/Cargo.toml | 9 +++++++ valuescript_program_embed/src/main.rs | 34 +++++++++++++++++++++++++++ 4 files changed, 51 insertions(+) create mode 100644 valuescript_program_embed/Cargo.toml create mode 100644 valuescript_program_embed/src/main.rs diff --git a/Cargo.lock b/Cargo.lock index 014cbc1..9ecb27b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2181,6 +2181,13 @@ dependencies = [ "swc_ecma_parser", ] +[[package]] +name = "valuescript_program_embed" +version = "0.1.0" +dependencies = [ + "valuescript_vm", +] + [[package]] name = "valuescript_vm" version = "0.1.0" diff --git a/Cargo.toml b/Cargo.toml index 5d92532..1f9f17c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,6 +3,7 @@ members = [ "valuescript_vm", "valuescript_compiler", + "valuescript_program_embed", "valuescript_wasm", "vstc", "swc_demo", diff --git a/valuescript_program_embed/Cargo.toml b/valuescript_program_embed/Cargo.toml new file mode 100644 index 0000000..545e75e --- /dev/null +++ b/valuescript_program_embed/Cargo.toml @@ -0,0 +1,9 @@ +[package] +name = "valuescript_program_embed" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +valuescript_vm = { path = "../valuescript_vm" } diff --git a/valuescript_program_embed/src/main.rs b/valuescript_program_embed/src/main.rs new file mode 100644 index 0000000..33f5e28 --- /dev/null +++ b/valuescript_program_embed/src/main.rs @@ -0,0 +1,34 @@ +use std::rc::Rc; + +use valuescript_vm::VirtualMachine; + +pub fn main() { + let mut vm = VirtualMachine::new(); + let result = vm.run( + &Rc::new(vec![ + 0x0d, 0x05, 0x00, 0x0a, 0x00, 0x0b, 0x08, 0x00, 0x21, 0x0d, 0x9c, 0x00, 0x09, 0x09, 0x06, + 0x01, 0x06, 0x09, 0x06, 0x19, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x50, 0x7f, 0x40, + 0x00, 0x02, 0x05, 0x0e, 0x02, 0x06, 0x01, 0x03, 0x21, 0x0d, 0x9c, 0x00, 0x09, 0x09, 0x06, + 0x01, 0x06, 0x03, 0x06, 0x0d, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x50, 0x7f, 0x40, + 0x00, 0x02, 0x05, 0x0e, 0x02, 0x06, 0x01, 0x04, 0x21, 0x0d, 0x9c, 0x00, 0x09, 0x09, 0x06, + 0x01, 0x06, 0x05, 0x06, 0x11, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x50, 0x7f, 0x40, + 0x00, 0x02, 0x05, 0x0e, 0x02, 0x06, 0x01, 0x05, 0x21, 0x0d, 0x9c, 0x00, 0x09, 0x09, 0x06, + 0x01, 0x06, 0x07, 0x06, 0x15, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x50, 0x7f, 0x40, + 0x00, 0x02, 0x05, 0x0e, 0x02, 0x06, 0x01, 0x06, 0x26, 0x09, 0x06, 0x01, 0x0e, 0x03, 0x0e, + 0x04, 0x0e, 0x05, 0x0e, 0x06, 0x00, 0x08, 0x06, 0x72, 0x65, 0x64, 0x75, 0x63, 0x65, 0x09, + 0x0d, 0x1e, 0x01, 0x00, 0x00, 0x00, 0x0b, 0x08, 0x02, 0x26, 0x0e, 0x02, 0x08, 0x06, 0x72, + 0x65, 0x64, 0x75, 0x63, 0x65, 0x09, 0x0d, 0x1e, 0x01, 0x00, 0x04, 0x01, 0x06, 0x03, 0x05, + 0x11, 0x0e, 0x05, 0x0e, 0x03, 0x06, 0x10, 0x0e, 0x06, 0x06, 0x28, 0x0e, 0x06, 0xe1, 0x00, + 0x21, 0x0d, 0xe6, 0x00, 0x09, 0x0e, 0x02, 0x00, 0x02, 0x24, 0x0e, 0x02, 0x06, 0x02, 0x06, + 0x04, 0x0e, 0x04, 0x0e, 0x06, 0x04, 0x01, 0x0e, 0x05, 0x06, 0x02, 0x05, 0x27, 0xb4, 0x00, + 0x01, 0x0e, 0x04, 0x00, 0x00, 0x0b, 0x09, 0x01, 0x24, 0x0e, 0x02, 0x06, 0x00, 0x03, 0x24, + 0x0e, 0x02, 0x06, 0x01, 0x04, 0x24, 0x0e, 0x02, 0x06, 0x02, 0x05, 0x06, 0x06, 0x03, 0x0e, + 0x05, 0x02, 0x06, 0x06, 0x03, 0x0e, 0x04, 0x06, 0x05, 0x0e, 0x02, 0x0e, 0x06, 0x07, 0x04, + 0x0e, 0x07, 0x0e, 0x03, 0x06, 0x01, 0x09, 0x0e, 0x04, 0x0e, 0x05, 0x0e, 0x06, 0x00, 0x00, + 0x00, 0x0b, 0x05, 0x02, 0x04, 0x0e, 0x02, 0x0e, 0x03, 0x00, 0x00, + ]), + &[], + ); + + println!("{}", result); +}