Draft changes.
This commit is contained in:
parent
90c97e7cfe
commit
c2943e0ba7
|
@ -426,4 +426,4 @@
|
|||
:floor floor
|
||||
:round round
|
||||
:range range-
|
||||
})
|
||||
})
|
||||
|
|
|
@ -664,16 +664,21 @@
|
|||
)
|
||||
))
|
||||
|
||||
(def state (atom {})) ;; for now use a global state atom
|
||||
|
||||
(defn- interpret-ref [ast ctx]
|
||||
(let [data (:data ast)
|
||||
name (-> data first :data first)
|
||||
expr (-> data second)]
|
||||
(when (contains? @ctx name)
|
||||
(throw (ex-info (str "Name " name " is already bound") {:ast ast})))
|
||||
(when (contains? @state name)
|
||||
(throw (ex-info (str "A ref already has " name " name") {:ast ast})))
|
||||
(let [value (interpret-ast expr ctx)
|
||||
box (atom value)
|
||||
ref {::data/ref true ::data/value box ::data/name name}]
|
||||
ref {::data/ref true ::data/value box ::data/name name ::data/state state}]
|
||||
(vswap! ctx update-ctx {name ref})
|
||||
(swap! state assoc name ref)
|
||||
ref)))
|
||||
|
||||
(defn- interpret-loop [ast ctx]
|
||||
|
@ -1068,4 +1073,4 @@
|
|||
(println result)
|
||||
|
||||
result
|
||||
)
|
||||
)
|
||||
|
|
|
@ -43,7 +43,7 @@
|
|||
post_tokens (:tokens post_scanned)
|
||||
post_parsed (p/apply-parser g/script post_tokens)
|
||||
post_result (i/interpret-safe source post_parsed {} false)
|
||||
ludus_result (assoc post_result :result result_str :test test_results)
|
||||
ludus_result (assoc post_result :result result_str :test test_results :state @i/state)
|
||||
clj_result (ld->clj ludus_result)
|
||||
]
|
||||
(cond
|
||||
|
|
Loading…
Reference in New Issue
Block a user