sdfsdfs
This commit is contained in:
@@ -7,27 +7,30 @@
|
||||
[emptyhead.contract.eval :as contract]
|
||||
[emptyhead.util.magic :as magic]))
|
||||
|
||||
;; TODO groups
|
||||
(defn make-thought
|
||||
"Helper function to make thought object.
|
||||
You may want `register-thought!` instead."
|
||||
[operator & {:keys [data ext-contract ext-stages transient]
|
||||
:or {data {} ext-contract {}
|
||||
ext-stages [[:thought operator]]
|
||||
ext-stages [[:thought operator :pre] [:thought operator]
|
||||
[:PRE-EXECUTE] [:EXECUTE] [:POST-EXECUTE]
|
||||
[:thought operator :post]]
|
||||
transient true}}]
|
||||
(hash-map :operator operator
|
||||
:data data
|
||||
:ext-contract ext-contract
|
||||
:ext-stages ext-stages
|
||||
:return {}
|
||||
:return []
|
||||
:transient (not (false? transient))))
|
||||
|
||||
(defn register-thought!
|
||||
"Create a thought and register it in the state.
|
||||
Returns a reference to the created thought."
|
||||
[operator & {:keys [data ext-contract ext-stages transient]
|
||||
[operator & {:keys [data ext-contract ext-stages transient group]
|
||||
:as args}]
|
||||
(idea/have-idea!
|
||||
:prefix (str "thought_" (magic/symbolize-ns operator) "_")
|
||||
:prefix (str "emptyhead.thought#" (magic/symbolize-ns operator))
|
||||
:properties [magic/thought-ns]
|
||||
:data (make-thought operator args)))
|
||||
|
||||
@@ -48,3 +51,22 @@
|
||||
Returns the operator keyword."
|
||||
[thought]
|
||||
(prtc/val-fn :operator thought))
|
||||
|
||||
(defn data
|
||||
"Get the data field of a `thought`."
|
||||
[thought]
|
||||
(prtc/val-fn :data thought))
|
||||
|
||||
(defn stack
|
||||
[thought]
|
||||
(prtc/val-fn :return thought))
|
||||
|
||||
(defn pop-stack
|
||||
[thought]
|
||||
[(assoc thought :return (-> thought prtc/copy stack butlast vec)) (-> thought prtc/copy stack peek)])
|
||||
|
||||
(def root-thought (make-thought :root))
|
||||
|
||||
(defn add-ext-stage!
|
||||
[thought stage]
|
||||
(idea/mutate-idea! #(update % :ext-stages conj stage) thought))
|
||||
|
Reference in New Issue
Block a user