aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/lux/compiler.clj9
-rw-r--r--src/lux/compiler/cache.clj10
-rw-r--r--src/lux/compiler/host.clj26
-rw-r--r--src/lux/host.clj3
-rw-r--r--src/lux/packager/program.clj2
5 files changed, 24 insertions, 26 deletions
diff --git a/src/lux/compiler.clj b/src/lux/compiler.clj
index 8fe64aa59..b4b76e0a6 100644
--- a/src/lux/compiler.clj
+++ b/src/lux/compiler.clj
@@ -493,7 +493,10 @@
.visitEnd)
(-> (.visitField (+ Opcodes/ACC_PUBLIC Opcodes/ACC_FINAL Opcodes/ACC_STATIC) &/compiler-field "Ljava/lang/String;" nil &&/version)
.visitEnd)
- (.visitSource file-name nil))]]
+ (.visitSource file-name nil))]
+ _ (if (= "lux" name)
+ &&host/compile-Function-class
+ (return nil))]
(fn [state]
(|case ((&/with-writer =class
(&/exhaust% compiler-step))
@@ -545,9 +548,7 @@
;; [Resources]
(defn compile-program [program-module]
(init!)
- (let [m-action (|do [_ &&host/compile-Function-class
- _ (&/map% compile-module (&/|list "lux" program-module))]
- (return nil))]
+ (let [m-action (&/map% compile-module (&/|list "lux" program-module))]
(|case (m-action (&/init-state nil))
(&/$Right ?state _)
(do (println "Compilation complete!")
diff --git a/src/lux/compiler/cache.clj b/src/lux/compiler/cache.clj
index 4f5a4b02d..2bb3a94f1 100644
--- a/src/lux/compiler/cache.clj
+++ b/src/lux/compiler/cache.clj
@@ -42,14 +42,16 @@
(-> class ^Field (.getField field-name) (.get nil)))
;; [Resources]
+(def module-class (str &/module-class-name ".class"))
+
(defn cached? [module]
"(-> Text Bool)"
- (.exists (new File (str &&/output-dir (&host/->module-class module) "/" &/module-class-name ".class"))))
+ (.exists (new File (str &&/output-dir "/" (&host/->module-class module) "/" module-class))))
(defn delete [module]
"(-> Text (Lux (,)))"
(fn [state]
- (do (clean-file (new File (str &&/output-dir (&host/->module-class module))))
+ (do (clean-file (new File (str &&/output-dir "/" (&host/->module-class module))))
(return* state nil))))
(defn clean [state]
@@ -83,7 +85,7 @@
(return true)
(if (cached? module)
(let [module* (&host-generics/->class-name module)
- module-path (str &&/output-dir module)
+ module-path (str &&/output-dir "/" module)
class-name (str module* "._")
^Class module-meta (do (swap! !classes assoc class-name (read-file (File. (str module-path "/_.class"))))
(&&/load-class! loader class-name))]
@@ -101,7 +103,7 @@
(do (doseq [^File file (seq (.listFiles (File. module-path)))
:when (not (.isDirectory file))
:let [file-name (.getName file)]
- :when (not= "_.class" file-name)]
+ :when (not= module-class file-name)]
(let [real-name (second (re-find #"^(.*)\.class$" file-name))
bytecode (read-file file)]
(swap! !classes assoc (str module* "." real-name) bytecode)))
diff --git a/src/lux/compiler/host.clj b/src/lux/compiler/host.clj
index c260a36fd..ceec03870 100644
--- a/src/lux/compiler/host.clj
+++ b/src/lux/compiler/host.clj
@@ -663,21 +663,17 @@
(&&/save-class! interface-name (.toByteArray =interface))))
(def compile-Function-class
- (|do [? (&&/class-exists? "lux" "Function")]
- (if ?
- (return nil)
- (&/with-scope "lux"
- (let [object-class (&/V &/$GenericClass (&/T "java.lang.Object" (&/|list)))
- interface-decl (&/T "Function" (&/|list))
- ?supers (&/|list)
- ?anns (&/|list)
- ?methods (&/|list (&/T "apply"
- (&/|list)
- (&/|list)
- (&/|list)
- (&/|list object-class)
- object-class))]
- (compile-jvm-interface nil interface-decl ?supers ?anns ?methods))))))
+ (let [object-class (&/V &/$GenericClass (&/T "java.lang.Object" (&/|list)))
+ interface-decl (&/T "Function" (&/|list))
+ ?supers (&/|list)
+ ?anns (&/|list)
+ ?methods (&/|list (&/T "apply"
+ (&/|list)
+ (&/|list)
+ (&/|list)
+ (&/|list object-class)
+ object-class))]
+ (compile-jvm-interface nil interface-decl ?supers ?anns ?methods)))
(defn compile-jvm-try [compile ?body ?catches ?finally]
(|do [^MethodVisitor *writer* &/get-writer
diff --git a/src/lux/host.clj b/src/lux/host.clj
index fed7c449b..87600b43b 100644
--- a/src/lux/host.clj
+++ b/src/lux/host.clj
@@ -20,8 +20,7 @@
MethodVisitor)))
;; [Constants]
-(def prefix "lux.")
-(def function-class (str prefix "Function"))
+(def function-class "lux.Function")
(def module-separator "/")
(def class-name-separator ".")
(def class-separator "/")
diff --git a/src/lux/packager/program.clj b/src/lux/packager/program.clj
index 0079f72d3..270c11ed7 100644
--- a/src/lux/packager/program.clj
+++ b/src/lux/packager/program.clj
@@ -46,7 +46,7 @@
))
))
-(let [output-dir-size (.length &&/output-dir)]
+(let [output-dir-size (inc (.length &&/output-dir))]
(defn ^:private write-module! [^File file ^JarOutputStream out]
"(-> File JarOutputStream Unit)"
(let [module-name (.substring (.getPath file) output-dir-size)