Skip to content

Commit 77d6c77

Browse files
committed
Emit constant sets.
1 parent 186b40e commit 77d6c77

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

src/clj/cljc/compiler.clj

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -365,8 +365,18 @@
365365
(emit-meta-constant x
366366
(persistent-hash-map-emit-kv-pairs key-names val-names)))))
367367

368+
(defn- persistent-hash-set-emit-seq [items]
369+
(emit-seq-construction items
370+
"VAR_NAME (cljc_DOT_core_DOT_PersistentHashSet_SLASH_EMPTY)"
371+
"FUNCALL2 ((closure_t*)VAR_NAME (cljc_DOT_core_SLASH__conj), "
372+
#(emits ", " %)
373+
")"))
374+
368375
(defmethod emit-constant clojure.lang.PersistentHashSet [x]
369-
(FIXME-IMPLEMENT))
376+
(let [names (doall (map emit-constant x))]
377+
(emit-value-wrap :const-map nil
378+
(emit-meta-constant x
379+
(persistent-hash-set-emit-seq names)))))
370380

371381
(defmacro emit-declaration [& body]
372382
`(swap! declarations conj (with-out-str ~@body)))

test/clojurec/core_test.clj

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -286,9 +286,11 @@
286286

287287
(deftest constants
288288
(testing "constants"
289-
(is (= (core-run '(pr (count '[(1 2)
290-
{3 4}])))
291-
2))))
289+
(is (= (core-run '(pr '(1 2)
290+
(let [m '{3 4 5 6}]
291+
(list (keys m) (vals m)))
292+
(map identity '#{7 8})))
293+
'[(1 2) ((3 5) (4 6)) (7 8)]))))
292294

293295
(deftest loops
294296
(testing "simple loops"

0 commit comments

Comments
 (0)