Skip to content

Commit

Permalink
Rework Wasm interface
Browse files Browse the repository at this point in the history
  • Loading branch information
bakaq committed Feb 14, 2025
1 parent 4a7e05a commit 61aad6c
Show file tree
Hide file tree
Showing 4 changed files with 394 additions and 15 deletions.
58 changes: 57 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ web-sys = { version = "0.3", features = [
"Performance",
] }
js-sys = "0.3"
ouroboros = "0.18"

[dev-dependencies]
maplit = "1.0.2"
Expand Down
16 changes: 2 additions & 14 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,27 +39,15 @@ mod repl_helper;
mod targets;
pub(crate) mod types;

#[cfg(target_arch = "wasm32")]
use wasm_bindgen::prelude::*;

// Re-exports
pub use machine::config::*;
pub use machine::lib_machine::*;
pub use machine::Machine;

/// Eval a source file in Wasm.
#[cfg(target_arch = "wasm32")]
#[wasm_bindgen]
pub fn eval_code(s: &str) -> String {
use machine::mock_wam::*;

console_error_panic_hook::set_once();

let mut wam = MachineBuilder::default().build();
let bytes = wam.test_load_string(s);
String::from_utf8_lossy(&bytes).to_string()
}
pub mod wasm;

#[cfg(not(target_arch = "wasm32"))]
/// The entry point for the Scryer Prolog CLI.
pub fn run_binary() -> std::process::ExitCode {
use crate::atom_table::Atom;
Expand Down
Loading

0 comments on commit 61aad6c

Please sign in to comment.