From f08a9fb208a32ee8f450649095c4f8a0f05931da Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Mon, 4 Sep 2017 19:41:59 -0400 Subject: - Re-named "real" numbers to "frac"(tions). --- luxc/src/lux/analyser.clj | 6 +-- luxc/src/lux/analyser/base.clj | 2 +- luxc/src/lux/analyser/case.clj | 30 +++++------ luxc/src/lux/analyser/parser.clj | 4 +- luxc/src/lux/analyser/proc/common.clj | 88 +++++++++++++++---------------- luxc/src/lux/base.clj | 6 +-- luxc/src/lux/compiler/cache/ann.clj | 6 +-- luxc/src/lux/compiler/js.clj | 4 +- luxc/src/lux/compiler/js/lux.clj | 4 +- luxc/src/lux/compiler/js/proc/common.clj | 82 ++++++++++++++-------------- luxc/src/lux/compiler/js/rt.clj | 4 +- luxc/src/lux/compiler/jvm.clj | 4 +- luxc/src/lux/compiler/jvm/case.clj | 2 +- luxc/src/lux/compiler/jvm/lux.clj | 2 +- luxc/src/lux/compiler/jvm/proc/common.clj | 78 +++++++++++++-------------- luxc/src/lux/compiler/jvm/rt.clj | 8 +-- luxc/src/lux/lexer.clj | 6 +-- luxc/src/lux/optimizer.clj | 18 +++---- luxc/src/lux/parser.clj | 4 +- luxc/src/lux/type.clj | 6 +-- luxc/src/lux/type/host.clj | 2 +- 21 files changed, 183 insertions(+), 183 deletions(-) (limited to 'luxc') diff --git a/luxc/src/lux/analyser.clj b/luxc/src/lux/analyser.clj index 5ea8cf64b..807a7cc68 100644 --- a/luxc/src/lux/analyser.clj +++ b/luxc/src/lux/analyser.clj @@ -82,9 +82,9 @@ (|do [_ (&type/check exo-type &type/Deg)] (return (&/|list (&&/|meta exo-type cursor (&&/$deg ?value))))) - (&/$Real ?value) - (|do [_ (&type/check exo-type &type/Real)] - (return (&/|list (&&/|meta exo-type cursor (&&/$real ?value))))) + (&/$Frac ?value) + (|do [_ (&type/check exo-type &type/Frac)] + (return (&/|list (&&/|meta exo-type cursor (&&/$frac ?value))))) (&/$Text ?value) (|do [_ (&type/check exo-type &type/Text)] diff --git a/luxc/src/lux/analyser/base.clj b/luxc/src/lux/analyser/base.clj index bfe931546..9f44db3af 100644 --- a/luxc/src/lux/analyser/base.clj +++ b/luxc/src/lux/analyser/base.clj @@ -10,7 +10,7 @@ ("nat" 1) ("int" 1) ("deg" 1) - ("real" 1) + ("frac" 1) ("text" 1) ("variant" 3) ("tuple" 1) diff --git a/luxc/src/lux/analyser/case.clj b/luxc/src/lux/analyser/case.clj index fa9d568d0..a8fdd6f18 100644 --- a/luxc/src/lux/analyser/case.clj +++ b/luxc/src/lux/analyser/case.clj @@ -16,7 +16,7 @@ ("NatTotal" 2) ("IntTotal" 2) ("DegTotal" 2) - ("RealTotal" 2) + ("FracTotal" 2) ("TextTotal" 2) ("TupleTotal" 2) ("VariantTotal" 2)) @@ -28,7 +28,7 @@ ("NatTestAC" 1) ("IntTestAC" 1) ("DegTestAC" 1) - ("RealTestAC" 1) + ("FracTestAC" 1) ("TextTestAC" 1) ("TupleTestAC" 1) ("VariantTestAC" 1)) @@ -289,10 +289,10 @@ =kont kont] (return (&/T [($DegTestAC ?value) =kont]))) - (&/$Real ?value) - (|do [_ (&type/check value-type &type/Real) + (&/$Frac ?value) + (|do [_ (&type/check value-type &type/Frac) =kont kont] - (return (&/T [($RealTestAC ?value) =kont]))) + (return (&/T [($FracTestAC ?value) =kont]))) (&/$Text ?value) (|do [_ (&type/check value-type &type/Text) @@ -418,8 +418,8 @@ [($DegTotal total? ?values) ($NoTestAC)] (return ($DegTotal true ?values)) - [($RealTotal total? ?values) ($NoTestAC)] - (return ($RealTotal true ?values)) + [($FracTotal total? ?values) ($NoTestAC)] + (return ($FracTotal true ?values)) [($TextTotal total? ?values) ($NoTestAC)] (return ($TextTotal true ?values)) @@ -445,8 +445,8 @@ [($DegTotal total? ?values) ($StoreTestAC ?idx)] (return ($DegTotal true ?values)) - [($RealTotal total? ?values) ($StoreTestAC ?idx)] - (return ($RealTotal true ?values)) + [($FracTotal total? ?values) ($StoreTestAC ?idx)] + (return ($FracTotal true ?values)) [($TextTotal total? ?values) ($StoreTestAC ?idx)] (return ($TextTotal true ?values)) @@ -481,11 +481,11 @@ [($DegTotal total? ?values) ($DegTestAC ?value)] (return ($DegTotal total? (&/$Cons ?value ?values))) - [($DefaultTotal total?) ($RealTestAC ?value)] - (return ($RealTotal total? (&/|list ?value))) + [($DefaultTotal total?) ($FracTestAC ?value)] + (return ($FracTotal total? (&/|list ?value))) - [($RealTotal total? ?values) ($RealTestAC ?value)] - (return ($RealTotal total? (&/$Cons ?value ?values))) + [($FracTotal total? ?values) ($FracTestAC ?value)] + (return ($FracTotal total? (&/$Cons ?value ?values))) [($DefaultTotal total?) ($TextTestAC ?value)] (return ($TextTotal total? (&/|list ?value))) @@ -568,8 +568,8 @@ (|do [_ (&type/check value-type &type/Deg)] (return ?total)) - ($RealTotal ?total _) - (|do [_ (&type/check value-type &type/Real)] + ($FracTotal ?total _) + (|do [_ (&type/check value-type &type/Frac)] (return ?total)) ($TextTotal ?total _) diff --git a/luxc/src/lux/analyser/parser.clj b/luxc/src/lux/analyser/parser.clj index 731b5bace..c2420f21b 100644 --- a/luxc/src/lux/analyser/parser.clj +++ b/luxc/src/lux/analyser/parser.clj @@ -135,11 +135,11 @@ [_ (&lexer/$Int param-value*)] &lexer/lex-int] (return (long param-value*))) - (|do [[_ (&lexer/$Real param-value*)] &lexer/lex-real] + (|do [[_ (&lexer/$Frac param-value*)] &lexer/lex-frac] (return (float param-value*))) (|do [_ (&reader/read-text "d") - [_ (&lexer/$Real param-value*)] &lexer/lex-real] + [_ (&lexer/$Frac param-value*)] &lexer/lex-frac] (return (double param-value*))) (|do [[_ (&lexer/$Text param-value*)] &lexer/lex-text] diff --git a/luxc/src/lux/analyser/proc/common.clj b/luxc/src/lux/analyser/proc/common.clj index 27af2a08d..d05c68564 100644 --- a/luxc/src/lux/analyser/proc/common.clj +++ b/luxc/src/lux/analyser/proc/common.clj @@ -210,13 +210,13 @@ ^:private analyse-deg-eq ["deg" "="] &type/Deg &type/Bool ^:private analyse-deg-lt ["deg" "<"] &type/Deg &type/Bool - ^:private analyse-real-add ["real" "+"] &type/Real &type/Real - ^:private analyse-real-sub ["real" "-"] &type/Real &type/Real - ^:private analyse-real-mul ["real" "*"] &type/Real &type/Real - ^:private analyse-real-div ["real" "/"] &type/Real &type/Real - ^:private analyse-real-rem ["real" "%"] &type/Real &type/Real - ^:private analyse-real-eq ["real" "="] &type/Real &type/Bool - ^:private analyse-real-lt ["real" "<"] &type/Real &type/Bool + ^: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 ) (do-template [ ] @@ -251,7 +251,7 @@ (return (&/|list (&&/|meta exo-type _cursor (&&/$proc (&/T ) (&/|list =x) (&/|list))))))))) - ^:private analyse-real-encode ["real" "encode"] ^:private analyse-real-decode ["real" "decode"] &type/Real + ^:private analyse-frac-encode ["frac" "encode"] ^:private analyse-frac-decode ["frac" "decode"] &type/Frac ) (do-template [ ] @@ -271,12 +271,12 @@ ^:private analyse-deg-min-value &type/Deg ["deg" "min-value"] ^:private analyse-deg-max-value &type/Deg ["deg" "max-value"] - ^:private analyse-real-smallest-value &type/Real ["real" "smallest-value"] - ^:private analyse-real-min-value &type/Real ["real" "min-value"] - ^:private analyse-real-max-value &type/Real ["real" "max-value"] - ^:private analyse-real-not-a-number &type/Real ["real" "not-a-number"] - ^:private analyse-real-positive-infinity &type/Real ["real" "positive-infinity"] - ^:private analyse-real-negative-infinity &type/Real ["real" "negative-infinity"] + ^:private analyse-frac-smallest-value &type/Frac ["frac" "smallest-value"] + ^:private analyse-frac-min-value &type/Frac ["frac" "min-value"] + ^:private analyse-frac-max-value &type/Frac ["frac" "max-value"] + ^:private analyse-frac-not-a-number &type/Frac ["frac" "not-a-number"] + ^:private analyse-frac-positive-infinity &type/Frac ["frac" "positive-infinity"] + ^:private analyse-frac-negative-infinity &type/Frac ["frac" "negative-infinity"] ) (do-template [ ] @@ -293,11 +293,11 @@ ^:private analyse-nat-to-char &type/Nat &type/Text ["nat" "to-char"] - ^:private analyse-int-to-real &type/Int &type/Real ["int" "to-real"] - ^:private analyse-real-to-int &type/Real &type/Int ["real" "to-int"] + ^:private analyse-int-to-frac &type/Int &type/Frac ["int" "to-frac"] + ^:private analyse-frac-to-int &type/Frac &type/Int ["frac" "to-int"] - ^:private analyse-deg-to-real &type/Deg &type/Real ["deg" "to-real"] - ^:private analyse-real-to-deg &type/Real &type/Deg ["real" "to-deg"] + ^:private analyse-deg-to-frac &type/Deg &type/Frac ["deg" "to-frac"] + ^:private analyse-frac-to-deg &type/Frac &type/Deg ["frac" "to-deg"] ^:private analyse-io-log &type/Text &/$Unit ["io" "log"] ^:private analyse-io-error &type/Text &type/Bottom ["io" "error"] @@ -368,7 +368,7 @@ (do-template [ ] (defn [analyse exo-type ?values] (|do [:let [(&/$Nil) ?values] - _ (&type/check exo-type &type/Real) + _ (&type/check exo-type &type/Frac) _cursor &/cursor] (return (&/|list (&&/|meta exo-type _cursor (&&/$proc (&/T ["math" ]) (&/|list) (&/|list))))))) @@ -380,8 +380,8 @@ (do-template [ ] (defn [analyse exo-type ?values] (|do [:let [(&/$Cons ?input (&/$Nil)) ?values] - =input (&&/analyse-1 analyse &type/Real ?input) - _ (&type/check exo-type &type/Real) + =input (&&/analyse-1 analyse &type/Frac ?input) + _ (&type/check exo-type &type/Frac) _cursor &/cursor] (return (&/|list (&&/|meta exo-type _cursor (&&/$proc (&/T ["math" ]) (&/|list =input) (&/|list))))))) @@ -407,9 +407,9 @@ (do-template [ ] (defn [analyse exo-type ?values] (|do [:let [(&/$Cons ?input (&/$Cons ?param (&/$Nil))) ?values] - =input (&&/analyse-1 analyse &type/Real ?input) - =param (&&/analyse-1 analyse &type/Real ?param) - _ (&type/check exo-type &type/Real) + =input (&&/analyse-1 analyse &type/Frac ?input) + =param (&&/analyse-1 analyse &type/Frac ?param) + _ (&type/check exo-type &type/Frac) _cursor &/cursor] (return (&/|list (&&/|meta exo-type _cursor (&&/$proc (&/T ["math" ]) (&/|list =input =param) (&/|list))))))) @@ -552,7 +552,7 @@ "min-value" (analyse-int-min-value analyse exo-type ?values) "max-value" (analyse-int-max-value analyse exo-type ?values) "to-nat" (analyse-int-to-nat analyse exo-type ?values) - "to-real" (analyse-int-to-real analyse exo-type ?values) + "to-frac" (analyse-int-to-frac analyse exo-type ?values) ) "deg" @@ -566,30 +566,30 @@ "<" (analyse-deg-lt analyse exo-type ?values) "min-value" (analyse-deg-min-value analyse exo-type ?values) "max-value" (analyse-deg-max-value analyse exo-type ?values) - "to-real" (analyse-deg-to-real analyse exo-type ?values) + "to-frac" (analyse-deg-to-frac analyse exo-type ?values) "scale" (analyse-deg-scale analyse exo-type ?values) "reciprocal" (analyse-deg-reciprocal analyse exo-type ?values) ) - "real" + "frac" (case proc - "+" (analyse-real-add analyse exo-type ?values) - "-" (analyse-real-sub analyse exo-type ?values) - "*" (analyse-real-mul analyse exo-type ?values) - "/" (analyse-real-div analyse exo-type ?values) - "%" (analyse-real-rem analyse exo-type ?values) - "=" (analyse-real-eq analyse exo-type ?values) - "<" (analyse-real-lt analyse exo-type ?values) - "encode" (analyse-real-encode analyse exo-type ?values) - "decode" (analyse-real-decode analyse exo-type ?values) - "smallest-value" (analyse-real-smallest-value analyse exo-type ?values) - "min-value" (analyse-real-min-value analyse exo-type ?values) - "max-value" (analyse-real-max-value analyse exo-type ?values) - "not-a-number" (analyse-real-not-a-number analyse exo-type ?values) - "positive-infinity" (analyse-real-positive-infinity analyse exo-type ?values) - "negative-infinity" (analyse-real-negative-infinity analyse exo-type ?values) - "to-deg" (analyse-real-to-deg analyse exo-type ?values) - "to-int" (analyse-real-to-int analyse exo-type ?values) + "+" (analyse-frac-add analyse exo-type ?values) + "-" (analyse-frac-sub analyse exo-type ?values) + "*" (analyse-frac-mul analyse exo-type ?values) + "/" (analyse-frac-div analyse exo-type ?values) + "%" (analyse-frac-rem analyse exo-type ?values) + "=" (analyse-frac-eq analyse exo-type ?values) + "<" (analyse-frac-lt analyse exo-type ?values) + "encode" (analyse-frac-encode analyse exo-type ?values) + "decode" (analyse-frac-decode analyse exo-type ?values) + "smallest-value" (analyse-frac-smallest-value analyse exo-type ?values) + "min-value" (analyse-frac-min-value analyse exo-type ?values) + "max-value" (analyse-frac-max-value analyse exo-type ?values) + "not-a-number" (analyse-frac-not-a-number analyse exo-type ?values) + "positive-infinity" (analyse-frac-positive-infinity analyse exo-type ?values) + "negative-infinity" (analyse-frac-negative-infinity analyse exo-type ?values) + "to-deg" (analyse-frac-to-deg analyse exo-type ?values) + "to-int" (analyse-frac-to-int analyse exo-type ?values) ) "math" diff --git a/luxc/src/lux/base.clj b/luxc/src/lux/base.clj index 8a7378586..172ade295 100644 --- a/luxc/src/lux/base.clj +++ b/luxc/src/lux/base.clj @@ -75,7 +75,7 @@ ("Nat" 1) ("Int" 1) ("Deg" 1) - ("Real" 1) + ("Frac" 1) ("Text" 1) ("Symbol" 1) ("Tag" 1) @@ -221,7 +221,7 @@ ("NatA" 1) ("IntA" 1) ("DegA" 1) - ("RealA" 1) + ("FracA" 1) ("TextA" 1) ("IdentA" 1) ("ListA" 1) @@ -1217,7 +1217,7 @@ [_ ($Deg ?value)] (encode-deg ?value) - [_ ($Real ?value)] + [_ ($Frac ?value)] (pr-str ?value) [_ ($Text ?value)] diff --git a/luxc/src/lux/compiler/cache/ann.clj b/luxc/src/lux/compiler/cache/ann.clj index 35a41f247..6ee941bf8 100644 --- a/luxc/src/lux/compiler/cache/ann.clj +++ b/luxc/src/lux/compiler/cache/ann.clj @@ -40,7 +40,7 @@ (&/$DegA value) (str "D" value stop) - (&/$RealA value) + (&/$FracA value) (str "R" value stop) (&/$TextA value) @@ -84,7 +84,7 @@ ^:private deserialize-nat "N" &/$NatA Long/parseLong ^:private deserialize-int "I" &/$IntA Long/parseLong ^:private deserialize-deg "D" &/$DegA Long/parseLong - ^:private deserialize-real "R" &/$RealA Double/parseDouble + ^:private deserialize-frac "R" &/$FracA Double/parseDouble ^:private deserialize-text "T" &/$TextA identity ) @@ -138,7 +138,7 @@ (deserialize-nat input) (deserialize-int input) (deserialize-deg input) - (deserialize-real input) + (deserialize-frac input) (deserialize-text input) (deserialize-ident input) (deserialize-list input) diff --git a/luxc/src/lux/compiler/js.clj b/luxc/src/lux/compiler/js.clj index b618b7b1b..6eff83688 100644 --- a/luxc/src/lux/compiler/js.clj +++ b/luxc/src/lux/compiler/js.clj @@ -48,8 +48,8 @@ (&o/$deg ?value) (&&lux/compile-deg ?value) - (&o/$real ?value) - (&&lux/compile-real ?value) + (&o/$frac ?value) + (&&lux/compile-frac ?value) (&o/$text ?value) (&&lux/compile-text ?value) diff --git a/luxc/src/lux/compiler/js/lux.clj b/luxc/src/lux/compiler/js/lux.clj index 593055b8b..0be8f1cae 100644 --- a/luxc/src/lux/compiler/js/lux.clj +++ b/luxc/src/lux/compiler/js/lux.clj @@ -42,7 +42,7 @@ compile-deg ) -(defn compile-real [value] +(defn compile-frac [value] (return (str value))) (defn compile-char [value] @@ -189,7 +189,7 @@ (|do [=value (compile-deg _value)] (return (str "if(!" (str "LuxRT$eqI64(" cursor-peek "," =value ")") ") { " pm-fail " }"))) - (&o/$RealPM _value) + (&o/$FracPM _value) (return (str "if(" cursor-peek " !== " _value ") { " pm-fail " }")) (&o/$TextPM _value) diff --git a/luxc/src/lux/compiler/js/proc/common.clj b/luxc/src/lux/compiler/js/proc/common.clj index 871f5e15b..a45bc2993 100644 --- a/luxc/src/lux/compiler/js/proc/common.clj +++ b/luxc/src/lux/compiler/js/proc/common.clj @@ -132,13 +132,13 @@ =y (compile ?y)] (return (str "(" =x " " " " =y ")")))) - ^:private compile-real-add "+" - ^:private compile-real-sub "-" - ^:private compile-real-mul "*" - ^:private compile-real-div "/" - ^:private compile-real-rem "%" - ^:private compile-real-eq "===" - ^:private compile-real-lt "<" + ^:private compile-frac-add "+" + ^:private compile-frac-sub "-" + ^:private compile-frac-mul "*" + ^:private compile-frac-div "/" + ^:private compile-frac-rem "%" + ^:private compile-frac-eq "===" + ^:private compile-frac-lt "<" ) (do-template [ ] @@ -148,7 +148,7 @@ (return (str "LuxRT$" "(" =x ")")) )) - ^:private compile-real-decode "decodeReal" + ^:private compile-frac-decode "decodeFrac" ) (do-template [ ] @@ -165,16 +165,16 @@ ^:private compile-deg-min-value &&lux/compile-deg 0 ^:private compile-deg-max-value &&lux/compile-deg -1 - ^:private compile-real-smallest-value &&lux/compile-real Double/MIN_VALUE - ^:private compile-real-min-value &&lux/compile-real (* -1.0 Double/MAX_VALUE) - ^:private compile-real-max-value &&lux/compile-real Double/MAX_VALUE + ^:private compile-frac-smallest-value &&lux/compile-frac Double/MIN_VALUE + ^:private compile-frac-min-value &&lux/compile-frac (* -1.0 Double/MAX_VALUE) + ^:private compile-frac-max-value &&lux/compile-frac Double/MAX_VALUE - ^:private compile-real-not-a-number &&lux/compile-real "NaN" - ^:private compile-real-positive-infinity &&lux/compile-real "Infinity" - ^:private compile-real-negative-infinity &&lux/compile-real "-Infinity" + ^:private compile-frac-not-a-number &&lux/compile-frac "NaN" + ^:private compile-frac-positive-infinity &&lux/compile-frac "Infinity" + ^:private compile-frac-negative-infinity &&lux/compile-frac "-Infinity" ) -(defn ^:private compile-real-encode [compile ?values special-args] +(defn ^:private compile-frac-encode [compile ?values special-args] (|do [:let [(&/$Cons ?x (&/$Nil)) ?values] =x (compile ?x)] (return (str "(" =x ")" ".toString()")))) @@ -188,25 +188,25 @@ ^:private compile-int-to-nat ) -(defn ^:private compile-int-to-real [compile ?values special-args] +(defn ^:private compile-int-to-frac [compile ?values special-args] (|do [:let [(&/$Cons ?x (&/$Nil)) ?values] =x (compile ?x)] (return (str "LuxRT$toNumberI64(" =x ")")))) -(defn ^:private compile-real-to-int [compile ?values special-args] +(defn ^:private compile-frac-to-int [compile ?values special-args] (|do [:let [(&/$Cons ?x (&/$Nil)) ?values] =x (compile ?x)] (return (str "LuxRT$fromNumberI64(" =x ")")))) -(defn ^:private compile-deg-to-real [compile ?values special-args] +(defn ^:private compile-deg-to-frac [compile ?values special-args] (|do [:let [(&/$Cons ?x (&/$Nil)) ?values] =x (compile ?x)] - (return (str "LuxRT$degToReal(" =x ")")))) + (return (str "LuxRT$degToFrac(" =x ")")))) -(defn ^:private compile-real-to-deg [compile ?values special-args] +(defn ^:private compile-frac-to-deg [compile ?values special-args] (|do [:let [(&/$Cons ?x (&/$Nil)) ?values] =x (compile ?x)] - (return (str "LuxRT$realToDeg(" =x ")")))) + (return (str "LuxRT$fracToDeg(" =x ")")))) (do-template [ ] (defn [compile ?values special-args] @@ -505,7 +505,7 @@ "max-value" (compile-int-max-value compile ?values special-args) "min-value" (compile-int-min-value compile ?values special-args) "to-nat" (compile-int-to-nat compile ?values special-args) - "to-real" (compile-int-to-real compile ?values special-args) + "to-frac" (compile-int-to-frac compile ?values special-args) ) "deg" @@ -519,30 +519,30 @@ "<" (compile-deg-lt compile ?values special-args) "max-value" (compile-deg-max-value compile ?values special-args) "min-value" (compile-deg-min-value compile ?values special-args) - "to-real" (compile-deg-to-real compile ?values special-args) + "to-frac" (compile-deg-to-frac compile ?values special-args) "scale" (compile-deg-scale compile ?values special-args) "reciprocal" (compile-deg-reciprocal compile ?values special-args) ) - "real" + "frac" (case proc - "+" (compile-real-add compile ?values special-args) - "-" (compile-real-sub compile ?values special-args) - "*" (compile-real-mul compile ?values special-args) - "/" (compile-real-div compile ?values special-args) - "%" (compile-real-rem compile ?values special-args) - "=" (compile-real-eq compile ?values special-args) - "<" (compile-real-lt compile ?values special-args) - "encode" (compile-real-encode compile ?values special-args) - "decode" (compile-real-decode compile ?values special-args) - "smallest-value" (compile-real-smallest-value compile ?values special-args) - "max-value" (compile-real-max-value compile ?values special-args) - "min-value" (compile-real-min-value compile ?values special-args) - "not-a-number" (compile-real-not-a-number compile ?values special-args) - "positive-infinity" (compile-real-positive-infinity compile ?values special-args) - "negative-infinity" (compile-real-negative-infinity compile ?values special-args) - "to-deg" (compile-real-to-deg compile ?values special-args) - "to-int" (compile-real-to-int compile ?values special-args) + "+" (compile-frac-add compile ?values special-args) + "-" (compile-frac-sub compile ?values special-args) + "*" (compile-frac-mul compile ?values special-args) + "/" (compile-frac-div compile ?values special-args) + "%" (compile-frac-rem compile ?values special-args) + "=" (compile-frac-eq compile ?values special-args) + "<" (compile-frac-lt compile ?values special-args) + "encode" (compile-frac-encode compile ?values special-args) + "decode" (compile-frac-decode compile ?values special-args) + "smallest-value" (compile-frac-smallest-value compile ?values special-args) + "max-value" (compile-frac-max-value compile ?values special-args) + "min-value" (compile-frac-min-value compile ?values special-args) + "not-a-number" (compile-frac-not-a-number compile ?values special-args) + "positive-infinity" (compile-frac-positive-infinity compile ?values special-args) + "negative-infinity" (compile-frac-negative-infinity compile ?values special-args) + "to-deg" (compile-frac-to-deg compile ?values special-args) + "to-int" (compile-frac-to-int compile ?values special-args) ) "char" diff --git a/luxc/src/lux/compiler/js/rt.clj b/luxc/src/lux/compiler/js/rt.clj index 838598bbb..04ee6fc69 100644 --- a/luxc/src/lux/compiler/js/rt.clj +++ b/luxc/src/lux/compiler/js/rt.clj @@ -637,13 +637,13 @@ "return LuxRT$shlI64(LuxRT$divI64(l,LuxRT$fromNumberI64(r.H)),32);" "}") "})") - "degToReal" (str "(function LuxRT$degToReal(input) {" + "degToFrac" (str "(function LuxRT$degToFrac(input) {" "var two32 = Math.pow(2,32);" "var high = input.H / two32;" "var low = (input.L / two32) / two32;" "return high+low;" "})") - "realToDeg" (str "(function LuxRT$realToDeg(input) {" + "fracToDeg" (str "(function LuxRT$fracToDeg(input) {" "var two32 = Math.pow(2,32);" "var shifted = (input % 1.0) * two32;" "var low = ((shifted % 1.0) * two32) | 0;" diff --git a/luxc/src/lux/compiler/jvm.clj b/luxc/src/lux/compiler/jvm.clj index 5c11c0c6d..e54f92d91 100644 --- a/luxc/src/lux/compiler/jvm.clj +++ b/luxc/src/lux/compiler/jvm.clj @@ -59,8 +59,8 @@ (&o/$deg ?value) (&&lux/compile-deg ?value) - (&o/$real ?value) - (&&lux/compile-real ?value) + (&o/$frac ?value) + (&&lux/compile-frac ?value) (&o/$text ?value) (&&lux/compile-text ?value) diff --git a/luxc/src/lux/compiler/jvm/case.clj b/luxc/src/lux/compiler/jvm/case.clj index c205381e8..38f3ad4fc 100644 --- a/luxc/src/lux/compiler/jvm/case.clj +++ b/luxc/src/lux/compiler/jvm/case.clj @@ -93,7 +93,7 @@ (.visitInsn Opcodes/LCMP) (.visitJumpInsn Opcodes/IFNE $else)) - (&o/$RealPM _value) + (&o/$FracPM _value) (doto writer stack-peek &&/unwrap-double diff --git a/luxc/src/lux/compiler/jvm/lux.clj b/luxc/src/lux/compiler/jvm/lux.clj index 123676d35..99e55c3a0 100644 --- a/luxc/src/lux/compiler/jvm/lux.clj +++ b/luxc/src/lux/compiler/jvm/lux.clj @@ -40,7 +40,7 @@ compile-nat "java/lang/Long" "J" long compile-int "java/lang/Long" "J" long compile-deg "java/lang/Long" "J" long - compile-real "java/lang/Double" "D" double + compile-frac "java/lang/Double" "D" double ) (defn compile-text [?value] diff --git a/luxc/src/lux/compiler/jvm/proc/common.clj b/luxc/src/lux/compiler/jvm/proc/common.clj index 7c44f3434..757f66afd 100644 --- a/luxc/src/lux/compiler/jvm/proc/common.clj +++ b/luxc/src/lux/compiler/jvm/proc/common.clj @@ -218,11 +218,11 @@ ^:private compile-deg-scale Opcodes/LMUL &&/unwrap-long &&/wrap-long ^:private compile-deg-reciprocal Opcodes/LDIV &&/unwrap-long &&/wrap-long - ^:private compile-real-add Opcodes/DADD &&/unwrap-double &&/wrap-double - ^:private compile-real-sub Opcodes/DSUB &&/unwrap-double &&/wrap-double - ^:private compile-real-mul Opcodes/DMUL &&/unwrap-double &&/wrap-double - ^:private compile-real-div Opcodes/DDIV &&/unwrap-double &&/wrap-double - ^:private compile-real-rem Opcodes/DREM &&/unwrap-double &&/wrap-double + ^:private compile-frac-add Opcodes/DADD &&/unwrap-double &&/wrap-double + ^:private compile-frac-sub Opcodes/DSUB &&/unwrap-double &&/wrap-double + ^:private compile-frac-mul Opcodes/DMUL &&/unwrap-double &&/wrap-double + ^:private compile-frac-div Opcodes/DDIV &&/unwrap-double &&/wrap-double + ^:private compile-frac-rem Opcodes/DREM &&/unwrap-double &&/wrap-double ) (do-template [ ] @@ -270,8 +270,8 @@ ^:private compile-int-eq Opcodes/LCMP 0 &&/unwrap-long ^:private compile-int-lt Opcodes/LCMP -1 &&/unwrap-long - ^:private compile-real-eq Opcodes/DCMPG 0 &&/unwrap-double - ^:private compile-real-lt Opcodes/DCMPG -1 &&/unwrap-double + ^:private compile-frac-eq Opcodes/DCMPG 0 &&/unwrap-double + ^:private compile-frac-lt Opcodes/DCMPG -1 &&/unwrap-double ) (do-template [ ] @@ -343,13 +343,13 @@ ^:private compile-deg-min-value (.visitLdcInsn 0) &&/wrap-long ^:private compile-deg-max-value (.visitLdcInsn -1) &&/wrap-long - ^:private compile-real-smallest-value (.visitLdcInsn Double/MIN_VALUE) &&/wrap-double - ^:private compile-real-min-value (.visitLdcInsn (* -1.0 Double/MAX_VALUE)) &&/wrap-double - ^:private compile-real-max-value (.visitLdcInsn Double/MAX_VALUE) &&/wrap-double + ^:private compile-frac-smallest-value (.visitLdcInsn Double/MIN_VALUE) &&/wrap-double + ^:private compile-frac-min-value (.visitLdcInsn (* -1.0 Double/MAX_VALUE)) &&/wrap-double + ^:private compile-frac-max-value (.visitLdcInsn Double/MAX_VALUE) &&/wrap-double - ^:private compile-real-not-a-number (.visitLdcInsn Double/NaN) &&/wrap-double - ^:private compile-real-positive-infinity (.visitLdcInsn Double/POSITIVE_INFINITY) &&/wrap-double - ^:private compile-real-negative-infinity (.visitLdcInsn Double/NEGATIVE_INFINITY) &&/wrap-double + ^:private compile-frac-not-a-number (.visitLdcInsn Double/NaN) &&/wrap-double + ^:private compile-frac-positive-infinity (.visitLdcInsn Double/POSITIVE_INFINITY) &&/wrap-double + ^:private compile-frac-negative-infinity (.visitLdcInsn Double/NEGATIVE_INFINITY) &&/wrap-double ) (do-template [ ] @@ -362,7 +362,7 @@ (.visitMethodInsn Opcodes/INVOKESTATIC "toString" ))]] (return nil))) - ^:private compile-real-encode "java/lang/Double" "(D)Ljava/lang/String;" &&/unwrap-double + ^:private compile-frac-encode "java/lang/Double" "(D)Ljava/lang/String;" &&/unwrap-double ) @@ -377,7 +377,7 @@ (return nil))) ^:private compile-int-decode "decode_int" - ^:private compile-real-decode "decode_real" + ^:private compile-frac-decode "decode_frac" ) (do-template [ ] @@ -411,8 +411,8 @@ )]] (return nil)))) - ^:private compile-deg-to-real "java.lang.Long" "deg-to-real" "(J)D" &&/unwrap-long &&/wrap-double - ^:private compile-real-to-deg "java.lang.Double" "real-to-deg" "(D)J" &&/unwrap-double &&/wrap-long + ^:private compile-deg-to-frac "java.lang.Long" "deg-to-frac" "(J)D" &&/unwrap-long &&/wrap-double + ^:private compile-frac-to-deg "java.lang.Double" "frac-to-deg" "(D)J" &&/unwrap-double &&/wrap-long ) (defn ^:private compile-nat-to-char [compile ?values special-args] @@ -448,8 +448,8 @@ )]] (return nil))) - ^:private compile-real-to-int &&/unwrap-double Opcodes/D2L &&/wrap-long - ^:private compile-int-to-real &&/unwrap-long Opcodes/L2D &&/wrap-double + ^:private compile-frac-to-int &&/unwrap-double Opcodes/D2L &&/wrap-long + ^:private compile-int-to-frac &&/unwrap-long Opcodes/L2D &&/wrap-double ) (defn ^:private compile-text-eq [compile ?values special-args] @@ -883,7 +883,7 @@ "<" (compile-deg-lt compile ?values special-args) "max-value" (compile-deg-max-value compile ?values special-args) "min-value" (compile-deg-min-value compile ?values special-args) - "to-real" (compile-deg-to-real compile ?values special-args) + "to-frac" (compile-deg-to-frac compile ?values special-args) "scale" (compile-deg-scale compile ?values special-args) "reciprocal" (compile-deg-reciprocal compile ?values special-args) ) @@ -900,28 +900,28 @@ "max-value" (compile-int-max-value compile ?values special-args) "min-value" (compile-int-min-value compile ?values special-args) "to-nat" (compile-int-to-nat compile ?values special-args) - "to-real" (compile-int-to-real compile ?values special-args) + "to-frac" (compile-int-to-frac compile ?values special-args) ) - "real" + "frac" (case proc - "+" (compile-real-add compile ?values special-args) - "-" (compile-real-sub compile ?values special-args) - "*" (compile-real-mul compile ?values special-args) - "/" (compile-real-div compile ?values special-args) - "%" (compile-real-rem compile ?values special-args) - "=" (compile-real-eq compile ?values special-args) - "<" (compile-real-lt compile ?values special-args) - "smallest-value" (compile-real-smallest-value compile ?values special-args) - "max-value" (compile-real-max-value compile ?values special-args) - "min-value" (compile-real-min-value compile ?values special-args) - "not-a-number" (compile-real-not-a-number compile ?values special-args) - "positive-infinity" (compile-real-positive-infinity compile ?values special-args) - "negative-infinity" (compile-real-negative-infinity compile ?values special-args) - "to-int" (compile-real-to-int compile ?values special-args) - "to-deg" (compile-real-to-deg compile ?values special-args) - "encode" (compile-real-encode compile ?values special-args) - "decode" (compile-real-decode compile ?values special-args) + "+" (compile-frac-add compile ?values special-args) + "-" (compile-frac-sub compile ?values special-args) + "*" (compile-frac-mul compile ?values special-args) + "/" (compile-frac-div compile ?values special-args) + "%" (compile-frac-rem compile ?values special-args) + "=" (compile-frac-eq compile ?values special-args) + "<" (compile-frac-lt compile ?values special-args) + "smallest-value" (compile-frac-smallest-value compile ?values special-args) + "max-value" (compile-frac-max-value compile ?values special-args) + "min-value" (compile-frac-min-value compile ?values special-args) + "not-a-number" (compile-frac-not-a-number compile ?values special-args) + "positive-infinity" (compile-frac-positive-infinity compile ?values special-args) + "negative-infinity" (compile-frac-negative-infinity compile ?values special-args) + "to-int" (compile-frac-to-int compile ?values special-args) + "to-deg" (compile-frac-to-deg compile ?values special-args) + "encode" (compile-frac-encode compile ?values special-args) + "decode" (compile-frac-decode compile ?values special-args) ) "math" diff --git a/luxc/src/lux/compiler/jvm/rt.clj b/luxc/src/lux/compiler/jvm/rt.clj index b2670b9ef..83f02af3e 100644 --- a/luxc/src/lux/compiler/jvm/rt.clj +++ b/luxc/src/lux/compiler/jvm/rt.clj @@ -416,7 +416,7 @@ (.visitInsn Opcodes/LRETURN) (.visitMaxs 0 0) (.visitEnd))) - _ (doto (.visitMethod =class (+ Opcodes/ACC_PUBLIC Opcodes/ACC_STATIC) "deg-to-real" "(J)D" nil nil) + _ (doto (.visitMethod =class (+ Opcodes/ACC_PUBLIC Opcodes/ACC_STATIC) "deg-to-frac" "(J)D" nil nil) (.visitCode) ;; Translate high bytes (.visitVarInsn Opcodes/LLOAD 0) high-4b @@ -435,7 +435,7 @@ (.visitInsn Opcodes/DRETURN) (.visitMaxs 0 0) (.visitEnd)) - _ (doto (.visitMethod =class (+ Opcodes/ACC_PUBLIC Opcodes/ACC_STATIC) "real-to-deg" "(D)J" nil nil) + _ (doto (.visitMethod =class (+ Opcodes/ACC_PUBLIC Opcodes/ACC_STATIC) "frac-to-deg" "(D)J" nil nil) (.visitCode) ;; Drop any excess (.visitVarInsn Opcodes/DLOAD 0) @@ -619,7 +619,7 @@ nil)) ^:private compile-LuxRT-int-methods "decode_int" "java/lang/Long" "parseLong" "(Ljava/lang/String;)J" &&/wrap-long - ^:private compile-LuxRT-real-methods "decode_real" "java/lang/Double" "parseDouble" "(Ljava/lang/String;)D" &&/wrap-double + ^:private compile-LuxRT-frac-methods "decode_frac" "java/lang/Double" "parseDouble" "(Ljava/lang/String;)D" &&/wrap-double ) (defn ^:private compile-LuxRT-pm-methods [^ClassWriter =class] @@ -889,7 +889,7 @@ (compile-LuxRT-nat-methods) (compile-LuxRT-int-methods) (compile-LuxRT-deg-methods) - (compile-LuxRT-real-methods) + (compile-LuxRT-frac-methods) (compile-LuxRT-text-methods) (compile-LuxRT-process-methods))]] (&&/save-class! (second (string/split &&/lux-utils-class #"/")) diff --git a/luxc/src/lux/lexer.clj b/luxc/src/lux/lexer.clj index dbdeef6a8..65a99de6a 100644 --- a/luxc/src/lux/lexer.clj +++ b/luxc/src/lux/lexer.clj @@ -13,7 +13,7 @@ ("Nat" 1) ("Int" 1) ("Deg" 1) - ("Real" 1) + ("Frac" 1) ("Text" 1) ("Symbol" 1) ("Tag" 1) @@ -141,7 +141,7 @@ lex-nat $Nat #"^\+(0|[1-9][0-9_]*)" lex-int $Int #"^-?(0|[1-9][0-9_]*)" lex-deg $Deg #"^(\.[0-9_]+)" - lex-real $Real #"^-?(0\.[0-9_]+|[1-9][0-9_]*\.[0-9_]+)(e-?[1-9][0-9_]*)?" + lex-frac $Frac #"^-?(0\.[0-9_]+|[1-9][0-9_]*\.[0-9_]+)(e-?[1-9][0-9_]*)?" ) (def ^:private lex-ident @@ -205,7 +205,7 @@ lex-comment lex-bool lex-nat - lex-real + lex-frac lex-deg lex-int lex-text diff --git a/luxc/src/lux/optimizer.clj b/luxc/src/lux/optimizer.clj index 107435f92..72dd1e4a5 100644 --- a/luxc/src/lux/optimizer.clj +++ b/luxc/src/lux/optimizer.clj @@ -10,7 +10,7 @@ ("nat" 1) ("int" 1) ("deg" 1) - ("real" 1) + ("frac" 1) ("text" 1) ("variant" 3) ("tuple" 1) @@ -73,8 +73,8 @@ ("IntPM" 1) ;; Compare the CDN with a degree value. ("DegPM" 1) - ;; Compare the CDN with a real value. - ("RealPM" 1) + ;; Compare the CDN with a frac value. + ("FracPM" 1) ;; Compare the CDN with a text value. ("TextPM" 1) ;; Compare the CDN with a variant value. If valid, proceed to test @@ -190,8 +190,8 @@ (&/|list ($DegPM _value) $PopPM) - (&a-case/$RealTestAC _value) - (&/|list ($RealPM _value) + (&a-case/$FracTestAC _value) + (&/|list ($FracPM _value) $PopPM) (&a-case/$TextTestAC _value) @@ -295,9 +295,9 @@ ($DegPM _pre-value) ($AltPM pre post)) - [($RealPM _pre-value) ($RealPM _post-value)] + [($FracPM _pre-value) ($FracPM _post-value)] (if (= _pre-value _post-value) - ($RealPM _pre-value) + ($FracPM _pre-value) ($AltPM pre post)) [($TextPM _pre-value) ($TextPM _post-value)] @@ -1013,8 +1013,8 @@ (&a/$deg value) (&/T [meta ($deg value)]) - (&a/$real value) - (&/T [meta ($real value)]) + (&a/$frac value) + (&/T [meta ($frac value)]) (&a/$text value) (&/T [meta ($text value)]) diff --git a/luxc/src/lux/parser.clj b/luxc/src/lux/parser.clj index 7c9076aee..6bc2190a7 100644 --- a/luxc/src/lux/parser.clj +++ b/luxc/src/lux/parser.clj @@ -76,8 +76,8 @@ (&lexer/$Deg ?value) (return (&/|list (&/T [meta (&/$Deg (&/decode-deg ?value))]))) - (&lexer/$Real ?value) - (return (&/|list (&/T [meta (&/$Real (Double/parseDouble ?value))]))) + (&lexer/$Frac ?value) + (return (&/|list (&/T [meta (&/$Frac (Double/parseDouble ?value))]))) (&lexer/$Text ?value) (return (&/|list (&/T [meta (&/$Text ?value)]))) diff --git a/luxc/src/lux/type.clj b/luxc/src/lux/type.clj index e6cc86fff..dd7a49610 100644 --- a/luxc/src/lux/type.clj +++ b/luxc/src/lux/type.clj @@ -27,7 +27,7 @@ (def Nat (&/$Named (&/T ["lux" "Nat"]) (&/$Host &&host/nat-data-tag &/$Nil))) (def Deg (&/$Named (&/T ["lux" "Deg"]) (&/$Host &&host/deg-data-tag &/$Nil))) (def Int (&/$Named (&/T ["lux" "Int"]) (&/$Host "#Int" &/$Nil))) -(def Real (&/$Named (&/T ["lux" "Real"]) (&/$Host "#Real" &/$Nil))) +(def Frac (&/$Named (&/T ["lux" "Frac"]) (&/$Host "#Frac" &/$Nil))) (def Text (&/$Named (&/T ["lux" "Text"]) (&/$Host "#Text" &/$Nil))) (def Ident (&/$Named (&/T ["lux" "Ident"]) (&/$Product Text Text))) @@ -140,8 +140,8 @@ ;; DegA Deg (&/$Sum - ;; RealA - Real + ;; FracA + Frac (&/$Sum ;; TextA Text diff --git a/luxc/src/lux/type/host.clj b/luxc/src/lux/type/host.clj index 7d894b4df..82f14812d 100644 --- a/luxc/src/lux/type/host.clj +++ b/luxc/src/lux/type/host.clj @@ -255,7 +255,7 @@ (def ^:private lux-jvm-type-combos #{#{"java.lang.Boolean" "#Bool"} #{"java.lang.Long" "#Int"} - #{"java.lang.Double" "#Real"} + #{"java.lang.Double" "#Frac"} #{"java.lang.Character" "#Char"} #{"java.lang.String" "#Text"}}) -- cgit v1.2.3