Skip to content

Commit

Permalink
Merge pull request #102 from calcit-lang/fix-formatter
Browse files Browse the repository at this point in the history
fix record field displaying in custom formatter
  • Loading branch information
soyaine authored Oct 11, 2021
2 parents 7ae9f2a + acd4c22 commit 57767ce
Show file tree
Hide file tree
Showing 8 changed files with 1,385 additions and 759 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

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

4 changes: 3 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "calcit_runner"
version = "0.5.0-a3"
version = "0.5.0-a4"
authors = ["jiyinyiyong <jiyinyiyong@gmail.com>"]
edition = "2018"
license = "MIT"
Expand Down Expand Up @@ -28,6 +28,8 @@ im = "15.0.0"
lazy_static = "1.4.0"
notify = "4.0.17"
walkdir = "2"

[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
libloading = "0.7"

[lib]
Expand Down
2,030 changes: 1,327 additions & 703 deletions calcit/calcit.cirru

Large diffs are not rendered by default.

100 changes: 49 additions & 51 deletions calcit/compact.cirru
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,26 @@
:modules $ []
:version |0.0.1
:files $ {}
|app.lib $ {}
:ns $ quote (ns app.lib)
:defs $ {}
|f2 $ quote
defn f2 () $ echo "\"f2 in lib"
|f3 $ quote
defn f3 (x) (echo "\"f3 in lib") (echo "\"v:" x)
|app.macro $ {}
:ns $ quote (ns app.macro)
:defs $ {}
|add-by-1 $ quote
defmacro add-by-1 (x)
quasiquote $ &+ ~x 1
|add-by-2 $ quote
defmacro add-by-2 (x)
quasiquote $ &+ 2 (add-by-1 ~x)
|add-num $ quote
defmacro add-num (a b)
quasiquote $ &let nil
&+ (~ a) (~ b)
|app.main $ {}
:ns $ quote
ns app.main $ :require (app.lib :as lib)
Expand All @@ -14,10 +34,29 @@
defmacro call-macro (x0 & xs)
quasiquote $ &{} :a (~ x0) :b
[] $ ~@ xs
|call-3 $ quote
defn call-3 (a b c) (echo "\"a is:" a) (echo "\"b is:" b) (echo "\"c is:" c)
|main! $ quote
defn main! () (demos) (; fib 10) (try-method)
|show-data $ quote
defn show-data () (load-console-formatter!)
js/console.log $ defrecord! :Demo (:a 1)
:b $ {} (:a 1)
|fib $ quote
defn fib (n)
if (< n 2) 1 $ +
fib $ - n 1
fib $ - n 2
|add-more $ quote
defmacro add-more (acc x times)
if (&< times 1) acc $ recur
quasiquote $ &+ (~ x) (~ acc)
, x (&- times 1)
|test-args $ quote
defn test-args ()
call-3 & $ [] 1 2 3
call-many 1
call-many 1 2
call-many 1 2 3
echo $ macroexpand (call-macro 11 12 13)
|call-many $ quote
defn call-many (x0 & xs) (echo "\"many...") (echo "\"x0" x0) (echo "\"xs" xs)
|demos $ quote
defn demos () (echo "\"demo")
echo $ &+ 2 2
Expand Down Expand Up @@ -55,60 +94,19 @@
echo "\"call and call" $ add-by-2 10
; echo $ macroexpand (assert= 1 2)
test-args
|call-many $ quote
defn call-many (x0 & xs) (echo "\"many...") (echo "\"x0" x0) (echo "\"xs" xs)
|main! $ quote
defn main! () (demos) (; fib 10) (try-method) (; show-data)
|f1 $ quote
defn f1 () $ echo "\"calling f1"
|try-method $ quote
defn try-method () $ println
.count $ range 11
|call-3 $ quote
defn call-3 (a b c) (echo "\"a is:" a) (echo "\"b is:" b) (echo "\"c is:" c)
|rec-sum $ quote
defn rec-sum (acc xs)
if (empty? xs) acc $ recur
&+ acc $ nth xs 0
rest xs
|test-args $ quote
defn test-args ()
call-3 & $ [] 1 2 3
call-many 1
call-many 1 2
call-many 1 2 3
echo $ macroexpand (call-macro 11 12 13)
|fib $ quote
defn fib (n)
if (< n 2) 1 $ +
fib $ - n 1
fib $ - n 2
|f1 $ quote
defn f1 () $ echo "\"calling f1"
|reload! $ quote
defn reload! () (println "\"reloaded 2") (; fib 40) (try-method)
|add-more $ quote
defmacro add-more (acc x times)
if (&< times 1) acc $ recur
quasiquote $ &+ (~ x) (~ acc)
, x (&- times 1)
:proc $ quote ()
:configs $ {}
|app.lib $ {}
:ns $ quote (ns app.lib)
:defs $ {}
|f2 $ quote
defn f2 () $ echo "\"f2 in lib"
|f3 $ quote
defn f3 (x) (echo "\"f3 in lib") (echo "\"v:" x)
:proc $ quote ()
:configs $ {}
|app.macro $ {}
:ns $ quote (ns app.macro)
:defs $ {}
|add-num $ quote
defmacro add-num (a b)
quasiquote $ &let nil
&+ (~ a) (~ b)
|add-by-1 $ quote
defmacro add-by-1 (x)
quasiquote $ &+ ~x 1
|add-by-2 $ quote
defmacro add-by-2 (x)
quasiquote $ &+ 2 (add-by-1 ~x)
:proc $ quote ()
:configs $ {}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@calcit/procs",
"version": "0.5.0-a3",
"version": "0.5.0-a4",
"main": "./lib/calcit.procs.js",
"devDependencies": {
"@types/node": "^16.9.6",
Expand Down
2 changes: 2 additions & 0 deletions src/bin/cr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use std::sync::mpsc::channel;
use std::time::Duration;
use std::time::Instant;

#[cfg(not(target_arch = "wasm32"))]
mod injection;

use notify::{RecommendedWatcher, RecursiveMode, Watcher};
Expand All @@ -25,6 +26,7 @@ fn main() -> Result<(), String> {
builtins::effects::init_effects_states();

// get dirty functions injected
#[cfg(not(target_arch = "wasm32"))]
builtins::register_import_proc("&call-dylib-edn", injection::call_dylib_edn);

let cli_matches = cli_args::parse_cli();
Expand Down
2 changes: 1 addition & 1 deletion ts-src/calcit.procs.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// CALCIT VERSION
export const calcit_version = "0.5.0-a3";
export const calcit_version = "0.5.0-a4";

import { overwriteComparator, initTernaryTreeMap } from "@calcit/ternary-tree";
import { parse, ICirruNode } from "@cirru/parser.ts";
Expand Down
2 changes: 1 addition & 1 deletion ts-src/custom-formatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export let load_console_formatter_$x_ = () => {
ret.push([
"div",
{ style: "margin-left: 8px;" },
["div", { style: "margin-left: 8px; display: inline-block;" }, obj.fields[idx]],
["div", { style: "margin-left: 8px; display: inline-block;" }, embedObject(obj.fields[idx])],
["div", { style: "margin-left: 8px; display: inline-block;" }, embedObject(obj.values[idx])],
]);
}
Expand Down

0 comments on commit 57767ce

Please sign in to comment.