rearrange code for bootstrap compatibility
This commit is contained in:
parent
ecda5e2cff
commit
85b91d19c4
2 changed files with 11 additions and 27 deletions
|
|
@ -48,29 +48,17 @@
|
||||||
(defn throw-illegal [& args]
|
(defn throw-illegal [& args]
|
||||||
(throw (js/Error. (apply str args))))
|
(throw (js/Error. (apply str args))))
|
||||||
|
|
||||||
|
;; need to get the expansion function like this so that
|
||||||
|
;; this code compiles in a clojure environment where cljs.analyzer
|
||||||
|
;; namespace does not exist
|
||||||
|
#+clj
|
||||||
|
(defn cljs-analyzer-macroexpand-1 []
|
||||||
|
(eval 'cljs.analyzer/macroexpand-1))
|
||||||
|
|
||||||
;; these macroexpand functions are for path macro in bootstrap cljs environment
|
;; this version is for bootstrap cljs
|
||||||
; #+cljs
|
#+cljs
|
||||||
; (defn macroexpand'
|
(defn cljs-analyzer-macroexpand-1 []
|
||||||
; [form]
|
^:cljs.analyzer/no-resolve cljs.analyzer/macroexpand-1)
|
||||||
; (let [orig-eval-fn ^:cljs.analyzer/no-resolve cljs.js/*eval-fn*]
|
|
||||||
; (try
|
|
||||||
; (set! ^:cljs.analyzer/no-resolve cljs.js/*eval-fn* ^:cljs.analyzer/no-resolve cljs.js/js-eval)
|
|
||||||
; (^:cljs.analyzer/no-resolve cljs.js/eval (^:cljs.analyzer/no-resolve cljs.js/empty-state)
|
|
||||||
; `(macroexpand (quote ~form))
|
|
||||||
; identity)
|
|
||||||
; (finally
|
|
||||||
; (set! ^:cljs.analyzer/no-resolve cljs.js/*eval-fn* orig-eval-fn)))))
|
|
||||||
|
|
||||||
; #+cljs
|
|
||||||
; (defn do-macroexpand-all
|
|
||||||
; "Recursively performs all possible macroexpansions in form."
|
|
||||||
; {:added "1.1"}
|
|
||||||
; [form]
|
|
||||||
; (walk/prewalk (fn [x]
|
|
||||||
; (if (seq? x)
|
|
||||||
; (macroexpand' x)
|
|
||||||
; x)) form))
|
|
||||||
|
|
||||||
#+clj
|
#+clj
|
||||||
(defn clj-macroexpand-all [form]
|
(defn clj-macroexpand-all [form]
|
||||||
|
|
|
||||||
|
|
@ -445,11 +445,7 @@
|
||||||
)))
|
)))
|
||||||
|
|
||||||
(defn cljs-macroexpand [env form]
|
(defn cljs-macroexpand [env form]
|
||||||
(require 'cljs.analyzer)
|
(let [expand-fn (i/cljs-analyzer-macroexpand-1)
|
||||||
;; need to get the expansion function like this so that
|
|
||||||
;; this code compiles in a clojure environment where cljs.analyzer
|
|
||||||
;; namespace does not exist
|
|
||||||
(let [expand-fn (eval 'cljs.analyzer/macroexpand-1)
|
|
||||||
mform (expand-fn env form)]
|
mform (expand-fn env form)]
|
||||||
(cond (identical? form mform) mform
|
(cond (identical? form mform) mform
|
||||||
(and (seq? mform) (#{'js*} (first mform))) form
|
(and (seq? mform) (#{'js*} (first mform))) form
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue