Skip to content

Commit

Permalink
upgrades and imports updates
Browse files Browse the repository at this point in the history
  • Loading branch information
tiye committed Mar 11, 2022
1 parent cb9bb88 commit 520f46b
Show file tree
Hide file tree
Showing 6 changed files with 157 additions and 151 deletions.
8 changes: 4 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ edition = "2018"

[dependencies]
# calcit = { path="../calcit" }
calcit = "0.5.18"
rpds = "0.10.0"
im_ternary_tree = "0.0.5-a1"
wasm-bindgen = "*"
calcit = "0.5.25"
rpds = "0.11.0"
im_ternary_tree = "0.0.6"
wasm-bindgen = "0.2.79"
console_error_panic_hook = "*"
web-sys = { version="0.3.5", features=[ "console" ] }

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Demo http://repo.calcit-lang.org/calcit-wasm-play/

### Development

> Based on local copy of calcit_runner.rs with `libloading` and injections disabled.
> Based on local copy of `calcit` with `libloading` and injections disabled.
Build wasm code:

Expand Down
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<div class="header" >
<a href="http://calcit-lang.org" class="logo" >Calcit Playground</a>
<div style="width: 16px; display: inline-block;" ></div>
<a href="https://github.com/calcit-lang/calcit_runner.rs/discussions/79#discussioncomment-1653493" target="_blank" >Examples</a>
<a href="https://github.com/calcit-lang/calcit/discussions/79#discussioncomment-1653493" target="_blank" >Examples</a>
<a href="http://apis.calcit-lang.org/" target="_blank">APIs</a>
<div style="width: 16px; display: inline-block;" ></div>
<button class="run" >Run</button>
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"author": "jiyinyiyong <[email protected]>",
"license": "MIT",
"devDependencies": {
"vite": "^2.8.4"
"vite": "^2.8.6"
},
"dependencies": {
"@mvc-works/codearea": "^0.0.3"
Expand Down
14 changes: 7 additions & 7 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use std::panic;

use wasm_bindgen::prelude::*;

use calcit_runner::{call_stack::CallStackList, load_core_snapshot, program, runner, snapshot, Calcit, CalcitErr, CalcitItems};
use calcit::{call_stack::CallStackList, load_core_snapshot, program, runner, snapshot, Calcit, CalcitErr, CalcitItems};

pub fn eval_code(snippet: String) -> Result<Calcit, String> {
// panic::set_hook(Box::new(console_error_panic_hook::hook));
Expand Down Expand Up @@ -40,16 +40,16 @@ pub fn eval_code(snippet: String) -> Result<Calcit, String> {

// make sure builtin classes are touched
runner::preprocess::preprocess_ns_def(
calcit_runner::primes::CORE_NS.into(),
calcit_runner::primes::BUILTIN_CLASSES_ENTRY.into(),
calcit_runner::primes::BUILTIN_CLASSES_ENTRY.into(),
calcit::primes::CORE_NS.into(),
calcit::primes::BUILTIN_CLASSES_ENTRY.into(),
calcit::primes::BUILTIN_CLASSES_ENTRY.into(),
None,
check_warnings,
&rpds::List::new_sync(),
)
.map_err(|e| e.msg)?;

let v = calcit_runner::run_program("app.main".into(), "main!".into(), TernaryTreeList::Empty).map_err(|e| format!("{}", e))?;
let v = calcit::run_program("app.main".into(), "main!".into(), TernaryTreeList::Empty).map_err(|e| format!("{}", e))?;

// web_sys::console::log_1(&JsValue::from_str(&format!("Result: {}", v)));
// JsValue::from_str(&format!("Result: {}", v))
Expand All @@ -70,8 +70,8 @@ pub fn console_log(xs: &CalcitItems, _call_stack: &CallStackList) -> Result<Calc

#[wasm_bindgen]
pub fn run_code(snippet: String) -> String {
calcit_runner::builtins::register_import_proc("println", console_log);
calcit_runner::builtins::register_import_proc("echo", console_log);
calcit::builtins::register_import_proc("println", console_log);
calcit::builtins::register_import_proc("echo", console_log);

match eval_code(snippet) {
Ok(v) => format!("{}", v),
Expand Down
Loading

0 comments on commit 520f46b

Please sign in to comment.