File tree Expand file tree Collapse file tree 1 file changed +28
-2
lines changed Expand file tree Collapse file tree 1 file changed +28
-2
lines changed Original file line number Diff line number Diff line change 525
525
(defn lite-mode? []
526
526
(get-in @env/*compiler* [:options :lite-mode ]))
527
527
528
+ (defn obj-map-key [x]
529
+ (if (keyword? x)
530
+ (str \" " \\ uFDD0" \'
531
+ (if (namespace x)
532
+ (str (namespace x) " /" ) " " )
533
+ (name x)
534
+ \")
535
+ x))
536
+
537
+ (defn emit-obj-map [str-keys vals comma-sep distinct-keys?]
538
+ (if (zero? (count str-keys))
539
+ (emits " cljs.core.ObjMap.EMPTY" )
540
+ (emits " cljs.core.ObjMap.fromObject([" (comma-sep str-keys) " ], {"
541
+ (comma-sep (map (fn [k v] (str k " :" (emit-str v))) str-keys vals))
542
+ " })" )))
543
+
544
+ (defn emit-lite-map [keys vals comma-sep distinct-keys?]
545
+ (if (zero? (count keys))
546
+ (emits " cljs.core.HashMap.EMPTY" )
547
+ (emits " cljs.core.HashMap.fromArrays([" (comma-sep keys) " ], [" (comma-sep vals) " ])" )))
548
+
528
549
(defn emit-map [keys vals comma-sep distinct-keys?]
529
550
(cond
530
551
(zero? (count keys))
547
568
" ])" )))
548
569
549
570
(defmethod emit* :map
550
- [{:keys [env keys vals]}]
571
+ [{:keys [env form keys vals]}]
551
572
(emit-wrap env
552
- (emit-map keys vals comma-sep distinct-keys?)))
573
+ (if (lite-mode? )
574
+ (let [form-keys (clojure.core/keys form)]
575
+ (if (every? #(or (string? %) (keyword? %)) form-keys)
576
+ (emit-obj-map (map obj-map-key form-keys) vals comma-sep distinct-keys?)
577
+ (emit-lite-map keys vals comma-sep distinct-keys?)))
578
+ (emit-map keys vals comma-sep distinct-keys?))))
553
579
554
580
(defn emit-list [items comma-sep]
555
581
(if (empty? items)
You can’t perform that action at this time.
0 commit comments