File tree Expand file tree Collapse file tree 3 files changed +801
-1
lines changed Expand file tree Collapse file tree 3 files changed +801
-1
lines changed Original file line number Diff line number Diff line change 342342 (emit-meta-constant x
343343 (persistent-vector-emit-seq names)))))
344344
345+ (defn- persistent-hash-map-emit-kv-pairs [keys vals]
346+ (letfn [(emit-assoc [keys vals]
347+ (if (empty? keys)
348+ (emits " VAR_NAME (cljc_DOT_core_DOT_PersistentHashMap_SLASH_EMPTY)" )
349+ (do
350+ (emits " FUNCALL3 ((closure_t*)VAR_NAME (cljc_DOT_core_SLASH__assoc), " )
351+ (emit-assoc (next keys)(next vals))
352+ (emits " , " (first keys))
353+ (emits " , " (first vals) " )" ))))]
354+ (emit-assoc (reverse keys) (reverse vals))))
355+
345356(defmethod emit-constant clojure.lang.IPersistentMap [x]
346357 (FIXME-IMPLEMENT ))
347358
402413
403414(defmethod emit :map
404415 [{:keys [env simple-keys? keys vals]}]
405- (FIXME-IMPLEMENT ))
416+ (let [keys (doall (map emit keys))
417+ vals (doall (map emit vals))]
418+ (emit-value-wrap :map env
419+ (emits (persistent-hash-map-emit-kv-pairs keys vals)))))
406420
407421(defmethod emit :vector
408422 [{:keys [items env]}]
Original file line number Diff line number Diff line change 305305 ; ; FIXME: see bit-clear
306306 (list 'c* " make_integer (integer_get (~{}) | (1ul << integer_get (~{})))" x n))
307307
308+ ; ; internal
309+ (defmacro mask [hash shift]
310+ (list 'c* " make_integer (((integer_get (~{}) >> integer_get (~{})) & 0x01f)) " hash shift))
311+
312+ ; ; internal
313+ (defmacro bitpos [hash shift]
314+ (list 'c* " make_integer ((1 << integer_get (~{})))" `(mask ~hash ~shift)))
315+
316+ ; ;internal
317+ (defmacro bit-count [num]
318+ (list 'c* " make_integer (__builtin_popcountll(integer_get (~{})))" num))
319+
320+ ; ;internal
321+ (defmacro bit-index [bitmap bitpos]
322+ (list 'c* " make_integer (__builtin_popcountll(integer_get (~{}) & (integer_get (~{}) - 1)))" bitmap bitpos))
323+
308324; ; internal
309325(defmacro caching-hash [coll hash-fn hash-key]
310326 `(let [h# ~hash-key]
You can’t perform that action at this time.
0 commit comments