diff options
author | Eduardo Julian | 2016-01-17 01:17:52 -0400 |
---|---|---|
committer | Eduardo Julian | 2016-01-17 01:17:52 -0400 |
commit | c0f17c4f29cbd194750eac19a481128d3b3b2335 (patch) | |
tree | 3a435a3b1e9518fcfcf02828e95991b789faae74 /src | |
parent | f54a23399de846e63cc9586f36efcb30fea10be5 (diff) |
- I overdid the switch from null to lux.base/unit-tag, so I reversed the change on places where it was superfluous, to reduce the overhead of variable look-up during compilation.
Diffstat (limited to 'src')
-rw-r--r-- | src/lux/analyser/host.clj | 8 | ||||
-rw-r--r-- | src/lux/analyser/lux.clj | 6 | ||||
-rw-r--r-- | src/lux/analyser/module.clj | 32 | ||||
-rw-r--r-- | src/lux/compiler.clj | 6 | ||||
-rw-r--r-- | src/lux/compiler/base.clj | 4 | ||||
-rw-r--r-- | src/lux/compiler/cache.clj | 8 | ||||
-rw-r--r-- | src/lux/compiler/host.clj | 86 | ||||
-rw-r--r-- | src/lux/compiler/lambda.clj | 2 | ||||
-rw-r--r-- | src/lux/compiler/lux.clj | 30 | ||||
-rw-r--r-- | src/lux/type.clj | 30 | ||||
-rw-r--r-- | src/lux/type/host.clj | 8 |
11 files changed, 110 insertions, 110 deletions
diff --git a/src/lux/analyser/host.clj b/src/lux/analyser/host.clj index 8dff15622..0bdb82d21 100644 --- a/src/lux/analyser/host.clj +++ b/src/lux/analyser/host.clj @@ -20,7 +20,7 @@ ;; [Utils] (defn ^:private ensure-catching [exceptions] - "(-> (List Text) (Lux (,)))" + "(-> (List Text) (Lux Null))" (|do [class-loader &/loader] (fn [state] (let [exceptions (&/|map #(Class/forName % true class-loader) exceptions) @@ -38,7 +38,7 @@ nil exceptions)] (&/fail* (str "[Analyser Error] Unhandled exception: " missing-ex)) - (&/return* state &/unit-tag))) + (&/return* state nil))) ))) (defn ^:private with-catches [catches body] @@ -629,7 +629,7 @@ (&/flat-map% (partial &host/abstract-methods class-loader) supers))) (defn ^:private check-method-completion [supers methods] - "(-> (List SuperClassDecl) (List (, MethodDecl Analysis)) (Lux (,)))" + "(-> (List SuperClassDecl) (List (, MethodDecl Analysis)) (Lux Null))" (|do [abstract-methods (mandatory-methods supers) :let [methods-map (&/fold (fn [mmap mentry] (|case mentry @@ -661,7 +661,7 @@ nil abstract-methods)]] (if (nil? missing-method) - (return &/unit-tag) + (return nil) (|let [[am-name am-inputs] missing-method] (fail (str "[Analyser Error] Missing method: " am-name " " "(" (->> am-inputs (&/|interpose " ") (&/fold str "")) ")")))))) diff --git a/src/lux/analyser/lux.clj b/src/lux/analyser/lux.clj index 8d2736f9d..04f2c9828 100644 --- a/src/lux/analyser/lux.clj +++ b/src/lux/analyser/lux.clj @@ -263,7 +263,7 @@ (|do [[[r-module r-name] [endo-type ?meta ?value]] (&&module/find-def module name) _ (if (and (clojure.lang.Util/identical &type/Type endo-type) (clojure.lang.Util/identical &type/Type exo-type)) - (return &/unit-tag) + (return nil) (&type/check exo-type endo-type)) _cursor &/cursor] (return (&/|list (&&/|meta endo-type _cursor @@ -520,7 +520,7 @@ (|do [module-name &/get-module-name _ (if (= module-name path) (fail (str "[Analyser Error] Module can't import itself: " path)) - (return &/unit-tag))] + (return nil))] (&/save-module (|do [already-compiled? (&&module/exists? path) active? (&/active-module? path) @@ -528,7 +528,7 @@ _ (&&module/add-import path) _ (if (not already-compiled?) (compile-module path) - (return &/unit-tag))] + (return nil))] (return &/Nil$))))) (defn analyse-alias [analyse compile-token ex-alias ex-module] diff --git a/src/lux/analyser/module.clj b/src/lux/analyser/module.clj index 4b6013d8e..69635d4ad 100644 --- a/src/lux/analyser/module.clj +++ b/src/lux/analyser/module.clj @@ -38,7 +38,7 @@ ;; [Exports] (defn add-import [module] - "(-> Text (Lux (,)))" + "(-> Text (Lux Null))" (|do [current-module &/get-module-name] (fn [state] (return* (&/update$ &/$modules @@ -47,10 +47,10 @@ (fn [m] (&/update$ $imports (partial &/Cons$ module) m)) ms)) state) - &/unit-tag)))) + nil)))) (defn set-imports [imports] - "(-> (List Text) (Lux (,)))" + "(-> (List Text) (Lux Null))" (|do [current-module &/get-module-name] (fn [state] (return* (&/update$ &/$modules @@ -59,7 +59,7 @@ (fn [m] (&/set$ $imports imports m)) ms)) state) - &/unit-tag)))) + nil)))) (defn define [module name def-type def-meta def-value] (fn [state] @@ -76,7 +76,7 @@ #(&/|put name (&/T [def-type def-meta def-value]) %) m)) ms)))) - &/unit-tag) + nil) _ (fail* (str "[Analyser Error] Can't create a new global definition outside of a global environment: " module ";" name))))) @@ -132,7 +132,7 @@ (&/|put alias reference aliases)) %) ms)))) - &/unit-tag)))) + nil)))) (defn find-def [module name] (|do [current-module &/get-module-name] @@ -178,17 +178,17 @@ (return* state (->> state (&/get$ &/$modules) (&/|get module) (&/get$ $imports)))))) (defn create-module [name] - "(-> Text (Lux (,)))" + "(-> Text (Lux Null))" (fn [state] - (return* (&/update$ &/$modules #(&/|put name +init+ %) state) &/unit-tag))) + (return* (&/update$ &/$modules #(&/|put name +init+ %) state) nil))) (defn enter-module [name] - "(-> Text (Lux (,)))" + "(-> Text (Lux Null))" (fn [state] (return* (->> state (&/update$ &/$modules #(&/|put name +init+ %)) (&/set$ &/$envs (&/|list (&/env name)))) - &/unit-tag))) + nil))) (do-template [<name> <tag> <type>] (defn <name> [module] @@ -208,18 +208,18 @@ _ (&/map% (fn [tag] (if (&/|get tag tags-table) (fail (str "[Analyser Error] Can't re-declare tag: " (&/ident->text (&/T [module tag])))) - (return &/unit-tag))) + (return nil))) tags)] - (return &/unit-tag))) + (return nil))) (defn ensure-undeclared-type [module name] (|do [types-table (types-by-module module) _ (&/assert! (nil? (&/|get name types-table)) (str "[Analyser Error] Can't re-declare type: " (&/ident->text (&/T [module name]))))] - (return &/unit-tag))) + (return nil))) (defn declare-tags [module tag-names type] - "(-> Text (List Text) Type (Lux (,)))" + "(-> Text (List Text) Type (Lux Null))" (|do [_ (ensure-undeclared-tags module tag-names) type-name (&type/type-name type) :let [[_module _name] type-name] @@ -241,7 +241,7 @@ (&/update$ $types (partial &/|put _name (&/T [tags type])))) =modules)) state) - &/unit-tag)) + nil)) (fail* (str "[Lux Error] Unknown module: " module)))))) (do-template [<name> <part> <doc>] @@ -283,7 +283,7 @@ (fail (str "[Analyser Error] Can't tag as lux;" <desc> "? if it's not a " <desc> ": " (str module ";" name))))) _ - (return &/unit-tag))) + (return nil))) test-type &type/Type &meta/type?-tag "type" test-macro &type/Macro &meta/macro?-tag "macro" diff --git a/src/lux/compiler.clj b/src/lux/compiler.clj index d9b76b84b..31e0ca3a2 100644 --- a/src/lux/compiler.clj +++ b/src/lux/compiler.clj @@ -460,7 +460,7 @@ (.visitInsn Opcodes/RETURN) (.visitMaxs 0 0) (.visitEnd))]] - (return &/unit-tag))) + (return nil))) :let [bytecode (.toByteArray (doto =class .visitEnd))] _ (&&/save-class! (str id) bytecode) @@ -494,8 +494,8 @@ _ (if (= "lux" name) (|do [_ &&host/compile-Function-class _ &&host/compile-LuxUtils-class] - (return &/unit-tag)) - (return &/unit-tag))] + (return nil)) + (return nil))] (fn [state] (|case ((&/with-writer =class (&/exhaust% compiler-step)) 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)) diff --git a/src/lux/type.clj b/src/lux/type.clj index 7fbd3f39c..cae91e588 100644 --- a/src/lux/type.clj +++ b/src/lux/type.clj @@ -211,7 +211,7 @@ (return* (&/update$ &/$type-vars (fn [ts] (&/update$ &/$mappings #(&/|put id (&/V &/$Some type) %) ts)) state) - &/unit-tag)) + nil)) (fail* (str "[Type Error] <set-var> Unknown type-var: " id " | " (->> state (&/get$ &/$type-vars) (&/get$ &/$mappings) &/|length)))))) ;; [Exports] @@ -234,7 +234,7 @@ (defn ^:private delete-var [id] (|do [? (bound? id) _ (if ? - (return &/unit-tag) + (return nil) (|do [ex existential] (set-var id ex)))] (fn [state] @@ -261,7 +261,7 @@ (fn [state] (return* (&/update$ &/$type-vars #(&/set$ &/$mappings (&/|remove id mappings*) %) state) - &/unit-tag))) + nil))) state)))) (defn with-var [k] @@ -584,12 +584,12 @@ (defn ^:private check* [class-loader fixpoints invariant?? expected actual] (if (clojure.lang.Util/identical expected actual) - (return (&/T [fixpoints &/unit-tag])) + (return (&/T [fixpoints nil])) (&/with-attempt (|case [expected actual] [(&/$VarT ?eid) (&/$VarT ?aid)] (if (.equals ^Object ?eid ?aid) - (return (&/T [fixpoints &/unit-tag])) + (return (&/T [fixpoints nil])) (|do [ebound (fn [state] (|case ((deref ?eid) state) (&/$Right state* ebound) @@ -607,7 +607,7 @@ (|case [ebound abound] [(&/$None _) (&/$None _)] (|do [_ (set-var ?eid actual)] - (return (&/T [fixpoints &/unit-tag]))) + (return (&/T [fixpoints nil]))) [(&/$Some etype) (&/$None _)] (check* class-loader fixpoints invariant?? etype actual) @@ -622,7 +622,7 @@ (fn [state] (|case ((set-var ?id actual) state) (&/$Right state* _) - (return* state* (&/T [fixpoints &/unit-tag])) + (return* state* (&/T [fixpoints nil])) (&/$Left _) ((|do [bound (deref ?id)] @@ -633,7 +633,7 @@ (fn [state] (|case ((set-var ?id expected) state) (&/$Right state* _) - (return* state* (&/T [fixpoints &/unit-tag])) + (return* state* (&/T [fixpoints nil])) (&/$Left _) ((|do [bound (deref ?id)] @@ -658,7 +658,7 @@ e* (apply-type F2 A1) a* (apply-type F2 A2) [fixpoints** _] (check* class-loader fixpoints* invariant?? e* a*)] - (return (&/T [fixpoints** &/unit-tag]))) + (return (&/T [fixpoints** nil]))) state))) [(&/$AppT F1 A1) (&/$AppT (&/$VarT ?id) A2)] @@ -674,7 +674,7 @@ e* (apply-type F1 A1) a* (apply-type F1 A2) [fixpoints** _] (check* class-loader fixpoints* invariant?? e* a*)] - (return (&/T [fixpoints** &/unit-tag]))) + (return (&/T [fixpoints** nil]))) state))) [(&/$AppT F A) _] @@ -691,7 +691,7 @@ (|case (fp-get fp-pair fixpoints) (&/$Some ?) (if ? - (return (&/T [fixpoints &/unit-tag])) + (return (&/T [fixpoints nil])) (check-error "" expected actual)) (&/$None) @@ -741,10 +741,10 @@ a!data) [(&/$VoidT) (&/$VoidT)] - (return (&/T [fixpoints &/unit-tag])) + (return (&/T [fixpoints nil])) [(&/$UnitT) (&/$UnitT)] - (return (&/T [fixpoints &/unit-tag])) + (return (&/T [fixpoints nil])) [(&/$LambdaT eI eO) (&/$LambdaT aI aO)] (|do [[fixpoints* _] (check* class-loader fixpoints invariant?? aI eI)] @@ -760,7 +760,7 @@ [(&/$ExT e!id) (&/$ExT a!id)] (if (.equals ^Object e!id a!id) - (return (&/T [fixpoints &/unit-tag])) + (return (&/T [fixpoints nil])) (check-error "" expected actual)) [(&/$NamedT ?ename ?etype) _] @@ -777,7 +777,7 @@ (defn check [expected actual] (|do [class-loader &/loader _ (check* class-loader init-fixpoints false expected actual)] - (return &/unit-tag))) + (return nil))) (defn actual-type [type] "(-> Type (Lux Type))" diff --git a/src/lux/type/host.clj b/src/lux/type/host.clj index 27afc1563..ae225db1f 100644 --- a/src/lux/type/host.clj +++ b/src/lux/type/host.clj @@ -215,16 +215,16 @@ (|let [[e!name e!params] expected [a!name a!params] actual] (try (cond (= "java.lang.Object" e!name) - (return (&/T [fixpoints &/unit-tag])) + (return (&/T [fixpoints nil])) (= null-data-tag a!name) (if (not (primitive-type? e!name)) - (return (&/T [fixpoints &/unit-tag])) + (return (&/T [fixpoints nil])) (check-error "" (&/V &/$DataT expected) (&/V &/$DataT actual))) (= null-data-tag e!name) (if (= null-data-tag a!name) - (return (&/T [fixpoints &/unit-tag])) + (return (&/T [fixpoints nil])) (check-error "" (&/V &/$DataT expected) (&/V &/$DataT actual))) (and (= array-data-tag e!name) @@ -237,7 +237,7 @@ (cond (.equals ^Object e!name a!name) (if (= (&/|length e!params) (&/|length a!params)) (|do [_ (&/map2% check e!params a!params)] - (return (&/T [fixpoints &/unit-tag]))) + (return (&/T [fixpoints nil]))) (fail (str "[Type Error] Amounts of generic parameters don't match: " e!name "(" (&/|length e!params) ")" " vs " a!name "(" (&/|length a!params) ")"))) (not invariant??) |