Created
April 15, 2010 04:06
-
-
Save mikedouglas/366667 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 lookup-lbl [prog] | |
(into {} | |
(for [lbl (-> prog count range) | |
:when (isit? (prog lbl) :minijava.gas/LABEL)] | |
[(:lbl (prog lbl)) lbl]))) | |
(defn flow [prog] | |
(let [lookup (lookup-lbl prog)] | |
(for [i (range (count prog))] | |
(let [instr (prog i)] | |
(cond | |
(isit? instr :minijava.gas/jmp) (lookup (:dst instr)) | |
(isit? instr :minijava.gas/jcc) [(inc i) (lookup (:dst instr))] | |
:else (inc i)))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment