From 69fefab57c40f323d759dc444dbcebad15071585 Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Fri, 13 Jul 2018 22:01:32 -0400 Subject: Re-named "Bool" type to "Bit". --- luxc/src/lux/analyser.clj | 6 +++--- luxc/src/lux/analyser/base.clj | 2 +- luxc/src/lux/analyser/case.clj | 30 +++++++++++++++--------------- luxc/src/lux/analyser/module.clj | 12 ++++++------ luxc/src/lux/analyser/parser.clj | 22 +++++++++++----------- luxc/src/lux/analyser/proc/common.clj | 16 ++++++++-------- luxc/src/lux/analyser/proc/jvm.clj | 34 +++++++++++++++++----------------- luxc/src/lux/base.clj | 14 +++++++------- luxc/src/lux/compiler/cache.clj | 14 +++++++++----- luxc/src/lux/compiler/cache/ann.clj | 6 +++--- luxc/src/lux/compiler/jvm.clj | 4 ++-- luxc/src/lux/compiler/jvm/base.clj | 5 +++-- luxc/src/lux/compiler/jvm/case.clj | 2 +- luxc/src/lux/compiler/jvm/lux.clj | 4 ++-- luxc/src/lux/lexer.clj | 6 +++--- luxc/src/lux/optimizer.clj | 28 ++++++++++++++-------------- luxc/src/lux/parser.clj | 4 ++-- luxc/src/lux/type.clj | 8 ++++---- luxc/src/lux/type/host.clj | 2 +- 19 files changed, 112 insertions(+), 107 deletions(-) (limited to 'luxc') diff --git a/luxc/src/lux/analyser.clj b/luxc/src/lux/analyser.clj index 9052e6f8f..6e2d8f7aa 100644 --- a/luxc/src/lux/analyser.clj +++ b/luxc/src/lux/analyser.clj @@ -65,9 +65,9 @@ macro-caller (aget compilers 2)] (|case token ;; Standard special forms - (&/$Bool ?value) - (|do [_ (&type/check exo-type &type/Bool)] - (return (&/|list (&&/|meta exo-type cursor (&&/$bool ?value))))) + (&/$Bit ?value) + (|do [_ (&type/check exo-type &type/Bit)] + (return (&/|list (&&/|meta exo-type cursor (&&/$bit ?value))))) (&/$Nat ?value) (|do [_ (&type/check exo-type &type/Nat)] diff --git a/luxc/src/lux/analyser/base.clj b/luxc/src/lux/analyser/base.clj index 25b73ba1a..7874b0bd2 100644 --- a/luxc/src/lux/analyser/base.clj +++ b/luxc/src/lux/analyser/base.clj @@ -6,7 +6,7 @@ ;; [Tags] (defvariant - ("bool" 1) + ("bit" 1) ("nat" 1) ("int" 1) ("rev" 1) diff --git a/luxc/src/lux/analyser/case.clj b/luxc/src/lux/analyser/case.clj index 86752d336..73b4c8df2 100644 --- a/luxc/src/lux/analyser/case.clj +++ b/luxc/src/lux/analyser/case.clj @@ -12,7 +12,7 @@ ;; [Tags] (defvariant ("DefaultTotal" 1) - ("BoolTotal" 2) + ("BitTotal" 2) ("NatTotal" 2) ("IntTotal" 2) ("RevTotal" 2) @@ -24,7 +24,7 @@ (defvariant ("NoTestAC" 0) ("StoreTestAC" 1) - ("BoolTestAC" 1) + ("BitTestAC" 1) ("NatTestAC" 1) ("IntTestAC" 1) ("RevTestAC" 1) @@ -268,10 +268,10 @@ (&/$Symbol ident) (&/fail-with-loc (str "[Pattern-matching Error] Symbols must be unqualified: " (&/ident->text ident))) - (&/$Bool ?value) - (|do [_ (&type/check value-type &type/Bool) + (&/$Bit ?value) + (|do [_ (&type/check value-type &type/Bit) =kont kont] - (return (&/T [($BoolTestAC ?value) =kont]))) + (return (&/T [($BitTestAC ?value) =kont]))) (&/$Nat ?value) (|do [_ (&type/check value-type &type/Nat) @@ -405,8 +405,8 @@ [($DefaultTotal total?) ($NoTestAC)] (return ($DefaultTotal true)) - [($BoolTotal total? ?values) ($NoTestAC)] - (return ($BoolTotal true ?values)) + [($BitTotal total? ?values) ($NoTestAC)] + (return ($BitTotal true ?values)) [($NatTotal total? ?values) ($NoTestAC)] (return ($NatTotal true ?values)) @@ -432,8 +432,8 @@ [($DefaultTotal total?) ($StoreTestAC ?idx)] (return ($DefaultTotal true)) - [($BoolTotal total? ?values) ($StoreTestAC ?idx)] - (return ($BoolTotal true ?values)) + [($BitTotal total? ?values) ($StoreTestAC ?idx)] + (return ($BitTotal true ?values)) [($NatTotal total? ?values) ($StoreTestAC ?idx)] (return ($NatTotal true ?values)) @@ -456,11 +456,11 @@ [($VariantTotal total? ?values) ($StoreTestAC ?idx)] (return ($VariantTotal true ?values)) - [($DefaultTotal total?) ($BoolTestAC ?value)] - (return ($BoolTotal total? (&/|list ?value))) + [($DefaultTotal total?) ($BitTestAC ?value)] + (return ($BitTotal total? (&/|list ?value))) - [($BoolTotal total? ?values) ($BoolTestAC ?value)] - (return ($BoolTotal total? (&/$Cons ?value ?values))) + [($BitTotal total? ?values) ($BitTestAC ?value)] + (return ($BitTotal total? (&/$Cons ?value ?values))) [($DefaultTotal total?) ($NatTestAC ?value)] (return ($NatTotal total? (&/|list ?value))) @@ -550,8 +550,8 @@ ($DefaultTotal ?total) (return ?total) - ($BoolTotal ?total ?values) - (|do [_ (&type/check value-type &type/Bool)] + ($BitTotal ?total ?values) + (|do [_ (&type/check value-type &type/Bit)] (return (or ?total (= #{true false} (set (&/->seq ?values)))))) diff --git a/luxc/src/lux/analyser/module.clj b/luxc/src/lux/analyser/module.clj index 130004701..4174932ca 100644 --- a/luxc/src/lux/analyser/module.clj +++ b/luxc/src/lux/analyser/module.clj @@ -61,7 +61,7 @@ state)] (&/$Right (&/T [state* &/unit-tag]))))) (defn - "(-> Text (Lux Bool))" + "(-> Text (Lux Bit))" [module-name] (fn [state] (if-let [=module (->> state (&/get$ &/$modules) (&/|get module-name))] @@ -141,7 +141,7 @@ state)))) (defn type-def - "(-> Text Text (Lux [Bool Type]))" + "(-> Text Text (Lux [Bit Type]))" [module name] (fn [state] (if-let [$module (->> state (&/get$ &/$modules) (&/|get module))] @@ -167,7 +167,7 @@ state)))) (defn exists? - "(-> Text (Lux Bool))" + "(-> Text (Lux Bit))" [name] (fn [state] (return* state @@ -269,7 +269,7 @@ _ (return* state (&/T [(&/T [module name]) $def]))) (|case (&meta/meta-get &meta/export?-tag ?meta) - (&/$Some [_ (&/$Bool true)]) + (&/$Some [_ (&/$Bit true)]) (return* state (&/T [(&/T [module name]) $def])) _ @@ -354,7 +354,7 @@ (return nil))) (defn declare-tags - "(-> Text (List Text) Bool Type (Lux Null))" + "(-> Text (List Text) Bit Type (Lux Null))" [module tag-names was-exported? type] (|do [_ (ensure-undeclared-tags module tag-names) type-name (&type/type-name type) @@ -437,7 +437,7 @@ (do-template [ ] (defn [module name meta type] (|case (&meta/meta-get meta) - (&/$Some [_ (&/$Bool true)]) + (&/$Some [_ (&/$Bit true)]) (&/try-all% (&/|list (&type/check type) (&/fail-with-loc (str "[Analyser Error] Cannot tag as lux;" "? if it's not a " ": " (str module &/+name-separator+ name))))) diff --git a/luxc/src/lux/analyser/parser.clj b/luxc/src/lux/analyser/parser.clj index c5cd84eab..6a46bab3c 100644 --- a/luxc/src/lux/analyser/parser.clj +++ b/luxc/src/lux/analyser/parser.clj @@ -133,7 +133,7 @@ (def ^:private parse-ann-param (|do [param-name parse-name _ (&reader/read-text "=") - param-value (&/try-all% (&/|list (|do [[_ (&lexer/$Bool param-value*)] &lexer/lex-bool] + param-value (&/try-all% (&/|list (|do [[_ (&lexer/$Bit param-value*)] &lexer/lex-bit] (return (boolean param-value*))) (|do [[_ (&lexer/$Int param-value*)] &lexer/lex-int] @@ -243,8 +243,8 @@ (|do [_ (&reader/read-text "init") =privacy-modifier (with-pre-space parse-privacy-modifier) - [_ (&lexer/$Bool =strict*)] (with-pre-space - &lexer/lex-bool) + [_ (&lexer/$Bit =strict*)] (with-pre-space + &lexer/lex-bit) :let [=strict (Boolean/parseBoolean =strict*)] =anns (with-pre-space (with-brackets @@ -271,11 +271,11 @@ parse-name) =privacy-modifier (with-pre-space parse-privacy-modifier) - [_ (&lexer/$Bool =final?*)] (with-pre-space - &lexer/lex-bool) + [_ (&lexer/$Bit =final?*)] (with-pre-space + &lexer/lex-bit) :let [=final? (Boolean/parseBoolean =final?*)] - [_ (&lexer/$Bool =strict*)] (with-pre-space - &lexer/lex-bool) + [_ (&lexer/$Bit =strict*)] (with-pre-space + &lexer/lex-bit) :let [=strict (Boolean/parseBoolean =strict*)] =anns (with-pre-space (with-brackets @@ -301,8 +301,8 @@ parse-gclass-decl) =name (with-pre-space parse-name) - [_ (&lexer/$Bool =strict*)] (with-pre-space - &lexer/lex-bool) + [_ (&lexer/$Bit =strict*)] (with-pre-space + &lexer/lex-bit) :let [=strict (Boolean/parseBoolean =strict*)] =anns (with-pre-space (with-brackets @@ -328,8 +328,8 @@ parse-name) =privacy-modifier (with-pre-space parse-privacy-modifier) - [_ (&lexer/$Bool =strict*)] (with-pre-space - &lexer/lex-bool) + [_ (&lexer/$Bit =strict*)] (with-pre-space + &lexer/lex-bit) :let [=strict (Boolean/parseBoolean =strict*)] =anns (with-pre-space (with-brackets diff --git a/luxc/src/lux/analyser/proc/common.clj b/luxc/src/lux/analyser/proc/common.clj index 359fcb314..7b6bc6a3f 100644 --- a/luxc/src/lux/analyser/proc/common.clj +++ b/luxc/src/lux/analyser/proc/common.clj @@ -12,7 +12,7 @@ (|do [:let [(&/$Cons left (&/$Cons right (&/$Nil))) ?values] =left (&&/analyse-1 analyse $var left) =right (&&/analyse-1 analyse $var right) - _ (&type/check exo-type &type/Bool) + _ (&type/check exo-type &type/Bit) _cursor &/cursor] (return (&/|list (&&/|meta exo-type _cursor (&&/$proc (&/T ["lux" "is"]) (&/|list =left =right) (&/|list))))))))) @@ -39,8 +39,8 @@ (return (&/|list (&&/|meta exo-type _cursor (&&/$proc (&/T ) (&/|list =x =y) (&/|list))))))) - ^:private analyse-text-eq ["text" "="] &type/Text &type/Bool - ^:private analyse-text-lt ["text" "<"] &type/Text &type/Bool + ^:private analyse-text-eq ["text" "="] &type/Text &type/Bit + ^:private analyse-text-lt ["text" "<"] &type/Text &type/Bit ^:private analyse-text-concat ["text" "concat"] &type/Text &type/Text ) @@ -143,7 +143,7 @@ (return (&/|list (&&/|meta exo-type _cursor (&&/$proc (&/T ) (&/|list subjectA paramA) (&/|list)))))))) - ^:private analyse-i64-eq ["i64" "="] (&/$Apply &type/Any &type/I64) &type/Bool + ^:private analyse-i64-eq ["i64" "="] (&/$Apply &type/Any &type/I64) &type/Bit ^:private analyse-i64-add ["i64" "+"] (&/$Apply &type/Any &type/I64) &type/I64 ^:private analyse-i64-sub ["i64" "-"] (&/$Apply &type/Any &type/I64) &type/I64 ) @@ -163,15 +163,15 @@ ^:private analyse-int-mul ["int" "*"] &type/Int &type/Int ^:private analyse-int-div ["int" "/"] &type/Int &type/Int ^:private analyse-int-rem ["int" "%"] &type/Int &type/Int - ^:private analyse-int-lt ["int" "<"] &type/Int &type/Bool + ^:private analyse-int-lt ["int" "<"] &type/Int &type/Bit ^:private analyse-frac-add ["frac" "+"] &type/Frac &type/Frac ^:private analyse-frac-sub ["frac" "-"] &type/Frac &type/Frac ^:private analyse-frac-mul ["frac" "*"] &type/Frac &type/Frac ^:private analyse-frac-div ["frac" "/"] &type/Frac &type/Frac ^:private analyse-frac-rem ["frac" "%"] &type/Frac &type/Frac - ^:private analyse-frac-eq ["frac" "="] &type/Frac &type/Bool - ^:private analyse-frac-lt ["frac" "<"] &type/Frac &type/Bool + ^:private analyse-frac-eq ["frac" "="] &type/Frac &type/Bit + ^:private analyse-frac-lt ["frac" "<"] &type/Frac &type/Bit ) (do-template [ ] @@ -348,7 +348,7 @@ =atom (&&/analyse-1 analyse (&type/Atom $var) ?atom) =old (&&/analyse-1 analyse $var ?old) =new (&&/analyse-1 analyse $var ?new) - _ (&type/check exo-type &type/Bool) + _ (&type/check exo-type &type/Bit) _cursor &/cursor] (return (&/|list (&&/|meta exo-type _cursor (&&/$proc (&/T ["atom" "compare-and-swap"]) (&/|list =atom =old =new) (&/|list))))))))) diff --git a/luxc/src/lux/analyser/proc/jvm.clj b/luxc/src/lux/analyser/proc/jvm.clj index b6d291073..98c2435e9 100644 --- a/luxc/src/lux/analyser/proc/jvm.clj +++ b/luxc/src/lux/analyser/proc/jvm.clj @@ -464,40 +464,40 @@ ^:private analyse-jvm-imul "imul" "java.lang.Integer" "java.lang.Integer" ^:private analyse-jvm-idiv "idiv" "java.lang.Integer" "java.lang.Integer" ^:private analyse-jvm-irem "irem" "java.lang.Integer" "java.lang.Integer" - ^:private analyse-jvm-ieq "ieq" "java.lang.Integer" "java.lang.Boolean" - ^:private analyse-jvm-ilt "ilt" "java.lang.Integer" "java.lang.Boolean" - ^:private analyse-jvm-igt "igt" "java.lang.Integer" "java.lang.Boolean" + ^:private analyse-jvm-ieq "ieq" "java.lang.Integer" "#Bit" + ^:private analyse-jvm-ilt "ilt" "java.lang.Integer" "#Bit" + ^:private analyse-jvm-igt "igt" "java.lang.Integer" "#Bit" - ^:private analyse-jvm-ceq "ceq" "java.lang.Character" "java.lang.Boolean" - ^:private analyse-jvm-clt "clt" "java.lang.Character" "java.lang.Boolean" - ^:private analyse-jvm-cgt "cgt" "java.lang.Character" "java.lang.Boolean" + ^:private analyse-jvm-ceq "ceq" "java.lang.Character" "#Bit" + ^:private analyse-jvm-clt "clt" "java.lang.Character" "#Bit" + ^:private analyse-jvm-cgt "cgt" "java.lang.Character" "#Bit" ^:private analyse-jvm-ladd "ladd" "java.lang.Long" "java.lang.Long" ^:private analyse-jvm-lsub "lsub" "java.lang.Long" "java.lang.Long" ^:private analyse-jvm-lmul "lmul" "java.lang.Long" "java.lang.Long" ^:private analyse-jvm-ldiv "ldiv" "java.lang.Long" "java.lang.Long" ^:private analyse-jvm-lrem "lrem" "java.lang.Long" "java.lang.Long" - ^:private analyse-jvm-leq "leq" "java.lang.Long" "java.lang.Boolean" - ^:private analyse-jvm-llt "llt" "java.lang.Long" "java.lang.Boolean" - ^:private analyse-jvm-lgt "lgt" "java.lang.Long" "java.lang.Boolean" + ^:private analyse-jvm-leq "leq" "java.lang.Long" "#Bit" + ^:private analyse-jvm-llt "llt" "java.lang.Long" "#Bit" + ^:private analyse-jvm-lgt "lgt" "java.lang.Long" "#Bit" ^:private analyse-jvm-fadd "fadd" "java.lang.Float" "java.lang.Float" ^:private analyse-jvm-fsub "fsub" "java.lang.Float" "java.lang.Float" ^:private analyse-jvm-fmul "fmul" "java.lang.Float" "java.lang.Float" ^:private analyse-jvm-fdiv "fdiv" "java.lang.Float" "java.lang.Float" ^:private analyse-jvm-frem "frem" "java.lang.Float" "java.lang.Float" - ^:private analyse-jvm-feq "feq" "java.lang.Float" "java.lang.Boolean" - ^:private analyse-jvm-flt "flt" "java.lang.Float" "java.lang.Boolean" - ^:private analyse-jvm-fgt "fgt" "java.lang.Float" "java.lang.Boolean" + ^:private analyse-jvm-feq "feq" "java.lang.Float" "#Bit" + ^:private analyse-jvm-flt "flt" "java.lang.Float" "#Bit" + ^:private analyse-jvm-fgt "fgt" "java.lang.Float" "#Bit" ^:private analyse-jvm-dadd "dadd" "java.lang.Double" "java.lang.Double" ^:private analyse-jvm-dsub "dsub" "java.lang.Double" "java.lang.Double" ^:private analyse-jvm-dmul "dmul" "java.lang.Double" "java.lang.Double" ^:private analyse-jvm-ddiv "ddiv" "java.lang.Double" "java.lang.Double" ^:private analyse-jvm-drem "drem" "java.lang.Double" "java.lang.Double" - ^:private analyse-jvm-deq "deq" "java.lang.Double" "java.lang.Boolean" - ^:private analyse-jvm-dlt "dlt" "java.lang.Double" "java.lang.Boolean" - ^:private analyse-jvm-dgt "dgt" "java.lang.Double" "java.lang.Boolean" + ^:private analyse-jvm-deq "deq" "java.lang.Double" "#Bit" + ^:private analyse-jvm-dlt "dlt" "java.lang.Double" "#Bit" + ^:private analyse-jvm-dgt "dgt" "java.lang.Double" "#Bit" ) (let [length-type &type/Nat @@ -606,7 +606,7 @@ (|do [:let [(&/$Cons object (&/$Nil)) ?values] =object (&&/analyse-1+ analyse object) _ (ensure-object (&&/expr-type* =object)) - :let [output-type &type/Bool] + :let [output-type &type/Bit] _ (&type/check exo-type output-type) _cursor &/cursor] (return (&/|list (&&/|meta exo-type _cursor @@ -805,7 +805,7 @@ (|do [:let [(&/$Cons object (&/$Nil)) ?values] =object (&&/analyse-1+ analyse object) _ (ensure-object (&&/expr-type* =object)) - :let [output-type &type/Bool] + :let [output-type &type/Bit] _ (&type/check exo-type output-type) _cursor &/cursor] (return (&/|list (&&/|meta output-type _cursor diff --git a/luxc/src/lux/base.clj b/luxc/src/lux/base.clj index 37db2a480..464b7b585 100644 --- a/luxc/src/lux/base.clj +++ b/luxc/src/lux/base.clj @@ -71,7 +71,7 @@ ;; Code (defvariant - ("Bool" 1) + ("Bit" 1) ("Nat" 1) ("Int" 1) ("Rev" 1) @@ -410,7 +410,7 @@ (assert false (prn-str '|map f (adt->text xs))))) (defn |empty? - "(All [a] (-> (List a) Bool))" + "(All [a] (-> (List a) Bit))" [xs] (|case xs ($Nil) @@ -420,7 +420,7 @@ false)) (defn |filter - "(All [a] (-> (-> a Bool) (List a) (List a)))" + "(All [a] (-> (-> a Bit) (List a) (List a)))" [p xs] (|case xs ($Nil) @@ -856,7 +856,7 @@ (do-template [ ] (defn - "(-> CompilerMode Bool)" + "(-> CompilerMode Bit)" [mode] (|case mode () true @@ -1204,7 +1204,7 @@ (defn show-ast [ast] (|case ast - [_ ($Bool ?value)] + [_ ($Bit ?value)] (pr-str ?value) [_ ($Nat ?value)] @@ -1325,7 +1325,7 @@ (return* state (|keys (get$ $modules state))))) (defn when% - "(-> Bool (Meta Any) (Meta Any))" + "(-> Bit (Meta Any) (Meta Any))" [test body] (if test body @@ -1377,7 +1377,7 @@ (do-template [ ] (defn - "(All [a] (-> (-> a Bool) (List a) Bool))" + "(All [a] (-> (-> a Bit) (List a) Bit))" [p xs] (|case xs ($Nil) diff --git a/luxc/src/lux/compiler/cache.clj b/luxc/src/lux/compiler/cache.clj index 04ef34e52..0b8739463 100644 --- a/luxc/src/lux/compiler/cache.clj +++ b/luxc/src/lux/compiler/cache.clj @@ -28,12 +28,14 @@ java.io.File/separator (.replace ^String (&host/->module-class module) "/" java.io.File/separator))) -(defn cached? [module] - "(-> Text Bool)" +(defn cached? + "(-> Text Bit)" + [module] (.exists (new File (str (module-path module) java.io.File/separator &&core/lux-module-descriptor-name)))) -(defn delete [module] +(defn delete "(-> Text (Lux Null))" + [module] (fn [state] (do (delete-all-module-files (new File (module-path module))) (return* state nil)))) @@ -48,8 +50,9 @@ (apply concat) (list* module))) -(defn clean [state] +(defn clean "(-> Lux Null)" + [state] (let [needed-modules (->> state (&/get$ &/$modules) &/|keys &/->seq set) output-dir-prefix (str (.getAbsolutePath (new File ^String @&&core/!output-dir)) java.io.File/separator) outdated? #(->> % (contains? needed-modules) not) @@ -237,8 +240,9 @@ compiler) nil))) -(defn load [module-name] +(defn load "(-> Text (Lux Null))" + [module-name] (if-let [module-struct (get @!pre-loaded-cache module-name)] (|do [_ (inject-module module-name module-struct)] (return nil)) diff --git a/luxc/src/lux/compiler/cache/ann.clj b/luxc/src/lux/compiler/cache/ann.clj index 458146992..bab3d20c7 100644 --- a/luxc/src/lux/compiler/cache/ann.clj +++ b/luxc/src/lux/compiler/cache/ann.clj @@ -24,7 +24,7 @@ "(-> Code Text)" [ann] (|case ann - [_ (&/$Bool value)] + [_ (&/$Bit value)] (str "B" value stop) [_ (&/$Nat value)] @@ -76,7 +76,7 @@ (let [[value* ^String input*] (.split (.substring input 1) stop 2)] [(&/T [dummy-cursor ( ( value*))]) input*]))) - ^:private deserialize-bool "B" &/$Bool Boolean/parseBoolean + ^:private deserialize-bit "B" &/$Bit Boolean/parseBoolean ^:private deserialize-nat "N" &/$Nat Long/parseLong ^:private deserialize-int "I" &/$Int Long/parseLong ^:private deserialize-rev "D" &/$Rev Long/parseLong @@ -124,7 +124,7 @@ (defn deserialize "(-> Text V[Code Text])" [input] - (or (deserialize-bool input) + (or (deserialize-bit input) (deserialize-nat input) (deserialize-int input) (deserialize-rev input) diff --git a/luxc/src/lux/compiler/jvm.clj b/luxc/src/lux/compiler/jvm.clj index a13427bc3..60a2c7d2e 100644 --- a/luxc/src/lux/compiler/jvm.clj +++ b/luxc/src/lux/compiler/jvm.clj @@ -47,8 +47,8 @@ (.visitLineNumber (int _line) debug-label)) (swap! !source->last-line assoc _file-name _line))]] (|case ?form - (&o/$bool ?value) - (&&lux/compile-bool ?value) + (&o/$bit ?value) + (&&lux/compile-bit ?value) (&o/$nat ?value) (&&lux/compile-nat ?value) diff --git a/luxc/src/lux/compiler/jvm/base.clj b/luxc/src/lux/compiler/jvm/base.clj index 99e0f08e9..b5e520de5 100644 --- a/luxc/src/lux/compiler/jvm/base.clj +++ b/luxc/src/lux/compiler/jvm/base.clj @@ -43,8 +43,9 @@ (.mkdirs (File. module-dir)) (&&/write-file (str module-dir java.io.File/separator name ".class") data))) -(defn class-exists? [^String module ^String class-name] - "(-> Text Text (IO Bool))" +(defn class-exists? + "(-> Text Text (IO Bit))" + [^String module ^String class-name] (|do [_ (return nil) :let [full-path (str @&&/!output-dir java.io.File/separator module java.io.File/separator class-name ".class") exists? (.exists (File. full-path))]] diff --git a/luxc/src/lux/compiler/jvm/case.clj b/luxc/src/lux/compiler/jvm/case.clj index 79e6c559c..4c195ba36 100644 --- a/luxc/src/lux/compiler/jvm/case.clj +++ b/luxc/src/lux/compiler/jvm/case.clj @@ -63,7 +63,7 @@ (.visitVarInsn Opcodes/ASTORE _var-id) (.visitMethodInsn Opcodes/INVOKESTATIC "lux/LuxRT" "pm_stack_pop" "([Ljava/lang/Object;)[Ljava/lang/Object;")) - (&o/$BoolPM _value) + (&o/$BitPM _value) (doto writer stack-peek &&/unwrap-boolean diff --git a/luxc/src/lux/compiler/jvm/lux.clj b/luxc/src/lux/compiler/jvm/lux.clj index 6a85e1075..d9b9f00d0 100644 --- a/luxc/src/lux/compiler/jvm/lux.clj +++ b/luxc/src/lux/compiler/jvm/lux.clj @@ -24,7 +24,7 @@ java.lang.reflect.Field)) ;; [Exports] -(defn compile-bool [?value] +(defn compile-bit [?value] (|do [^MethodVisitor *writer* &/get-writer :let [_ (.visitFieldInsn *writer* Opcodes/GETSTATIC "java/lang/Boolean" (if ?value "TRUE" "FALSE") "Ljava/lang/Boolean;")]] (return nil))) @@ -253,7 +253,7 @@ :let [def-class (&&/load-class! class-loader (&host-generics/->class-name current-class)) def-type (&a/expr-type* ?body) is-type? (|case (&a-meta/meta-get &a-meta/type?-tag ?meta) - (&/$Some [_ (&/$Bool true)]) + (&/$Some [_ (&/$Bit true)]) true _ diff --git a/luxc/src/lux/lexer.clj b/luxc/src/lux/lexer.clj index d56a901ff..be8f8b69a 100644 --- a/luxc/src/lux/lexer.clj +++ b/luxc/src/lux/lexer.clj @@ -9,7 +9,7 @@ (defvariant ("White_Space" 1) ("Comment" 1) - ("Bool" 1) + ("Bit" 1) ("Nat" 1) ("Int" 1) ("Rev" 1) @@ -130,7 +130,7 @@ (|do [[meta _ token] (&reader/read-regex )] (return (&/T [meta ( token)])))) - lex-bool $Bool #"^(true|false)" + lex-bit $Bit #"^(true|false)" ) (do-template [ ] @@ -205,7 +205,7 @@ (&/try-all-% "[Reader Error]" (&/|list lex-white-space lex-comment - lex-bool + lex-bit lex-nat lex-frac lex-rev diff --git a/luxc/src/lux/optimizer.clj b/luxc/src/lux/optimizer.clj index 8f331cc95..e1187594c 100644 --- a/luxc/src/lux/optimizer.clj +++ b/luxc/src/lux/optimizer.clj @@ -6,7 +6,7 @@ ;; [Tags] (defvariant ;; These tags just have a one-to-one correspondence with Analysis data-structures. - ("bool" 1) + ("bit" 1) ("nat" 1) ("int" 1) ("rev" 1) @@ -65,8 +65,8 @@ ("PopPM" 0) ;; Store the CDN in a register. ("BindPM" 1) - ;; Compare the CDN with a boolean value. - ("BoolPM" 1) + ;; Compare the CDN with a bit value. + ("BitPM" 1) ;; Compare the CDN with a natural value. ("NatPM" 1) ;; Compare the CDN with an integer value. @@ -174,8 +174,8 @@ (&a-case/$StoreTestAC _register) (&/|list ($BindPM _register)) - (&a-case/$BoolTestAC _value) - (&/|list ($BoolPM _value) + (&a-case/$BitTestAC _value) + (&/|list ($BitPM _value) $PopPM) (&a-case/$NatTestAC _value) @@ -275,9 +275,9 @@ ($BindPM _pre-var-id) ($AltPM pre post)) - [($BoolPM _pre-value) ($BoolPM _post-value)] + [($BitPM _pre-value) ($BitPM _post-value)] (if (= _pre-value _post-value) - ($BoolPM _pre-value) + ($BitPM _pre-value) ($AltPM pre post)) [($NatPM _pre-value) ($NatPM _post-value)] @@ -632,7 +632,7 @@ ;; Shifts the body of a function after a folding is performed. (defn shift-function-body - "(-> Scope Scope Bool Optimized Optimized)" + "(-> Scope Scope Bit Optimized Optimized)" [old-scope new-scope own-body? body] (|let [[meta body-] body] (|case body- @@ -818,7 +818,7 @@ ))) (defn ^:private contains-self-reference? - "(-> Optimized Bool)" + "(-> Optimized Bit)" [body] (|let [[meta body-] body stepwise-test (fn [base arg] (or base (contains-self-reference? arg)))] @@ -997,12 +997,12 @@ (&/T [_name (optimize _analysis)]))) closure))] (defn ^:private pass-0 - "(-> Bool Analysis Optimized)" + "(-> Bit Analysis Optimized)" [top-level-func? analysis] (|let [[meta analysis-] analysis] (|case analysis- - (&a/$bool value) - (&/T [meta ($bool value)]) + (&a/$bit value) + (&/T [meta ($bit value)]) (&a/$nat value) (&/T [meta ($nat value)]) @@ -1052,8 +1052,8 @@ (&/$Cons [(&a-case/$StoreTestAC _register) _body] (&/$Nil)) (&/T [meta ($let (pass-0 top-level-func? value) _register (pass-0 top-level-func? _body))]) - (&/$Cons [(&a-case/$BoolTestAC false) _else] - (&/$Cons [(&a-case/$BoolTestAC true) _then] + (&/$Cons [(&a-case/$BitTestAC false) _else] + (&/$Cons [(&a-case/$BitTestAC true) _then] (&/$Nil))) (&/T [meta ($if (pass-0 top-level-func? value) (pass-0 top-level-func? _then) (pass-0 top-level-func? _else))]) diff --git a/luxc/src/lux/parser.clj b/luxc/src/lux/parser.clj index 130a794ac..92a23da81 100644 --- a/luxc/src/lux/parser.clj +++ b/luxc/src/lux/parser.clj @@ -64,8 +64,8 @@ (&lexer/$Comment _) (return &/$Nil) - (&lexer/$Bool ?value) - (return (&/|list (&/T [meta (&/$Bool (Boolean/parseBoolean ?value))]))) + (&lexer/$Bit ?value) + (return (&/|list (&/T [meta (&/$Bit (Boolean/parseBoolean ?value))]))) (&lexer/$Nat ?value) (return (&/|list (&/T [meta (&/$Nat (Long/parseUnsignedLong ?value))]))) diff --git a/luxc/src/lux/type.clj b/luxc/src/lux/type.clj index 6cc33688e..8a498463e 100644 --- a/luxc/src/lux/type.clj +++ b/luxc/src/lux/type.clj @@ -32,7 +32,7 @@ (def Rev* (&/$Primitive &&host/rev-data-tag &/$Nil)) (def Int* (&/$Primitive &&host/int-data-tag &/$Nil)) -(def Bool (&/$Named (&/T ["lux" "Bool"]) (&/$Primitive "#Bool" &/$Nil))) +(def Bit (&/$Named (&/T ["lux" "Bit"]) (&/$Primitive "#Bit" &/$Nil))) (def Nat (&/$Named (&/T ["lux" "Nat"]) (&/$Apply Nat* I64))) (def Rev (&/$Named (&/T ["lux" "Rev"]) (&/$Apply Rev* I64))) (def Int (&/$Named (&/T ["lux" "Int"]) (&/$Apply Int* I64))) @@ -150,8 +150,8 @@ (&/$Parameter 1)) Code-List (&/$Apply Code List)] (&/$UnivQ empty-env - (&/$Sum ;; "lux;Bool" - Bool + (&/$Sum ;; "lux;Bit" + Bit (&/$Sum ;; "lux;Nat" Nat (&/$Sum ;; "lux;Int" @@ -886,7 +886,7 @@ )) (defn unknown? [type] - "(-> Type (Lux Bool))" + "(-> Type (Lux Bit))" (|case type (&/$Var id) (|do [? (bound? id)] diff --git a/luxc/src/lux/type/host.clj b/luxc/src/lux/type/host.clj index 474153316..e0eafdd73 100644 --- a/luxc/src/lux/type/host.clj +++ b/luxc/src/lux/type/host.clj @@ -310,7 +310,7 @@ (contains? primitive-types type-name))) (def ^:private lux-jvm-type-combos - #{#{"java.lang.Boolean" "#Bool"} + #{#{"java.lang.Boolean" "#Bit"} #{"java.lang.Long" i64-data-tag} #{"java.lang.Double" "#Frac"} #{"java.lang.String" "#Text"}}) -- cgit v1.2.3