Skip to content

Commit

Permalink
Merge pull request #141 from calcit-lang/ternary-tree
Browse files Browse the repository at this point in the history
moving back to ternary-tree
  • Loading branch information
soyaine authored Dec 4, 2021
2 parents db2e8b1 + 40d1575 commit 01d2978
Show file tree
Hide file tree
Showing 21 changed files with 264 additions and 529 deletions.
16 changes: 8 additions & 8 deletions Cargo.lock

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

7 changes: 3 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "calcit_runner"
version = "0.5.10"
version = "0.5.11"
authors = ["jiyinyiyong <jiyinyiyong@gmail.com>"]
edition = "2018"
license = "MIT"
Expand Down Expand Up @@ -30,9 +30,8 @@ notify = "4.0.17"
walkdir = "2"
hex = "0.4.3"
rpds = "0.10.0"
fingertrees = "0.2.9"
# calcit_fingertrees = "0.0.3"
# calcit_fingertrees = { path = "/Users/chen/repo/calcit-lang/fingertree-rs" }
im_ternary_tree = "0.0.2-a2"
# im_ternary_tree = { path = "/Users/chen/repo/calcit-lang/ternary-tree" }

[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
libloading = "0.7.2"
Expand Down
14 changes: 7 additions & 7 deletions src/bin/cr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@ use std::time::Instant;
#[cfg(not(target_arch = "wasm32"))]
mod injection;

use im_ternary_tree::TernaryTreeList;
use notify::{RecommendedWatcher, RecursiveMode, Watcher};

use calcit_runner::{
builtins, call_stack, cli_args, codegen, codegen::emit_js::gen_stack, codegen::COMPILE_ERRORS_FILE, primes::finger_list::FingerList,
program, runner, snapshot, util, ProgramEntries,
builtins, call_stack, cli_args, codegen, codegen::emit_js::gen_stack, codegen::COMPILE_ERRORS_FILE, program, runner, snapshot, util,
ProgramEntries,
};

pub struct CLIOptions {
Expand Down Expand Up @@ -137,7 +138,7 @@ fn main() -> Result<(), String> {
let started_time = Instant::now();

let v =
calcit_runner::run_program(entries.init_ns.to_owned(), entries.init_def.to_owned(), FingerList::new_empty()).map_err(|e| {
calcit_runner::run_program(entries.init_ns.to_owned(), entries.init_def.to_owned(), TernaryTreeList::Empty).map_err(|e| {
for w in e.warnings {
println!("{}", w);
}
Expand Down Expand Up @@ -264,14 +265,13 @@ fn recall_program(content: &str, entries: &ProgramEntries, settings: &CLIOptions
let warnings = check_warnings.to_owned().into_inner();
throw_on_warnings(&warnings)?;
}
let v = calcit_runner::run_program(entries.reload_ns.to_owned(), entries.reload_def.to_owned(), FingerList::new_empty()).map_err(
|e| {
let v =
calcit_runner::run_program(entries.reload_ns.to_owned(), entries.reload_def.to_owned(), TernaryTreeList::Empty).map_err(|e| {
for w in e.warnings {
println!("{}", w);
}
e.msg
},
)?;
})?;
let duration = Instant::now().duration_since(started_time);
println!("took {}ms: {}", duration.as_micros() as f64 / 1000.0, v);
Ok(())
Expand Down
14 changes: 8 additions & 6 deletions src/bin/injection/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@ use cirru_edn::Edn;
use std::sync::Arc;
use std::thread;

use im_ternary_tree::TernaryTreeList;

use calcit_runner::{
builtins,
call_stack::{display_stack, CallStackList},
data::edn::{calcit_to_edn, edn_to_calcit},
primes::{finger_list::FingerList, Calcit, CalcitErr, CalcitItems, CrListWrap},
primes::{Calcit, CalcitErr, CalcitItems, CrListWrap},
runner::track,
};

Expand Down Expand Up @@ -137,9 +139,9 @@ pub fn call_dylib_edn_fn(xs: &CalcitItems, call_stack: &CallStackList) -> Result
def_ns, scope, args, body, ..
} = &callback
{
let mut real_args = FingerList::new_empty();
let mut real_args = TernaryTreeList::Empty;
for p in ps {
real_args = real_args.push(edn_to_calcit(&p));
real_args = real_args.push_right(edn_to_calcit(&p));
}
let r = runner::run_fn(&real_args, scope, args, body, def_ns.to_owned(), &copied_stack);
match r {
Expand Down Expand Up @@ -225,9 +227,9 @@ pub fn blocking_dylib_edn_fn(xs: &CalcitItems, call_stack: &CallStackList) -> Re
def_ns, scope, args, body, ..
} = &callback
{
let mut real_args = FingerList::new_empty();
let mut real_args = TernaryTreeList::Empty;
for p in ps {
real_args = real_args.push(edn_to_calcit(&p));
real_args = real_args.push_right(edn_to_calcit(&p));
}
let r = runner::run_fn(&real_args, scope, args, body, def_ns.to_owned(), &copied_stack.clone());
match r {
Expand Down Expand Up @@ -267,7 +269,7 @@ pub fn on_ctrl_c(xs: &CalcitItems, call_stack: &CallStackList) -> Result<Calcit,
def_ns, scope, args, body, ..
} = cb.as_ref()
{
if let Err(e) = runner::run_fn(&FingerList::new_empty(), scope, args, body, def_ns.to_owned(), &copied_stack) {
if let Err(e) = runner::run_fn(&TernaryTreeList::Empty, scope, args, body, def_ns.to_owned(), &copied_stack) {
println!("error: {}", e);
}
}
Expand Down
Loading

0 comments on commit 01d2978

Please sign in to comment.