Expose Forge compiler

This commit is contained in:
2024-04-28 00:01:15 -05:00
parent 64460429de
commit c8c5a5d99c
+6
View File
@@ -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))
}