From 8e266ee6c1bd4fbd502580dec9bbfef2075abe20 Mon Sep 17 00:00:00 2001 From: Jonas Enlund Date: Sun, 27 May 2012 17:32:10 +0300 Subject: [PATCH] added :do --- src/scape/core.clj | 18 ++++++++++++------ src/scape/emitter.clj | 6 +++++- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/src/scape/core.clj b/src/scape/core.clj index cae7b5d..61a67f0 100644 --- a/src/scape/core.clj +++ b/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") @@ -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 diff --git a/src/scape/emitter.clj b/src/scape/emitter.clj index 6d4d4d0..0bcd66e 100644 --- a/src/scape/emitter.clj +++ b/src/scape/emitter.clj @@ -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}]