diff options
| author | Brian Cully <bjc@spork.org> | 2025-08-22 11:39:14 -0400 |
|---|---|---|
| committer | Brian Cully <bjc@spork.org> | 2025-08-22 11:39:14 -0400 |
| commit | 40352318ad887ad0bab7c9a3d22695bbcbe9f738 (patch) | |
| tree | 2d9822c1762cbc0852114149539abfa21185cc93 /src/lib.rs | |
| parent | a1c946b747325b4d7df778ebc70112338482f143 (diff) | |
| download | automathon-40352318ad887ad0bab7c9a3d22695bbcbe9f738.tar.gz automathon-40352318ad887ad0bab7c9a3d22695bbcbe9f738.zip | |
start hooking the web ui up to rust
Diffstat (limited to 'src/lib.rs')
| -rwxr-xr-x | src/lib.rs | 24 |
1 files changed, 22 insertions, 2 deletions
@@ -1,3 +1,5 @@ +use log::{Level, debug, info}; +use console_log; use wasm_bindgen::prelude::*; mod forth; @@ -8,8 +10,26 @@ extern { fn debug(s: &str); } +#[wasm_bindgen] +pub fn compile() { + info!("compiling code"); +} + +#[wasm_bindgen] +pub fn tick() { + info!("executing single instruction"); +} + +#[wasm_bindgen] +pub fn run() { + info!("running to completion"); +} + #[wasm_bindgen(start)] -pub fn run() -> Result<(), JsValue> { +pub fn init() -> Result<(), JsValue> { + console_log::init_with_level(Level::Debug).expect("couldn't init console log"); + debug!("starting run"); + let window = web_sys::window().expect("no global `window` exists"); let document = window.document().expect("should have `document` on window"); let body = document.body().expect("document should have `body`"); @@ -18,7 +38,7 @@ pub fn run() -> Result<(), JsValue> { val.set_text_content(Some("hi there")); body.append_child(&val)?; - debug("done in rust's run"); + debug!("done in rust's run"); Ok(()) } |
