Basic WebAssembly support with minimal Javascript API #615. Currently 6/12 crypto functions supported. Tested in browser with all default features disabled.

This commit is contained in:
Rujia Liu
2023-09-08 17:27:22 +08:00
parent a0b5a24853
commit b6ce6b7cdb
9 changed files with 184 additions and 32 deletions

View File

@@ -40,3 +40,17 @@ pub mod types;
use instructions::instr;
mod rcu;
#[cfg(target_arch = "wasm32")]
use wasm_bindgen::prelude::*;
#[cfg(target_arch = "wasm32")]
#[wasm_bindgen]
pub fn eval_code(s: &str) -> String {
use web_sys::console;
use machine::mock_wam::*;
let mut wam = Machine::with_test_streams();
let bytes = wam.test_load_string(s);
String::from_utf8_lossy(&bytes).to_string()
}