Skip to content

Instantly share code, notes, and snippets.

@Sophia-Gold
Created May 1, 2018 14:00
Show Gist options
  • Save Sophia-Gold/b838ee9e2b2da5d11700ba7d3fec0fa2 to your computer and use it in GitHub Desktop.
Save Sophia-Gold/b838ee9e2b2da5d11700ba7d3fec0fa2 to your computer and use it in GitHub Desktop.
Disassembling with Continuations
(ns core.clj
(:require [clojure.string :as str]
[fipp.edn :refer [pprint] :rename {pprint fipp}]
[com.positronic-solutions.pulley.cps :refer :all]
[no.disassemble :refer :all]))
(defn stacks []
(->> disassemble
call-cc
str/split-lines
(filter #(re-find #"Stack" %))
(map (comp (fn [s] (map #(Long/parseLong (re-find #"\d+" %)) s))
#(str/split % #",")))
(map #(zipmap [:stack :locals] %))
(sort-by :stack)
fipp))
(defn get-cc []
(call-cc
(fn [cc]
#(cc (conj [] %)))))
(defn read-cc []
(-> (get-cc)
disassemble-data
fipp))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment