Skip to content

Commit f67fb7b

Browse files
committed
sketch for vector and vec replace compiler passes
1 parent 2d34791 commit f67fb7b

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
;; Copyright (c) Rich Hickey. All rights reserved.
2+
;; The use and distribution terms for this software are covered by the
3+
;; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)
4+
;; which can be found in the file epl-v10.html at the root of this distribution.
5+
;; By using this software in any fashion, you are agreeing to be bound by
6+
;; the terms of this license.
7+
;; You must not remove this notice, or any other, from this software.
8+
9+
(ns cljs.analyzer.passes.lite)
10+
11+
(defn var? [ast]
12+
(= :var (:op ast)))
13+
14+
(def replace
15+
'{cljs.core/vector cljs.core/simple-vector
16+
cljs.core/vec cljs.core/simple-vec})
17+
18+
(defn update-var [{:keys [name] :as ast}]
19+
(update-in ast :name (get replace name)))
20+
21+
(defn replace-var? [ast]
22+
(and (var? ast)
23+
(contains? replace (:name ast))))
24+
25+
(defn use-lite-types
26+
[env ast _]
27+
(cond-> ast
28+
(replace-var? ast) update-var))

0 commit comments

Comments
 (0)