aboutsummaryrefslogtreecommitdiff
path: root/src/lux/compiler
diff options
context:
space:
mode:
Diffstat (limited to 'src/lux/compiler')
-rw-r--r--src/lux/compiler/base.clj4
-rw-r--r--src/lux/compiler/cache.clj8
-rw-r--r--src/lux/compiler/host.clj86
-rw-r--r--src/lux/compiler/lambda.clj2
-rw-r--r--src/lux/compiler/lux.clj30
5 files changed, 65 insertions, 65 deletions
diff --git a/src/lux/compiler/base.clj b/src/lux/compiler/base.clj
index 66e3d23f2..b046b237f 100644
--- a/src/lux/compiler/base.clj
+++ b/src/lux/compiler/base.clj
@@ -64,7 +64,7 @@
(defn class-exists? [^String module ^String class-name]
"(-> Text Text (IO Bool))"
- (|do [_ (return &/unit-tag)
+ (|do [_ (return nil)
:let [full-path (str output-dir "/" module "/" class-name ".class")
exists? (.exists (File. full-path))]]
(return exists?)))
@@ -84,7 +84,7 @@
_ (when (not eval?)
(write-output module name bytecode))
_ (load-class! loader real-name)]]
- (return &/unit-tag)))
+ (return nil)))
(do-template [<wrap-name> <unwrap-name> <class> <unwrap-method> <prim> <dup>]
(do (defn <wrap-name> [^MethodVisitor writer]
diff --git a/src/lux/compiler/cache.clj b/src/lux/compiler/cache.clj
index efba55f1a..38592d16f 100644
--- a/src/lux/compiler/cache.clj
+++ b/src/lux/compiler/cache.clj
@@ -50,13 +50,13 @@
(.exists (new File (str &&/output-dir "/" (&host/->module-class module) "/" module-class))))
(defn delete [module]
- "(-> Text (Lux Unit))"
+ "(-> Text (Lux Null))"
(fn [state]
(do (clean-file (new File (str &&/output-dir "/" (&host/->module-class module))))
- (return* state &/unit-tag))))
+ (return* state nil))))
(defn clean [state]
- "(-> Compiler Unit)"
+ "(-> Compiler Null)"
(let [needed-modules (->> state (&/get$ &/$modules) &/|keys &/->seq set)
outdated? #(-> ^File % .getName (string/replace &host/module-separator "/") (->> (contains? needed-modules)) not)
outdate-files (->> &&/output-dir (new File) .listFiles seq (filter outdated?))
@@ -65,7 +65,7 @@
(.delete program-file))
(doseq [f outdate-files]
(clean-file f))
- &/unit-tag))
+ nil))
(let [->regex (fn [text] (re-pattern (java.util.regex.Pattern/quote text)))
import-separator-re (->regex &&/import-separator)
diff --git a/src/lux/compiler/host.clj b/src/lux/compiler/host.clj
index eb67b5215..e7982a8ca 100644
--- a/src/lux/compiler/host.clj
+++ b/src/lux/compiler/host.clj
@@ -109,7 +109,7 @@
_ (doto *writer*
(.visitInsn <opcode>)
(<wrap>))]]
- (return &/unit-tag)))
+ (return nil)))
compile-jvm-iadd Opcodes/IADD "java.lang.Integer" "intValue" "()I" &&/wrap-int
compile-jvm-isub Opcodes/ISUB "java.lang.Integer" "intValue" "()I" &&/wrap-int
@@ -157,7 +157,7 @@
(.visitLabel $then)
(.visitFieldInsn Opcodes/GETSTATIC (&host-generics/->bytecode-class-name "java.lang.Boolean") "FALSE" (&host-generics/->type-signature "java.lang.Boolean"))
(.visitLabel $end))]]
- (return &/unit-tag)))
+ (return nil)))
compile-jvm-ieq Opcodes/IF_ICMPEQ "java.lang.Integer" "intValue" "()I"
compile-jvm-ilt Opcodes/IF_ICMPLT "java.lang.Integer" "intValue" "()I"
@@ -191,7 +191,7 @@
(.visitLabel $then)
(.visitFieldInsn Opcodes/GETSTATIC (&host-generics/->bytecode-class-name "java.lang.Boolean") "TRUE" (&host-generics/->type-signature "java.lang.Boolean"))
(.visitLabel $end))]]
- (return &/unit-tag)))
+ (return nil)))
compile-jvm-leq Opcodes/LCMP 0 "java.lang.Long" "longValue" "()J"
compile-jvm-llt Opcodes/LCMP 1 "java.lang.Long" "longValue" "()J"
@@ -218,7 +218,7 @@
:let [_ (doto *writer*
(.visitMethodInsn Opcodes/INVOKESTATIC (&host-generics/->bytecode-class-name (&host-type/as-obj ?class)) ?method method-sig)
(prepare-return! ?output-type))]]
- (return &/unit-tag)))
+ (return nil)))
(do-template [<name> <op>]
(defn <name> [compile ?class ?method ?classes ?object ?args ?output-type]
@@ -237,7 +237,7 @@
:let [_ (doto *writer*
(.visitMethodInsn <op> ?class* ?method method-sig)
(prepare-return! ?output-type))]]
- (return &/unit-tag)))
+ (return nil)))
compile-jvm-invokevirtual Opcodes/INVOKEVIRTUAL
compile-jvm-invokeinterface Opcodes/INVOKEINTERFACE
@@ -247,7 +247,7 @@
(defn compile-jvm-null [compile]
(|do [^MethodVisitor *writer* &/get-writer
:let [_ (.visitInsn *writer* Opcodes/ACONST_NULL)]]
- (return &/unit-tag)))
+ (return nil)))
(defn compile-jvm-null? [compile ?object]
(|do [^MethodVisitor *writer* &/get-writer
@@ -261,7 +261,7 @@
(.visitLabel $then)
(.visitFieldInsn Opcodes/GETSTATIC (&host-generics/->bytecode-class-name "java.lang.Boolean") "TRUE" (&host-generics/->type-signature "java.lang.Boolean"))
(.visitLabel $end))]]
- (return &/unit-tag)))
+ (return nil)))
(defn compile-jvm-new [compile ?class ?classes ?args]
(|do [^MethodVisitor *writer* &/get-writer
@@ -278,7 +278,7 @@
(&/zip2 ?classes ?args))
:let [_ (doto *writer*
(.visitMethodInsn Opcodes/INVOKESPECIAL class* "<init>" init-sig))]]
- (return &/unit-tag)))
+ (return nil)))
(do-template [<prim-type> <array-type> <new-name> <load-name> <load-op> <store-name> <store-op> <wrapper> <unwrapper>]
(do (defn <new-name> [compile ?length]
@@ -288,7 +288,7 @@
&&/unwrap-long
(.visitInsn Opcodes/L2I))]
:let [_ (.visitIntInsn *writer* Opcodes/NEWARRAY <prim-type>)]]
- (return &/unit-tag)))
+ (return nil)))
(defn <load-name> [compile ?array ?idx]
(|do [^MethodVisitor *writer* &/get-writer
@@ -301,7 +301,7 @@
:let [_ (doto *writer*
(.visitInsn <load-op>)
<wrapper>)]]
- (return &/unit-tag)))
+ (return nil)))
(defn <store-name> [compile ?array ?idx ?elem]
(|do [^MethodVisitor *writer* &/get-writer
@@ -316,7 +316,7 @@
:let [_ (doto *writer*
<unwrapper>
(.visitInsn <store-op>))]]
- (return &/unit-tag)))
+ (return nil)))
)
Opcodes/T_BOOLEAN "[Z" compile-jvm-znewarray compile-jvm-zaload Opcodes/BALOAD compile-jvm-zastore Opcodes/BASTORE &&/wrap-boolean &&/unwrap-boolean
@@ -336,7 +336,7 @@
&&/unwrap-long
(.visitInsn Opcodes/L2I))]
:let [_ (.visitTypeInsn *writer* Opcodes/ANEWARRAY (&host-generics/gclass->bytecode-class-name* ?gclass type-env))]]
- (return &/unit-tag)))
+ (return nil)))
(defn compile-jvm-aaload [compile ?array ?idx]
(|do [^MethodVisitor *writer* &/get-writer
@@ -348,7 +348,7 @@
&&/unwrap-long
(.visitInsn Opcodes/L2I))]
:let [_ (.visitInsn *writer* Opcodes/AALOAD)]]
- (return &/unit-tag)))
+ (return nil)))
(defn compile-jvm-aastore [compile ?array ?idx ?elem]
(|do [^MethodVisitor *writer* &/get-writer
@@ -362,7 +362,7 @@
(.visitInsn Opcodes/L2I))]
_ (compile ?elem)
:let [_ (.visitInsn *writer* Opcodes/AASTORE)]]
- (return &/unit-tag)))
+ (return nil)))
(defn compile-jvm-arraylength [compile ?array]
(|do [^MethodVisitor *writer* &/get-writer
@@ -373,7 +373,7 @@
(.visitInsn Opcodes/ARRAYLENGTH)
(.visitInsn Opcodes/I2L)
&&/wrap-long)]]
- (return &/unit-tag)))
+ (return nil)))
(defn compile-jvm-getstatic [compile ?class ?field ?output-type]
(|do [^MethodVisitor *writer* &/get-writer
@@ -381,7 +381,7 @@
:let [_ (doto *writer*
(.visitFieldInsn Opcodes/GETSTATIC (&host-generics/->bytecode-class-name (&host-type/as-obj ?class)) ?field =output-type)
(prepare-return! ?output-type))]]
- (return &/unit-tag)))
+ (return nil)))
(defn compile-jvm-getfield [compile ?class ?field ?object ?output-type]
(|do [:let [class* (&host-generics/->bytecode-class-name (&host-type/as-obj ?class))]
@@ -392,7 +392,7 @@
(.visitTypeInsn Opcodes/CHECKCAST class*)
(.visitFieldInsn Opcodes/GETFIELD class* ?field =output-type)
(prepare-return! ?output-type))]]
- (return &/unit-tag)))
+ (return nil)))
(defn compile-jvm-putstatic [compile ?class ?field ?value input-gclass ?input-type]
(|do [^MethodVisitor *writer* &/get-writer
@@ -402,7 +402,7 @@
(prepare-arg! (&host-generics/gclass->class-name input-gclass))
(.visitFieldInsn Opcodes/PUTSTATIC (&host-generics/->bytecode-class-name (&host-type/as-obj ?class)) ?field =input-sig)
(.visitInsn Opcodes/ACONST_NULL))]]
- (return &/unit-tag)))
+ (return nil)))
(defn compile-jvm-putfield [compile ?class ?field ?object ?value input-gclass ?input-type]
(|do [:let [class* (&host-generics/->bytecode-class-name (&host-type/as-obj ?class))]
@@ -415,7 +415,7 @@
(prepare-arg! (&host-generics/gclass->class-name input-gclass))
(.visitFieldInsn Opcodes/PUTFIELD class* ?field =input-sig)
(.visitInsn Opcodes/ACONST_NULL))]]
- (return &/unit-tag)))
+ (return nil)))
(defn compile-jvm-instanceof [compile class object]
(|do [:let [class* (&host-generics/->bytecode-class-name class)]
@@ -424,7 +424,7 @@
:let [_ (doto *writer*
(.visitTypeInsn Opcodes/INSTANCEOF class*)
(&&/wrap-boolean))]]
- (return &/unit-tag)))
+ (return nil)))
(defn ^:private compile-annotation [writer ann]
(doto ^AnnotationVisitor (.visitAnnotation writer (&host-generics/->bytecode-class-name (:name ann)) true)
@@ -432,7 +432,7 @@
(->> (|let [[param-name param-value] param])
(doseq [param (&/->seq (:params ann))])))
(.visitEnd))
- &/unit-tag)
+ nil)
(defn ^:private compile-field [^ClassWriter writer field]
(|let [[=name =anns =type] field
@@ -441,7 +441,7 @@
(&host-generics/gclass->signature =type) nil)]
(do (&/|map (partial compile-annotation =field) =anns)
(.visitEnd =field)
- &/unit-tag)))
+ nil)))
(defn ^:private compile-method-return [^MethodVisitor writer output]
(|case output
@@ -519,7 +519,7 @@
(compile-method-return ?output)
(.visitMaxs 0 0)
(.visitEnd))]]
- (return &/unit-tag))))
+ (return nil))))
(&/$VirtualMethodAnalysis ?name ?anns ?gvars ?exceptions ?inputs ?output ?body)
(|let [=method-decl (&/T [?name ?anns ?gvars ?exceptions (&/|map &/|second ?inputs) ?output])
@@ -538,7 +538,7 @@
(compile-method-return ?output)
(.visitMaxs 0 0)
(.visitEnd))]]
- (return &/unit-tag))))
+ (return nil))))
(&/$OverridenMethodAnalysis ?class-decl ?name ?anns ?gvars ?exceptions ?inputs ?output ?body)
(|let [=method-decl (&/T [?name ?anns ?gvars ?exceptions (&/|map &/|second ?inputs) ?output])
@@ -557,7 +557,7 @@
(compile-method-return ?output)
(.visitMaxs 0 0)
(.visitEnd))]]
- (return &/unit-tag))))
+ (return nil))))
))
(defn ^:private compile-method-decl [^ClassWriter class-writer =method-decl]
@@ -571,7 +571,7 @@
(->> =exceptions (&/|map &host-generics/gclass->class-name) &/->seq (into-array java.lang.String)))
_ (&/|map (partial compile-annotation =method) =anns)
_ (.visitEnd =method)]
- &/unit-tag))
+ nil))
(defn ^:private prepare-ctor-arg [^MethodVisitor writer type]
(case type
@@ -621,7 +621,7 @@
(|let [[type term] type+term]
(|do [_ (compile term)
:let [_ (prepare-ctor-arg =method type)]]
- (return &/unit-tag))))
+ (return nil))))
ctor-args)
:let [_ (doto =method
(.visitMethodInsn Opcodes/INVOKESPECIAL (&host-generics/->bytecode-class-name super-class-name) init-method (str "(" init-types ")" <init>-return))
@@ -635,7 +635,7 @@
(.visitInsn Opcodes/RETURN)
(.visitMaxs 0 0)
(.visitEnd))]]
- (return &/unit-tag)))))
+ (return nil)))))
)
(defn compile-jvm-class [compile class-decl ?super-class ?interfaces ?anns ?fields ?methods env ??ctor-args]
@@ -658,7 +658,7 @@
(add-anon-class-<init> =class compile full-name ?super-class env ctor-args)
_
- (return &/unit-tag))]
+ (return nil))]
(&&/save-class! ?name (.toByteArray (doto =class .visitEnd)))))
(defn compile-jvm-interface [compile interface-decl ?supers ?anns ?methods]
@@ -692,7 +692,7 @@
(compile-jvm-interface nil interface-decl ?supers ?anns ?methods)))
(def compile-LuxUtils-class
- (|do [_ (return &/unit-tag)
+ (|do [_ (return nil)
:let [full-name &&/lux-utils-class
super-class (&host-generics/->bytecode-class-name "java.lang.Object")
tag-sig (&host-generics/->type-signature "java.lang.String")
@@ -829,15 +829,15 @@
$end (new Label)
$catch-finally (new Label)
compile-finally (|case ?finally
- (&/$Some ?finally*) (|do [_ (return &/unit-tag)
+ (&/$Some ?finally*) (|do [_ (return nil)
_ (compile ?finally*)
:let [_ (doto *writer*
(.visitInsn Opcodes/POP)
(.visitJumpInsn Opcodes/GOTO $end))]]
- (return &/unit-tag))
- (&/$None) (|do [_ (return &/unit-tag)
+ (return nil))
+ (&/$None) (|do [_ (return nil)
:let [_ (.visitJumpInsn *writer* Opcodes/GOTO $end)]]
- (return &/unit-tag)))
+ (return nil)))
catch-boundaries (&/|map (fn [_catch_]
(|let [[?ex-class ?ex-idx ?catch-body] _catch_]
(&/T [?ex-class (new Label) (new Label)])))
@@ -868,19 +868,19 @@
(&/$Some ?finally*) (|do [_ (compile ?finally*)
:let [_ (.visitInsn *writer* Opcodes/POP)]
:let [_ (.visitInsn *writer* Opcodes/ATHROW)]]
- (return &/unit-tag))
- (&/$None) (|do [_ (return &/unit-tag)
+ (return nil))
+ (&/$None) (|do [_ (return nil)
:let [_ (.visitInsn *writer* Opcodes/ATHROW)]]
- (return &/unit-tag)))
+ (return nil)))
:let [_ (.visitJumpInsn *writer* Opcodes/GOTO $end)]
:let [_ (.visitLabel *writer* $end)]]
- (return &/unit-tag)))
+ (return nil)))
(defn compile-jvm-throw [compile ?ex]
(|do [^MethodVisitor *writer* &/get-writer
_ (compile ?ex)
:let [_ (.visitInsn *writer* Opcodes/ATHROW)]]
- (return &/unit-tag)))
+ (return nil)))
(do-template [<name> <op>]
(defn <name> [compile ?monitor]
@@ -889,7 +889,7 @@
:let [_ (doto *writer*
(.visitInsn <op>)
(.visitInsn Opcodes/ACONST_NULL))]]
- (return &/unit-tag)))
+ (return nil)))
compile-jvm-monitorenter Opcodes/MONITORENTER
compile-jvm-monitorexit Opcodes/MONITOREXIT
@@ -907,7 +907,7 @@
(.visitMethodInsn Opcodes/INVOKEVIRTUAL (&host-generics/->bytecode-class-name <from-class>) <from-method> <from-sig>)
(.visitInsn <op>)
(.visitMethodInsn Opcodes/INVOKESPECIAL (&host-generics/->bytecode-class-name <to-class>) init-method <to-sig>))]]
- (return &/unit-tag)))
+ (return nil)))
compile-jvm-d2f Opcodes/D2F "java.lang.Double" "doubleValue" "()D" "java.lang.Float" "(F)V"
compile-jvm-d2i Opcodes/D2I "java.lang.Double" "doubleValue" "()D" "java.lang.Integer" "(I)V"
@@ -946,7 +946,7 @@
:let [_ (doto *writer*
(.visitInsn <op>)
(.visitMethodInsn Opcodes/INVOKESPECIAL (&host-generics/->bytecode-class-name <to-class>) init-method <to-sig>))]]
- (return &/unit-tag)))
+ (return nil)))
compile-jvm-iand Opcodes/IAND "intValue" "()I" "java.lang.Integer" "intValue" "()I" "java.lang.Integer" "java.lang.Integer" "(I)V"
compile-jvm-ior Opcodes/IOR "intValue" "()I" "java.lang.Integer" "intValue" "()I" "java.lang.Integer" "java.lang.Integer" "(I)V"
@@ -1049,4 +1049,4 @@
(.visitInsn Opcodes/RETURN)
(.visitMaxs 0 0)
(.visitEnd))]]
- (return &/unit-tag)))))
+ (return nil)))))
diff --git a/src/lux/compiler/lambda.clj b/src/lux/compiler/lambda.clj
index 9767e93dc..83714517f 100644
--- a/src/lux/compiler/lambda.clj
+++ b/src/lux/compiler/lambda.clj
@@ -87,7 +87,7 @@
(compile ?source)))
closed-over)
:let [_ (.visitMethodInsn *writer* Opcodes/INVOKESPECIAL lambda-class "<init>" init-signature)]]
- (return &/unit-tag)))
+ (return nil)))
;; [Exports]
(let [lambda-flags (+ Opcodes/ACC_PUBLIC Opcodes/ACC_FINAL Opcodes/ACC_SUPER)
diff --git a/src/lux/compiler/lux.clj b/src/lux/compiler/lux.clj
index 14d34e6dc..3c09f6362 100644
--- a/src/lux/compiler/lux.clj
+++ b/src/lux/compiler/lux.clj
@@ -31,7 +31,7 @@
(defn compile-bool [compile ?value]
(|do [^MethodVisitor *writer* &/get-writer
:let [_ (.visitFieldInsn *writer* Opcodes/GETSTATIC "java/lang/Boolean" (if ?value "TRUE" "FALSE") "Ljava/lang/Boolean;")]]
- (return &/unit-tag)))
+ (return nil)))
(do-template [<name> <class> <sig> <caster>]
(defn <name> [compile value]
@@ -41,7 +41,7 @@
(.visitInsn Opcodes/DUP)
(.visitLdcInsn (<caster> value))
(.visitMethodInsn Opcodes/INVOKESPECIAL <class> "<init>" <sig>))]]
- (return &/unit-tag)))
+ (return nil)))
compile-int "java/lang/Long" "(J)V" long
compile-real "java/lang/Double" "(D)V" double
@@ -51,7 +51,7 @@
(defn compile-text [compile ?value]
(|do [^MethodVisitor *writer* &/get-writer
:let [_ (.visitLdcInsn *writer* ?value)]]
- (return &/unit-tag)))
+ (return nil)))
(defn compile-tuple [compile ?elems]
(|do [^MethodVisitor *writer* &/get-writer
@@ -59,7 +59,7 @@
(|case num-elems
0
(|do [:let [_ (.visitLdcInsn *writer* &/unit-tag)]]
- (return &/unit-tag))
+ (return nil))
1
(compile (&/|head ?elems))
@@ -81,7 +81,7 @@
(.visitLdcInsn (int num-elems))
(.visitLdcInsn &/product-tag)
(.visitInsn Opcodes/AASTORE))]]
- (return &/unit-tag)))))
+ (return nil)))))
(defn compile-variant [compile ?tag tail? ?value]
(|do [^MethodVisitor *writer* &/get-writer
@@ -105,12 +105,12 @@
(.visitLdcInsn (int 3)))]
_ (compile ?value)
:let [_ (.visitInsn *writer* Opcodes/AASTORE)]]
- (return &/unit-tag)))
+ (return nil)))
(defn compile-local [compile ?idx]
(|do [^MethodVisitor *writer* &/get-writer
:let [_ (.visitVarInsn *writer* Opcodes/ALOAD (int ?idx))]]
- (return &/unit-tag)))
+ (return nil)))
(defn compile-captured [compile ?scope ?captured-id ?source]
(|do [^MethodVisitor *writer* &/get-writer
@@ -120,12 +120,12 @@
(str (&host/->module-class (&/|head ?scope)) "/" (&host/location (&/|tail ?scope)))
(str &&/closure-prefix ?captured-id)
"Ljava/lang/Object;"))]]
- (return &/unit-tag)))
+ (return nil)))
(defn compile-global [compile ?owner-class ?name]
(|do [^MethodVisitor *writer* &/get-writer
:let [_ (.visitFieldInsn *writer* Opcodes/GETSTATIC (str (&host/->module-class ?owner-class) "/" (&host/def-name ?name)) &/value-field "Ljava/lang/Object;")]]
- (return &/unit-tag)))
+ (return nil)))
(defn compile-apply [compile ?fn ?args]
(|do [^MethodVisitor *writer* &/get-writer
@@ -135,7 +135,7 @@
:let [_ (.visitMethodInsn *writer* Opcodes/INVOKEINTERFACE &&/function-class "apply" &&/apply-signature)]]
(return =arg)))
?args)]
- (return &/unit-tag)))
+ (return nil)))
(defn ^:private compile-def-type [compile ?body]
(|do [:let [?def-type (|case ?body
@@ -167,7 +167,7 @@
def-meta ?meta
def-value (-> def-class (.getField &/value-field) (.get nil))]
_ (&a-module/define module-name ?name def-type def-meta def-value)]
- (return &/unit-tag))
+ (return nil))
(fail (str "[Compilation Error] Aliases cannot contain meta-data: " module-name ";" ?name)))
(&/$Some _)
@@ -205,7 +205,7 @@
(.visitInsn Opcodes/RETURN)
(.visitMaxs 0 0)
(.visitEnd))]]
- (return &/unit-tag)))
+ (return nil)))
:let [_ (.visitEnd *writer*)]
_ (&&/save-class! def-name (.toByteArray =class))
:let [def-class (&&/load-class! class-loader (&host-generics/->class-name current-class))
@@ -234,7 +234,7 @@
(fail "[Compiler Error] Incorrect format for tags.")))
tags*)
_ (&a-module/declare-tags module-name tags def-value)]
- (return &/unit-tag))
+ (return nil))
[false (&/$Some _)]
(fail "[Compiler Error] Can't define tags for non-type.")
@@ -243,9 +243,9 @@
(fail "[Compiler Error] Incorrect format for tags.")
[_ (&/$None)]
- (return &/unit-tag))
+ (return nil))
:let [_ (println 'DEF (str module-name ";" ?name))]]
- (return &/unit-tag))))))
+ (return nil))))))
(defn compile-ann [compile ?value-ex ?type-ex ?value-type]
(compile ?value-ex))