-
-
Save samth/2481092 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn analysis->map | |
"Convert Java Object expr into nested maps" | |
; result type: | |
; (rec X (U {:op :def | |
; :env {:source Object | |
; :line Object} | |
; :var Var} | |
; {:op :if | |
; :env {:source Object | |
; :line Object} | |
; :test X | |
; :then X | |
; :else X} | |
; ... } | |
[expr] | |
(cond | |
(Def? expr) {:op :def | |
:env {:source (.source expr) | |
:line (.line expr)} | |
:var (.var expr)} | |
(If? expr) {:op :if | |
:env {:source (.source expr) | |
:line (.line expr)} | |
:test (analysis->map (.test expr)) | |
:then (analysis->map (.then expr)) | |
:else (analysis->map (.else expr))} | |
... | |
)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment