Skip to content
This repository was archived by the owner on Jan 2, 2023. It is now read-only.

Commit 0add062

Browse files
committed
vector
1 parent 99d567c commit 0add062

File tree

5 files changed

+19
-5
lines changed

5 files changed

+19
-5
lines changed

cherry/corpus/core_vars.cljs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,7 @@
99
(js/console.log (get clj-map :foo/bar)) ;; => 6
1010

1111
(js/console.log (str clj-map))
12+
13+
(def log js/console.log)
14+
15+
(log (first [1 2 3]))

cherry/corpus/core_vars.mjs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
import { toJs, get, keyword, str, arrayMap } from 'cherry-cljs/cljs.core.js'
1+
import { toJs, first, get, vector, keyword, str, arrayMap } from 'cherry-cljs/cljs.core.js'
22

33
const js_map = toJs(arrayMap(keyword("foo"), keyword("bar")));
44
console.log(js_map);
55
const clj_map = arrayMap(keyword("foo/bar"), (1 + 2 + 3));
66
console.log(get(clj_map, keyword("foo/bar")));
77
console.log(str(clj_map));
8+
const log = console.log;
9+
log(first(vector(1, 2, 3)));

cherry/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"type": "module",
33
"name": "cherry-cljs",
44
"sideEffects": false,
5-
"version": "0.0.0-alpha.5",
5+
"version": "0.0.0-alpha.6",
66
"files": [
77
"cljs.core.js",
88
"lib/cljs_core.js"

cherry/shadow-cljs.edn

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,13 @@
2020
conj cljs.core/conj
2121
get cljs.core/get
2222
arrayMap cljs.core/array-map
23-
hashMap cljs.core/hash-map}}
23+
hashMap cljs.core/hash-map
24+
first cljs.core/first
25+
rest cljs.core/rest
26+
next cljs.core/next
27+
nth cljs.core/nth
28+
seq cljs.core/seq
29+
}}
2430
#_#_:transpiler {}}
2531
:build-hooks [(shadow.cljs.build-report/hook
2632
{:output-to "report.html"})]}}}

cherry/src/cherry/transpiler.clj

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,8 @@
9999
'await 'const 'defn 'let 'ns 'def]))
100100

101101
(def core-vars (set '[map assoc str keyword symbol
102-
dissoc conj vector clj->js js->clj get]))
102+
dissoc conj vector clj->js js->clj get
103+
hash-map array-map first rest next nth seq]))
103104

104105
(def core->js '{clj->js toJs
105106
js->cljs toCljs
@@ -400,7 +401,8 @@
400401
(throw (new Exception (str "invalid form: " expr))))))
401402

402403
(defmethod emit clojure.lang.IPersistentVector [expr]
403-
(str "[" (str/join ", " (map emit expr)) "]"))
404+
(swap! *imported-core-vars* conj 'vector)
405+
(format "vector(%s)" (str/join ", " (map emit expr))))
404406

405407
(defmethod emit clojure.lang.LazySeq [expr]
406408
(emit (into [] expr)))

0 commit comments

Comments
 (0)