loader: drop write-only compiled-form cache and its unused helpers
compiled?/get-compiled-forms/clear-compiled-cache were never called, and load-ns only ever wrote to :compiled-cache with no reader. All dead once the self-host path landed. Removed the helpers, the cache writes, and the :compiled-cache env field.
This commit is contained in:
parent
497970029d
commit
984af02532
2 changed files with 26 additions and 60 deletions
|
|
@ -45,16 +45,11 @@
|
|||
(eval-form ctx @{} form)))
|
||||
|
||||
(defn load-ns
|
||||
"Load a Clojure namespace from a .clj file.
|
||||
When ctx has :compile? enabled, forms are compiled to Janet source,
|
||||
evaluated via Janet's evaluator, and cached.
|
||||
"Load a Clojure namespace from a .clj file. Per-form routing (compile-or-
|
||||
interpret, stateful forms interpret) is shared with eval-one via eval-toplevel.
|
||||
|
||||
(load-ns ctx filepath) → namespace symbol string"
|
||||
[ctx filepath]
|
||||
(let [env (ctx :env)
|
||||
compile? (get env :compile?)
|
||||
cache (get env :compiled-cache)]
|
||||
|
||||
(def source (slurp filepath))
|
||||
(var ns-name nil)
|
||||
(var remaining source)
|
||||
|
|
@ -79,33 +74,5 @@
|
|||
(when (nil? ns-name)
|
||||
(error (string "No ns form found in " filepath)))
|
||||
|
||||
# Per-form routing (compile-or-interpret, stateful forms interpret) is shared
|
||||
# with eval-one via eval-toplevel. When compiling, also record the forms so a
|
||||
# namespace can be inspected / re-emitted.
|
||||
(when compile?
|
||||
(var cached (get cache ns-name))
|
||||
(when (nil? cached)
|
||||
(set cached @[])
|
||||
(put cache ns-name cached))
|
||||
(each form forms (array/push cached form)))
|
||||
(each form forms (eval-toplevel ctx form))
|
||||
ns-name))
|
||||
|
||||
(defn compiled?
|
||||
"Check if a namespace has been compiled and cached."
|
||||
[ctx ns-name]
|
||||
(let [cache (get (ctx :env) :compiled-cache)]
|
||||
(not (nil? (get cache ns-name)))))
|
||||
|
||||
(defn get-compiled-forms
|
||||
"Get the compiled Janet source forms for a namespace."
|
||||
[ctx ns-name]
|
||||
(get (ctx :env) :compiled-cache ns-name))
|
||||
|
||||
(defn clear-compiled-cache
|
||||
"Clear the compiled form cache for a namespace or all namespaces."
|
||||
[ctx &opt ns-name]
|
||||
(let [cache (get (ctx :env) :compiled-cache)]
|
||||
(if ns-name
|
||||
(put cache ns-name nil)
|
||||
(loop [[k] :pairs cache] (put cache k nil)))))
|
||||
ns-name)
|
||||
|
|
|
|||
|
|
@ -373,7 +373,6 @@
|
|||
# to a .clj/.cljc file. jolt-core holds the portable Clojure layer
|
||||
# (analyzer/IR/core); deps.edn resolution appends dep src dirs.
|
||||
:source-paths @["jolt-core" "src/jolt"]
|
||||
:compiled-cache @{}
|
||||
:type-registry @{}
|
||||
:data-readers (let [dr @{}]
|
||||
(put dr (keyword "#inst") (fn [s] s))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue