Skip to content

Instantly share code, notes, and snippets.

@samth
Forked from frenchy64/map_as_obj.clj
Created April 24, 2012 16:13
Show Gist options
  • Save samth/2481092 to your computer and use it in GitHub Desktop.
Save samth/2481092 to your computer and use it in GitHub Desktop.
(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