Expose Forge compiler
This commit is contained in:
@@ -4,6 +4,7 @@ mod nova_forth;
|
||||
mod error;
|
||||
|
||||
use wasm_bindgen::prelude::*;
|
||||
use forge_core::compiler::build_boot;
|
||||
use crate::error::JsVasmError;
|
||||
|
||||
#[wasm_bindgen]
|
||||
@@ -16,3 +17,8 @@ pub fn source_map(snippet: String) -> JsValue {
|
||||
let source_map = vasm_core::snippet_source_map(snippet.lines().map(String::from)).map_err(|err| JsVasmError::from(err));
|
||||
serde_wasm_bindgen::to_value(&source_map).unwrap()
|
||||
}
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn compile_forge(src: String) -> Result<String, String> {
|
||||
build_boot(src.as_str()).map(|s| s.join("\n")).map_err(|e| format!("{}", e))
|
||||
}
|
||||
Reference in New Issue
Block a user