/docs/cache-cljs/cljs_SLASH_analyzer_SLASH_macros.clj

https://github.com/viebel/klipse · Clojure · 56 lines · 40 code · 9 blank · 7 comment · 5 complexity · 06e11b6dd2675dd38490240b2534e628 MD5 · raw file

  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. (ns cljs.analyzer.macros
  9. (:refer-clojure :exclude [binding]))
  10. (defmacro with-warning-handlers [handlers & body]
  11. `(cljs.core/binding [cljs.analyzer/*cljs-warning-handlers* ~handlers]
  12. ~@body))
  13. (defmacro no-warn [& body]
  14. `(cljs.core/binding [cljs.analyzer/*cljs-warnings*
  15. (zipmap (keys cljs.analyzer/*cljs-warnings*) (repeat false))]
  16. ~@body))
  17. (defmacro with-core-macros
  18. [path & body]
  19. `(do
  20. (when (not= cljs.analyzer/*cljs-macros-path* ~path)
  21. (reset! cljs.analyzer/-cljs-macros-loaded false))
  22. (cljs.core/binding [cljs.analyzer/*cljs-macros-path* ~path]
  23. ~@body)))
  24. (defmacro with-core-macros-file
  25. [path & body]
  26. `(do
  27. (when (not= cljs.analyzer/*cljs-macros-path* ~path)
  28. (reset! cljs.analyzer/-cljs-macros-loaded false))
  29. (cljs.core/binding [cljs.analyzer/*cljs-macros-path* ~path
  30. cljs.analyzer/*cljs-macros-is-classpath* false]
  31. ~@body)))
  32. (defmacro wrapping-errors [env & body]
  33. `(try
  34. ~@body
  35. (catch :default err#
  36. (if (cljs.analyzer/analysis-error? err#)
  37. (throw err#)
  38. (throw (cljs.analyzer/error ~env (.-message err#) err#))))))
  39. (defmacro disallowing-recur [& body]
  40. `(cljs.core/binding [cljs.analyzer/*recur-frames*
  41. (cons nil cljs.analyzer/*recur-frames*)]
  42. ~@body))
  43. (defmacro allowing-redef [& body]
  44. `(cljs.core/binding [cljs.analyzer/*allow-redef* true]
  45. ~@body))
  46. (defmacro disallowing-ns* [& body]
  47. `(cljs.core/binding [cljs.analyzer/*allow-ns* false] ~@body))