diff options
author | Eduardo Julian | 2017-02-20 19:54:18 -0400 |
---|---|---|
committer | Eduardo Julian | 2017-02-20 19:54:18 -0400 |
commit | 22b50868848f757b7f03fbd423ed3620ded52273 (patch) | |
tree | 10d71eee218f076169d9f131f89c4d1c3042bfae /luxc/src/lux/compiler/js/cache.clj | |
parent | db5dcef3d2a5d3d786617a379a106bd66de3082f (diff) |
- Implemented caching mechanisms for JS.
Diffstat (limited to '')
-rw-r--r-- | luxc/src/lux/compiler/js/cache.clj | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/luxc/src/lux/compiler/js/cache.clj b/luxc/src/lux/compiler/js/cache.clj new file mode 100644 index 000000000..0945e6b5b --- /dev/null +++ b/luxc/src/lux/compiler/js/cache.clj @@ -0,0 +1,40 @@ +(ns lux.compiler.js.cache + (:refer-clojure :exclude [load]) + (:require [clojure.string :as string] + [clojure.java.io :as io] + clojure.core.match + clojure.core.match.array + (lux [base :as & :refer [|do return* return |case |let]] + [type :as &type] + [host :as &host]) + [lux.host.generics :as &host-generics] + (lux.analyser [base :as &a] + [module :as &a-module] + [meta :as &a-meta]) + (lux.compiler [core :as &&core] + [io :as &&io]) + (lux.compiler.js [base :as &&])) + (:import (java.io File))) + +;; [Utils] +(defn ^:private read-file [^File file] + "(-> File (Array Byte))" + (with-open [reader (io/input-stream file)] + (let [length (.length file) + buffer (byte-array length)] + (.read reader buffer 0 length) + buffer))) + +;; [Resources] +(defn load-def-value [module name] + (&&/run-js!+ (&&/js-var-name module name))) + +(defn install-all-defs-in-module [module-name] + (|do [:let [module-code-path (str @&&core/!output-dir java.io.File/separator module-name java.io.File/separator &&/module-js-name) + ^bytes module-code (read-file (new File module-code-path))] + _ (&&/run-js!+ (new String module-code))] + (return (&/|list)))) + +(defn uninstall-all-defs-in-module [module-name] + (|do [] + (return nil))) |