aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/lux/analyser/lux.clj33
-rw-r--r--src/lux/compiler.clj10
-rw-r--r--src/lux/compiler/cache.clj2
-rw-r--r--src/lux/compiler/parallel.clj4
4 files changed, 24 insertions, 25 deletions
diff --git a/src/lux/analyser/lux.clj b/src/lux/analyser/lux.clj
index 69b389e70..8a8f22586 100644
--- a/src/lux/analyser/lux.clj
+++ b/src/lux/analyser/lux.clj
@@ -653,29 +653,30 @@
_ (&&module/add-import path)
?async (if (not already-compiled?)
(compile-module path)
- (|do [_module (&/find-module path)
- _compiler get-compiler]
+ (|do [_compiler get-compiler]
(return (doto (promise)
- (deliver _compiler)))))
+ (deliver (&/$Right _compiler))))))
_ (if (= "" alias)
(return nil)
(&&module/alias current-module alias path))]
(return ?async))))))
_imports)
_compiler get-compiler
- :let [;; Some type-vars in the typing environment stay in
- ;; the environment forever, making type-checking slower.
- ;; The merging process for compilers more-or-less "fixes" the
- ;; problem by resetting the typing enviroment, but ideally
- ;; those type-vars shouldn't survive in the first place.
- ;; TODO: MUST FIX
- _compiler* (&/fold2 (fn [compiler _import _async]
- (|let [[path alias] _import]
- (merge-compilers current-module @_async compiler)))
- _compiler
- _imports
- =asyncs)]
- _ (set-compiler _compiler*)]
+ ;; Some type-vars in the typing environment stay in
+ ;; the environment forever, making type-checking slower.
+ ;; The merging process for compilers more-or-less "fixes" the
+ ;; problem by resetting the typing enviroment, but ideally
+ ;; those type-vars shouldn't survive in the first place.
+ ;; TODO: MUST FIX
+ _ (&/fold% (fn [compiler _async]
+ (|case @_async
+ (&/$Right _new-compiler)
+ (set-compiler (merge-compilers current-module _new-compiler compiler))
+
+ (&/$Left ?error)
+ (fail ?error)))
+ _compiler
+ =asyncs)]
(return &/$Nil)))
(defn ^:private coerce [new-type analysis]
diff --git a/src/lux/compiler.clj b/src/lux/compiler.clj
index 8b9e8bbed..6506c867b 100644
--- a/src/lux/compiler.clj
+++ b/src/lux/compiler.clj
@@ -169,13 +169,11 @@
(defn compile-module [source-dirs name]
(let [file-name (str name ".lux")]
(|do [file-content (&&io/read-file source-dirs file-name)
- :let [file-hash (hash file-content)]]
+ :let [file-hash (hash file-content)
+ compile-module!! (&&parallel/parallel-compilation (partial compile-module source-dirs))]]
(if (&&cache/cached? name)
- (&&cache/load source-dirs name file-hash compile-module)
- (let [compiler-step (&analyser/analyse &optimizer/optimize
- eval!
- (&&parallel/parallel-compilation (partial compile-module source-dirs))
- all-compilers)]
+ (&&cache/load source-dirs name file-hash compile-module!!)
+ (let [compiler-step (&analyser/analyse &optimizer/optimize eval! compile-module!! all-compilers)]
(|do [module-exists? (&a-module/exists? name)]
(if module-exists?
(fail "[Compiler Error] Can't redefine a module!")
diff --git a/src/lux/compiler/cache.clj b/src/lux/compiler/cache.clj
index f2668f8b5..4f90c7cce 100644
--- a/src/lux/compiler/cache.clj
+++ b/src/lux/compiler/cache.clj
@@ -89,7 +89,7 @@
(if already-loaded?
(return module-hash)
(|let [redo-cache (|do [_ (delete module)]
- (compile-module source-dirs module))]
+ (compile-module module))]
(if (cached? module)
(|do [loader &/loader
!classes &/classes
diff --git a/src/lux/compiler/parallel.clj b/src/lux/compiler/parallel.clj
index 3506eb82e..8f6fee99d 100644
--- a/src/lux/compiler/parallel.clj
+++ b/src/lux/compiler/parallel.clj
@@ -39,9 +39,9 @@
(|case (&/run-state (compile-module* module-name)
compiler)
(&/$Right post-compiler _)
- (deliver task post-compiler)
+ (deliver task (&/$Right post-compiler))
(&/$Left ?error)
- (println ?error)))]
+ (deliver task (&/$Left ?error))))]
(&/|log! out-str))))))]]
(return task))))