-
-
Notifications
You must be signed in to change notification settings - Fork 148
/
Copy pathcljs_SLASH_analyzer_SLASH_macros.clj
56 lines (47 loc) · 1.97 KB
/
cljs_SLASH_analyzer_SLASH_macros.clj
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
; Copyright (c) Rich Hickey. All rights reserved.
; The use and distribution terms for this software are covered by the
; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)
; which can be found in the file epl-v10.html at the root of this distribution.
; By using this software in any fashion, you are agreeing to be bound by
; the terms of this license.
; You must not remove this notice, or any other, from this software.
(ns cljs.analyzer.macros
(:refer-clojure :exclude [binding]))
(defmacro with-warning-handlers [handlers & body]
`(cljs.core/binding [cljs.analyzer/*cljs-warning-handlers* ~handlers]
~@body))
(defmacro no-warn [& body]
`(cljs.core/binding [cljs.analyzer/*cljs-warnings*
(zipmap (keys cljs.analyzer/*cljs-warnings*) (repeat false))]
~@body))
(defmacro with-core-macros
[path & body]
`(do
(when (not= cljs.analyzer/*cljs-macros-path* ~path)
(reset! cljs.analyzer/-cljs-macros-loaded false))
(cljs.core/binding [cljs.analyzer/*cljs-macros-path* ~path]
~@body)))
(defmacro with-core-macros-file
[path & body]
`(do
(when (not= cljs.analyzer/*cljs-macros-path* ~path)
(reset! cljs.analyzer/-cljs-macros-loaded false))
(cljs.core/binding [cljs.analyzer/*cljs-macros-path* ~path
cljs.analyzer/*cljs-macros-is-classpath* false]
~@body)))
(defmacro wrapping-errors [env & body]
`(try
~@body
(catch :default err#
(if (cljs.analyzer/analysis-error? err#)
(throw err#)
(throw (cljs.analyzer/error ~env (.-message err#) err#))))))
(defmacro disallowing-recur [& body]
`(cljs.core/binding [cljs.analyzer/*recur-frames*
(cons nil cljs.analyzer/*recur-frames*)]
~@body))
(defmacro allowing-redef [& body]
`(cljs.core/binding [cljs.analyzer/*allow-redef* true]
~@body))
(defmacro disallowing-ns* [& body]
`(cljs.core/binding [cljs.analyzer/*allow-ns* false] ~@body))