Skip to content

Commit

Permalink
added :do
Browse files Browse the repository at this point in the history
  • Loading branch information
jonase committed May 27, 2012
1 parent 023eabe commit 8e266ee
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
18 changes: 12 additions & 6 deletions src/scape/core.clj
@@ -1,10 +1,9 @@
(ns scape.core
(:require [datomic.api :refer [db q] :as d]
[scape.emitter :refer [emit-transaction-data]]
[scape.analyze :refer [analyze-file ast-seq op= default-env]]
[scape.analyze :refer [analyze-file]]
[scape.schema :refer [schema]]
[clojure.pprint :refer [pprint]]))


(comment
(def uri "datomic:mem://ast")
Expand All @@ -17,12 +16,19 @@
(d/transact conn schema)

(doseq [ast (analyze-file "cljs/core.cljs")]
(println "Transacting " (:op ast))
(let [tdata (emit-transaction-data ast)]
;; (pprint tdata)
(d/transact conn tdata))
(println "Done."))
(d/transact conn tdata)))

;; how many transactions? i.e., top level forms
(count (analyze-file "cljs/core.cljs"))
;; 502

;; How many datoms is the above?
(->> (analyze-file "cljs/core.cljs")
(mapcat emit-transaction-data)
count)
;; 142955 facts about cljs.core!

;; How many ast nodes are there in core.cljs?
(count (q '[:find ?e
:where
Expand Down
6 changes: 5 additions & 1 deletion src/scape/emitter.clj
Expand Up @@ -87,7 +87,11 @@
:transaction (concat (emit-common entity-id ast)
method-txs)}))


(defmethod emit :do [ast]
(let [entity-id (id)]
{:entity-id entity-id
:transaction (concat (emit-common entity-id ast)
(emit-block entity-id ast))}))

(defmethod emit :constant
[{:keys [form] :as ast}]
Expand Down

0 comments on commit 8e266ee

Please sign in to comment.