Develop wasm support further.

This commit is contained in:
Oleksandr Kozachuk
2023-01-06 16:16:04 +01:00
parent 3416ea96ae
commit e9dba54750
5 changed files with 49 additions and 16 deletions
+18 -3
View File
@@ -1,6 +1,21 @@
use hel::lk::LK;
use std::sync::{Arc, Mutex};
use hel::lk::{LK, LKRef};
use hel::repl::LKRead;
use hel::utils::editor::Editor;
use std::sync::Arc;
use parking_lot::ReentrantMutex;
use std::cell::RefCell;
use wasm_bindgen::prelude::*;
lazy_static! {
static ref STATE: Arc<Mutex<LK>> = Arc::new(Mutex::new(LK::new()));
static ref STATE: LKRef = Arc::new(ReentrantMutex::new(RefCell::new(LK::new())));
}
#[wasm_bindgen]
pub fn hel_command(cmd: String) -> String {
let editor = Editor::new();
let mut lkread = LKRead::new(editor, "> ".to_string(), STATE.clone());
lkread.cmd = cmd.to_string();
let lkeval = lkread.read();
let lkprint = lkeval.eval();
lkprint.out.output().join("\n")
}