File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 5353(def ^:dynamic *load-macros* true )
5454(def ^:dynamic *reload-macros* false )
5555(def ^:dynamic *macro-infer* true )
56-
56+ ( def ^:dynamic *passes* nil )
5757(def ^:dynamic *file-defs* nil )
5858
5959(def constants-ns-sym
12891289(defn valid-proto [x]
12901290 (when (symbol? x) x))
12911291
1292+ (defn elide-env [env ast opts]
1293+ (dissoc ast :env ))
1294+
1295+ (defn constant-value?
1296+ [{:keys [op] :as ast}]
1297+ (or (= :constant op)
1298+ (and (#{:map :set :vector :list } op)
1299+ (every? constant-value? (:children ast)))))
1300+
12921301(defmethod parse 'def
12931302 [op env form _ _]
12941303 (when (> (count form) 4 )
13831392 f))))}
13841393 (when doc {:doc doc})
13851394 (when const?
1386- {:const-init (:init args)})
1395+ (let [const-expr
1396+ (binding [*passes* (conj *passes* elide-env)]
1397+ (analyze env (:init args)))]
1398+ (when (constant-value? const-expr)
1399+ {:const-expr const-expr})))
13871400 (when (true ? dynamic) {:dynamic true })
13881401 (source-info var-name env)
13891402 ; ; the protocol a protocol fn belongs to
29192932 (if-not (true ? (:def-var env))
29202933 (merge
29212934 (assoc ret :op :var :info info)
2922- (when-let [const-init (:const-init info)]
2923- {:const-expr ( analyze env const-init) }))
2935+ (when-let [const-expr (:const-expr info)]
2936+ {:const-expr const-expr }))
29242937 (let [info (resolve-var env sym)]
29252938 (assoc ret :op :var :info info))))))))
29262939
32023215 ast)))
32033216 ast)))
32043217
3205- (def ^:dynamic *passes* nil )
3206-
32073218#?(:clj
32083219 (defn analyze-form [env form name opts]
32093220 (load-core )
You can’t perform that action at this time.
0 commit comments