From f8c2389db4a9b3239b00b9d209237d5116e12e3c Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Wed, 25 Jan 2017 07:02:33 -0400 Subject: - Renamed lux/data/struct/tree to lux/data/struct/tree/rose. - Moved lux/data/struct/zipper to lux/data/struct/tree/zipper. - Moved lux/regex to lux/lexer/regex. - Changed the suffix of annotation tags, from M to A. - Renamed Frac(tional) numbers to Deg(rees). --- luxc/src/lux.clj | 10 +-- luxc/src/lux/analyser.clj | 6 +- luxc/src/lux/analyser/base.clj | 2 +- luxc/src/lux/analyser/case.clj | 30 ++++---- luxc/src/lux/analyser/host.clj | 64 ++++++++--------- luxc/src/lux/analyser/module.clj | 14 ++-- luxc/src/lux/base.clj | 98 +++++++++++++------------- luxc/src/lux/compiler.clj | 4 +- luxc/src/lux/compiler/cache.clj | 2 +- luxc/src/lux/compiler/cache/ann.clj | 44 ++++++------ luxc/src/lux/compiler/case.clj | 2 +- luxc/src/lux/compiler/host.clj | 134 ++++++++++++++++++------------------ luxc/src/lux/compiler/lux.clj | 16 ++--- luxc/src/lux/lexer.clj | 14 ++-- luxc/src/lux/optimizer.clj | 22 +++--- luxc/src/lux/parser.clj | 4 +- luxc/src/lux/type.clj | 24 +++---- luxc/src/lux/type/host.clj | 8 +-- 18 files changed, 249 insertions(+), 249 deletions(-) (limited to 'luxc/src') diff --git a/luxc/src/lux.clj b/luxc/src/lux.clj index c1e04b9a3..d17f1640d 100644 --- a/luxc/src/lux.clj +++ b/luxc/src/lux.clj @@ -15,7 +15,7 @@ (def unit-separator (str (char 31))) -(defn ^:private process-dirs +(defn ^:private separate-paths "(-> Text (List Text))" [resources-dirs] (-> resources-dirs @@ -26,14 +26,14 @@ (defn -main [& args] (|case (&/->list args) (&/$Cons "release" (&/$Cons program-module (&/$Cons resources-dirs (&/$Cons source-dirs (&/$Cons target-dir (&/$Nil)))))) - (time (&compiler/compile-program &/$Release program-module (process-dirs resources-dirs) (process-dirs source-dirs) target-dir)) + (time (&compiler/compile-program &/$Release program-module (separate-paths resources-dirs) (separate-paths source-dirs) target-dir)) (&/$Cons "debug" (&/$Cons program-module (&/$Cons resources-dirs (&/$Cons source-dirs (&/$Cons target-dir (&/$Nil)))))) - (time (&compiler/compile-program &/$Debug program-module (process-dirs resources-dirs) (process-dirs source-dirs) target-dir)) + (time (&compiler/compile-program &/$Debug program-module (separate-paths resources-dirs) (separate-paths source-dirs) target-dir)) (&/$Cons "repl" (&/$Cons resources-dirs (&/$Cons source-dirs (&/$Cons target-dir (&/$Nil))))) - (&repl/repl (process-dirs resources-dirs) - (process-dirs source-dirs) + (&repl/repl (separate-paths resources-dirs) + (separate-paths source-dirs) target-dir) _ diff --git a/luxc/src/lux/analyser.clj b/luxc/src/lux/analyser.clj index eefa5ee3d..f47bcf914 100644 --- a/luxc/src/lux/analyser.clj +++ b/luxc/src/lux/analyser.clj @@ -79,9 +79,9 @@ (|do [_ (&type/check exo-type &type/Int)] (return (&/|list (&&/|meta exo-type cursor (&&/$int ?value))))) - (&/$FracS ?value) - (|do [_ (&type/check exo-type &type/Frac)] - (return (&/|list (&&/|meta exo-type cursor (&&/$frac ?value))))) + (&/$DegS ?value) + (|do [_ (&type/check exo-type &type/Deg)] + (return (&/|list (&&/|meta exo-type cursor (&&/$deg ?value))))) (&/$RealS ?value) (|do [_ (&type/check exo-type &type/Real)] diff --git a/luxc/src/lux/analyser/base.clj b/luxc/src/lux/analyser/base.clj index 9bdcdeb11..ccc7260bc 100644 --- a/luxc/src/lux/analyser/base.clj +++ b/luxc/src/lux/analyser/base.clj @@ -14,7 +14,7 @@ ("bool" 1) ("nat" 1) ("int" 1) - ("frac" 1) + ("deg" 1) ("real" 1) ("char" 1) ("text" 1) diff --git a/luxc/src/lux/analyser/case.clj b/luxc/src/lux/analyser/case.clj index a5c37ba6b..042ca8352 100644 --- a/luxc/src/lux/analyser/case.clj +++ b/luxc/src/lux/analyser/case.clj @@ -20,7 +20,7 @@ ("BoolTotal" 2) ("NatTotal" 2) ("IntTotal" 2) - ("FracTotal" 2) + ("DegTotal" 2) ("RealTotal" 2) ("CharTotal" 2) ("TextTotal" 2) @@ -33,7 +33,7 @@ ("BoolTestAC" 1) ("NatTestAC" 1) ("IntTestAC" 1) - ("FracTestAC" 1) + ("DegTestAC" 1) ("RealTestAC" 1) ("CharTestAC" 1) ("TextTestAC" 1) @@ -291,10 +291,10 @@ =kont kont] (return (&/T [($IntTestAC ?value) =kont]))) - (&/$FracS ?value) - (|do [_ (&type/check value-type &type/Frac) + (&/$DegS ?value) + (|do [_ (&type/check value-type &type/Deg) =kont kont] - (return (&/T [($FracTestAC ?value) =kont]))) + (return (&/T [($DegTestAC ?value) =kont]))) (&/$RealS ?value) (|do [_ (&type/check value-type &type/Real) @@ -426,8 +426,8 @@ [($IntTotal total? ?values) ($NoTestAC)] (return ($IntTotal true ?values)) - [($FracTotal total? ?values) ($NoTestAC)] - (return ($FracTotal true ?values)) + [($DegTotal total? ?values) ($NoTestAC)] + (return ($DegTotal true ?values)) [($RealTotal total? ?values) ($NoTestAC)] (return ($RealTotal true ?values)) @@ -456,8 +456,8 @@ [($IntTotal total? ?values) ($StoreTestAC ?idx)] (return ($IntTotal true ?values)) - [($FracTotal total? ?values) ($StoreTestAC ?idx)] - (return ($FracTotal true ?values)) + [($DegTotal total? ?values) ($StoreTestAC ?idx)] + (return ($DegTotal true ?values)) [($RealTotal total? ?values) ($StoreTestAC ?idx)] (return ($RealTotal true ?values)) @@ -492,11 +492,11 @@ [($IntTotal total? ?values) ($IntTestAC ?value)] (return ($IntTotal total? (&/$Cons ?value ?values))) - [($DefaultTotal total?) ($FracTestAC ?value)] - (return ($FracTotal total? (&/|list ?value))) + [($DefaultTotal total?) ($DegTestAC ?value)] + (return ($DegTotal total? (&/|list ?value))) - [($FracTotal total? ?values) ($FracTestAC ?value)] - (return ($FracTotal total? (&/$Cons ?value ?values))) + [($DegTotal total? ?values) ($DegTestAC ?value)] + (return ($DegTotal total? (&/$Cons ?value ?values))) [($DefaultTotal total?) ($RealTestAC ?value)] (return ($RealTotal total? (&/|list ?value))) @@ -585,8 +585,8 @@ (|do [_ (&type/check value-type &type/Int)] (return ?total)) - ($FracTotal ?total _) - (|do [_ (&type/check value-type &type/Frac)] + ($DegTotal ?total _) + (|do [_ (&type/check value-type &type/Deg)] (return ?total)) ($RealTotal ?total _) diff --git a/luxc/src/lux/analyser/host.clj b/luxc/src/lux/analyser/host.clj index 977a7b1fe..8c6b1ac80 100644 --- a/luxc/src/lux/analyser/host.clj +++ b/luxc/src/lux/analyser/host.clj @@ -1074,23 +1074,23 @@ ^:private analyse-nat-eq ["nat" "="] &type/Nat &type/Bool ^:private analyse-nat-lt ["nat" "<"] &type/Nat &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 + ^:private analyse-deg-add ["deg" "+"] &type/Deg &type/Deg + ^:private analyse-deg-sub ["deg" "-"] &type/Deg &type/Deg + ^:private analyse-deg-mul ["deg" "*"] &type/Deg &type/Deg + ^:private analyse-deg-div ["deg" "/"] &type/Deg &type/Deg + ^:private analyse-deg-rem ["deg" "%"] &type/Deg &type/Deg + ^:private analyse-deg-eq ["deg" "="] &type/Deg &type/Bool + ^:private analyse-deg-lt ["deg" "<"] &type/Deg &type/Bool ) -(defn ^:private analyse-frac-scale [analyse exo-type ?values] +(defn ^:private analyse-deg-scale [analyse exo-type ?values] (|do [:let [(&/$Cons x (&/$Cons y (&/$Nil))) ?values] - =x (&&/analyse-1 analyse &type/Frac x) + =x (&&/analyse-1 analyse &type/Deg x) =y (&&/analyse-1 analyse &type/Nat y) - _ (&type/check exo-type &type/Frac) + _ (&type/check exo-type &type/Deg) _cursor &/cursor] - (return (&/|list (&&/|meta &type/Frac _cursor - (&&/$proc (&/T ["frac" "scale"]) (&/|list =x =y) (&/|list))))))) + (return (&/|list (&&/|meta &type/Deg _cursor + (&&/$proc (&/T ["deg" "scale"]) (&/|list =x =y) (&/|list))))))) (do-template [ ] (do (defn [analyse exo-type ?values] @@ -1111,7 +1111,7 @@ (&&/$proc (&/T ) (&/|list =x) (&/|list))))))))) ^:private analyse-nat-encode ["nat" "encode"] ^:private analyse-nat-decode ["nat" "decode"] &type/Nat - ^:private analyse-frac-encode ["frac" "encode"] ^:private analyse-frac-decode ["frac" "decode"] &type/Frac + ^:private analyse-deg-encode ["deg" "encode"] ^:private analyse-deg-decode ["deg" "decode"] &type/Deg ) (do-template [ ] @@ -1125,8 +1125,8 @@ ^:private analyse-nat-min-value &type/Nat ["nat" "min-value"] ^:private analyse-nat-max-value &type/Nat ["nat" "max-value"] - ^:private analyse-frac-min-value &type/Frac ["frac" "min-value"] - ^:private analyse-frac-max-value &type/Frac ["frac" "max-value"] + ^:private analyse-deg-min-value &type/Deg ["deg" "min-value"] + ^:private analyse-deg-max-value &type/Deg ["deg" "max-value"] ) (do-template [ ] @@ -1143,8 +1143,8 @@ ^:private analyse-int-to-nat &type/Int &type/Nat ["int" "to-nat"] ^:private analyse-char-to-nat &type/Char &type/Nat ["char" "to-nat"] - ^:private analyse-frac-to-real &type/Frac &type/Real ["frac" "to-real"] - ^:private analyse-real-to-frac &type/Real &type/Frac ["real" "to-frac"] + ^:private analyse-deg-to-real &type/Deg &type/Real ["deg" "to-real"] + ^:private analyse-real-to-deg &type/Real &type/Deg ["real" "to-deg"] ) (defn analyse-host [analyse exo-type compilers category proc ?values] @@ -1189,21 +1189,21 @@ "to-char" (analyse-nat-to-char analyse exo-type ?values) ) - "frac" + "deg" (case proc - "+" (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) - "min-value" (analyse-frac-min-value analyse exo-type ?values) - "max-value" (analyse-frac-max-value analyse exo-type ?values) - "to-real" (analyse-frac-to-real analyse exo-type ?values) - "scale" (analyse-frac-scale analyse exo-type ?values) + "+" (analyse-deg-add analyse exo-type ?values) + "-" (analyse-deg-sub analyse exo-type ?values) + "*" (analyse-deg-mul analyse exo-type ?values) + "/" (analyse-deg-div analyse exo-type ?values) + "%" (analyse-deg-rem analyse exo-type ?values) + "=" (analyse-deg-eq analyse exo-type ?values) + "<" (analyse-deg-lt analyse exo-type ?values) + "encode" (analyse-deg-encode analyse exo-type ?values) + "decode" (analyse-deg-decode 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) + "scale" (analyse-deg-scale analyse exo-type ?values) ) "int" @@ -1213,7 +1213,7 @@ "real" (case proc - "to-frac" (analyse-real-to-frac analyse exo-type ?values) + "to-deg" (analyse-real-to-deg analyse exo-type ?values) ) "char" diff --git a/luxc/src/lux/analyser/module.clj b/luxc/src/lux/analyser/module.clj index 62948bf0d..272f37e64 100644 --- a/luxc/src/lux/analyser/module.clj +++ b/luxc/src/lux/analyser/module.clj @@ -204,14 +204,14 @@ (|let [[?type ?meta ?value] $def] (if (.equals ^Object current-module module) (|case (&meta/meta-get &meta/alias-tag ?meta) - (&/$Some (&/$IdentM [?r-module ?r-name])) + (&/$Some (&/$IdentA [?r-module ?r-name])) ((find-def ?r-module ?r-name) state) _ (return* state (&/T [(&/T [module name]) $def]))) (|case (&meta/meta-get &meta/export?-tag ?meta) - (&/$Some (&/$BoolM true)) + (&/$Some (&/$BoolA true)) (return* state (&/T [(&/T [module name]) $def])) _ @@ -364,7 +364,7 @@ (|let [[k _def-data] kv [_ ?def-meta _] _def-data] (|case (&meta/meta-get &meta/alias-tag ?def-meta) - (&/$Some (&/$IdentM [?r-module ?r-name])) + (&/$Some (&/$IdentA [?r-module ?r-name])) (&/T [k (str ?r-module ";" ?r-name) _def-data]) _ @@ -374,7 +374,7 @@ (do-template [ ] (defn [module name meta type] (|case (&meta/meta-get meta) - (&/$Some (&/$BoolM true)) + (&/$Some (&/$BoolA true)) (&/try-all% (&/|list (&type/check type) (&/fail-with-loc (str "[Analyser Error] Can't tag as lux;" "? if it's not a " ": " (str module ";" name))))) @@ -387,11 +387,11 @@ (defn fetch-imports [meta] (|case (&meta/meta-get &meta/imports-tag meta) - (&/$Some (&/$ListM _parts)) + (&/$Some (&/$ListA _parts)) (&/map% (fn [_part] (|case _part - (&/$ListM (&/$Cons [(&/$TextM _module) - (&/$Cons [(&/$TextM _alias) + (&/$ListA (&/$Cons [(&/$TextA _module) + (&/$Cons [(&/$TextA _alias) (&/$Nil)])])) (return (&/T [_module _alias])) diff --git a/luxc/src/lux/base.clj b/luxc/src/lux/base.clj index 69dbdf5bf..f893f3a02 100644 --- a/luxc/src/lux/base.clj +++ b/luxc/src/lux/base.clj @@ -74,7 +74,7 @@ ("BoolS" 1) ("NatS" 1) ("IntS" 1) - ("FracS" 1) + ("DegS" 1) ("RealS" 1) ("CharS" 1) ("TextS" 1) @@ -216,16 +216,16 @@ ;; Meta-data (defvariant - ("BoolM" 1) - ("NatM" 1) - ("IntM" 1) - ("FracM" 1) - ("RealM" 1) - ("CharM" 1) - ("TextM" 1) - ("IdentM" 1) - ("ListM" 1) - ("DictM" 1)) + ("BoolA" 1) + ("NatA" 1) + ("IntA" 1) + ("DegA" 1) + ("RealA" 1) + ("CharA" 1) + ("TextA" 1) + ("IdentA" 1) + ("ListA" 1) + ("DictA" 1)) ;; [Exports] (def ^:const name-field "_name") @@ -1059,12 +1059,12 @@ (fn [state] (return* state (get$ $cursor state)))) -(def frac-bits 64) +(def deg-bits 64) (let [clean-separators (fn [^String input] (.replaceAll input "_" "")) - frac-text-to-digits (fn [^String input] - (loop [output (vec (repeat frac-bits 0)) + deg-text-to-digits (fn [^String input] + (loop [output (vec (repeat deg-bits 0)) index (dec (.length input))] (if (>= index 0) (let [digit (Byte/parseByte (.substring input index (inc index)))] @@ -1081,50 +1081,50 @@ (int (/ raw 10)) (assoc digits index (rem raw 10)))) digits))) - frac-digit-power (fn [level] - (loop [output (-> (vec (repeat frac-bits 0)) + deg-digit-power (fn [level] + (loop [output (-> (vec (repeat deg-bits 0)) (assoc level 1)) times level] (if (>= times 0) (recur (times5 level output) (dec times)) output))) - frac-digits-lt (fn frac-digits-lt + deg-digits-lt (fn deg-digits-lt ([subject param index] - (and (< index frac-bits) + (and (< index deg-bits) (or (< (get subject index) (get param index)) (and (= (get subject index) (get param index)) - (frac-digits-lt subject param (inc index)))))) + (deg-digits-lt subject param (inc index)))))) ([subject param] - (frac-digits-lt subject param 0))) - frac-digits-sub-once (fn [subject param-digit index] + (deg-digits-lt subject param 0))) + deg-digits-sub-once (fn [subject param-digit index] (if (>= (get subject index) param-digit) (update-in subject [index] #(- % param-digit)) (recur (update-in subject [index] #(- 10 (- param-digit %))) 1 (dec index)))) - frac-digits-sub (fn [subject param] + deg-digits-sub (fn [subject param] (loop [target subject - index (dec frac-bits)] + index (dec deg-bits)] (if (>= index 0) - (recur (frac-digits-sub-once target (get param index) index) + (recur (deg-digits-sub-once target (get param index) index) (dec index)) target))) - frac-digits-to-text (fn [digits] + deg-digits-to-text (fn [digits] (loop [output "" - index (dec frac-bits)] + index (dec deg-bits)] (if (>= index 0) (recur (-> (get digits index) (Character/forDigit 10) (str output)) (dec index)) output))) - add-frac-digit-powers (fn [dl dr] - (loop [index (dec frac-bits) - output (vec (repeat frac-bits 0)) + add-deg-digit-powers (fn [dl dr] + (loop [index (dec deg-bits) + output (vec (repeat deg-bits 0)) carry 0] (if (>= index 0) (let [raw (+ carry @@ -1134,45 +1134,45 @@ (assoc output index (rem raw 10)) (int (/ raw 10)))) output)))] - ;; Based on the LuxRT.encode_frac method - (defn encode-frac [input] + ;; Based on the LuxRT.encode_deg method + (defn encode-deg [input] (if (= 0 input) ".0" - (loop [index (dec frac-bits) - output (vec (repeat frac-bits 0))] + (loop [index (dec deg-bits) + output (vec (repeat deg-bits 0))] (if (>= index 0) (recur (dec index) (if (bit-test input index) - (->> (- (dec frac-bits) index) - frac-digit-power - (add-frac-digit-powers output)) + (->> (- (dec deg-bits) index) + deg-digit-power + (add-deg-digit-powers output)) output)) - (-> output frac-digits-to-text + (-> output deg-digits-to-text (->> (str ".")) (.split "0*$") (aget 0)))))) - ;; Based on the LuxRT.decode_frac method - (defn decode-frac [^String input] + ;; Based on the LuxRT.decode_deg method + (defn decode-deg [^String input] (if (and (.startsWith input ".") - (< (.length input) (inc frac-bits))) + (< (.length input) (inc deg-bits))) (loop [digits-left (-> input (.substring 1) clean-separators - frac-text-to-digits) + deg-text-to-digits) index 0 ouput 0] - (if (< index frac-bits) - (let [power-slice (frac-digit-power index)] - (if (not (frac-digits-lt digits-left power-slice)) - (recur (frac-digits-sub digits-left power-slice) + (if (< index deg-bits) + (let [power-slice (deg-digit-power index)] + (if (not (deg-digits-lt digits-left power-slice)) + (recur (deg-digits-sub digits-left power-slice) (inc index) - (bit-set ouput (- (dec frac-bits) index))) + (bit-set ouput (- (dec deg-bits) index))) (recur digits-left (inc index) ouput))) ouput)) - (throw (str "Bad format for Frac number: " input)))) + (throw (str "Bad format for Deg number: " input)))) ) (defn show-ast [ast] @@ -1186,8 +1186,8 @@ [_ ($IntS ?value)] (pr-str ?value) - [_ ($FracS ?value)] - (encode-frac ?value) + [_ ($DegS ?value)] + (encode-deg ?value) [_ ($RealS ?value)] (pr-str ?value) diff --git a/luxc/src/lux/compiler.clj b/luxc/src/lux/compiler.clj index 48c90e759..0c30c76e9 100644 --- a/luxc/src/lux/compiler.clj +++ b/luxc/src/lux/compiler.clj @@ -60,8 +60,8 @@ (&o/$int ?value) (&&lux/compile-int ?value) - (&o/$frac ?value) - (&&lux/compile-frac ?value) + (&o/$deg ?value) + (&&lux/compile-deg ?value) (&o/$real ?value) (&&lux/compile-real ?value) diff --git a/luxc/src/lux/compiler/cache.clj b/luxc/src/lux/compiler/cache.clj index dbb7945b8..436f778f5 100644 --- a/luxc/src/lux/compiler/cache.clj +++ b/luxc/src/lux/compiler/cache.clj @@ -136,7 +136,7 @@ 2 (let [[_name _alias] parts [_ __module __name] (re-find #"^(.*);(.*)$" _alias) def-class (&&/load-class! loader (str (&host-generics/->class-name __module) "." (&host/def-name __name))) - def-anns (&/|list (&/T [&a-meta/alias-tag (&/$IdentM (&/T [__module __name]))])) + def-anns (&/|list (&/T [&a-meta/alias-tag (&/$IdentA (&/T [__module __name]))])) def-value (get-field &/value-field def-class)] (|do [def-type (&a-module/def-type __module __name)] (&a-module/define module _name def-type def-anns def-value))) diff --git a/luxc/src/lux/compiler/cache/ann.clj b/luxc/src/lux/compiler/cache/ann.clj index 7f343d229..e2df55286 100644 --- a/luxc/src/lux/compiler/cache/ann.clj +++ b/luxc/src/lux/compiler/cache/ann.clj @@ -33,34 +33,34 @@ "(-> Ann-Value Text)" [ann] (|case ann - (&/$BoolM value) + (&/$BoolA value) (str "B" value stop) - (&/$NatM value) + (&/$NatA value) (str "N" value stop) - (&/$IntM value) + (&/$IntA value) (str "I" value stop) - (&/$FracM value) - (str "F" value stop) + (&/$DegA value) + (str "D" value stop) - (&/$RealM value) + (&/$RealA value) (str "R" value stop) - (&/$CharM value) + (&/$CharA value) (str "C" value stop) - (&/$TextM value) + (&/$TextA value) (serialize-text value) - (&/$IdentM ident) + (&/$IdentA ident) (serialize-ident ident) - (&/$ListM elems) + (&/$ListA elems) (str "L" (serialize-seq serialize-ann elems)) - (&/$DictM kvs) + (&/$DictA kvs) (str "D" (serialize-seq (fn [kv] (|let [[k v] kv] (str (serialize-text k) @@ -88,13 +88,13 @@ (let [[value* ^String input*] (.split (.substring input 1) stop 2)] [( ( value*)) input*]))) - ^:private deserialize-bool "B" &/$BoolM Boolean/parseBoolean - ^:private deserialize-nat "N" &/$NatM Long/parseLong - ^:private deserialize-int "I" &/$IntM Long/parseLong - ^:private deserialize-frac "F" &/$FracM Long/parseLong - ^:private deserialize-real "R" &/$RealM Double/parseDouble - ^:private deserialize-char "C" &/$CharM (fn [^String input] (.charAt input 0)) - ^:private deserialize-text "T" &/$TextM identity + ^:private deserialize-bool "B" &/$BoolA Boolean/parseBoolean + ^: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-char "C" &/$CharA (fn [^String input] (.charAt input 0)) + ^:private deserialize-text "T" &/$TextA identity ) (defn ^:private deserialize-ident* [^String input] @@ -107,7 +107,7 @@ (when (.startsWith input "@") (let [[^String ident* ^String input*] (.split (.substring input 1) stop 2) [_module _name] (.split ident* ident-separator 2)] - [(&/$IdentM (&/T [_module _name])) input*]))) + [(&/$IdentA (&/T [_module _name])) input*]))) (defn ^:private deserialize-seq [deserializer ^String input] (cond (.startsWith input nil-signal) @@ -136,8 +136,8 @@ (.substring input 1))] [( elems) input*]))) - ^:private deserialize-list "L" &/$ListM deserialize-ann - ^:private deserialize-dict "D" &/$DictM deserialize-kv + ^:private deserialize-list "L" &/$ListA deserialize-ann + ^:private deserialize-dict "D" &/$DictA deserialize-kv ) (defn ^:private deserialize-ann @@ -146,7 +146,7 @@ (or (deserialize-bool input) (deserialize-nat input) (deserialize-int input) - (deserialize-frac input) + (deserialize-deg input) (deserialize-real input) (deserialize-char input) (deserialize-text input) diff --git a/luxc/src/lux/compiler/case.clj b/luxc/src/lux/compiler/case.clj index afdcd3eed..416c93622 100644 --- a/luxc/src/lux/compiler/case.clj +++ b/luxc/src/lux/compiler/case.clj @@ -90,7 +90,7 @@ (.visitInsn Opcodes/LCMP) (.visitJumpInsn Opcodes/IFNE $else)) - (&o/$FracPM _value) + (&o/$DegPM _value) (doto writer stack-peek &&/unwrap-long diff --git a/luxc/src/lux/compiler/host.clj b/luxc/src/lux/compiler/host.clj index 5f98bcdb9..10a718093 100644 --- a/luxc/src/lux/compiler/host.clj +++ b/luxc/src/lux/compiler/host.clj @@ -777,9 +777,9 @@ (.visitInsn Opcodes/LCMP) ;; I )) -(defn ^:private compile-LuxRT-frac-methods [^ClassWriter =class] - (|let [frac-bits 64 - _ (doto (.visitMethod =class (+ Opcodes/ACC_PUBLIC Opcodes/ACC_STATIC) "mul_frac" "(JJ)J" nil nil) +(defn ^:private compile-LuxRT-deg-methods [^ClassWriter =class] + (|let [deg-bits 64 + _ (doto (.visitMethod =class (+ Opcodes/ACC_PUBLIC Opcodes/ACC_STATIC) "mul_deg" "(JJ)J" nil nil) ;; Based on: http://stackoverflow.com/a/31629280/6823464 (.visitCode) ;; Bottom part @@ -810,7 +810,7 @@ (.visitInsn Opcodes/LRETURN) (.visitMaxs 0 0) (.visitEnd)) - _ (doto (.visitMethod =class (+ Opcodes/ACC_PUBLIC Opcodes/ACC_STATIC) "div_frac" "(JJ)J" nil nil) + _ (doto (.visitMethod =class (+ Opcodes/ACC_PUBLIC Opcodes/ACC_STATIC) "div_deg" "(JJ)J" nil nil) (.visitCode) ;; Based on: http://stackoverflow.com/a/8510587/6823464 (.visitVarInsn Opcodes/LLOAD 0) @@ -821,7 +821,7 @@ (.visitInsn Opcodes/LRETURN) (.visitMaxs 0 0) (.visitEnd)) - _ (doto (.visitMethod =class (+ Opcodes/ACC_PUBLIC Opcodes/ACC_STATIC) "frac-to-real" "(J)D" nil nil) + _ (doto (.visitMethod =class (+ Opcodes/ACC_PUBLIC Opcodes/ACC_STATIC) "deg-to-real" "(J)D" nil nil) (.visitCode) ;; Translate high bytes (.visitVarInsn Opcodes/LLOAD 0) high-4b @@ -840,7 +840,7 @@ (.visitInsn Opcodes/DRETURN) (.visitMaxs 0 0) (.visitEnd)) - _ (doto (.visitMethod =class (+ Opcodes/ACC_PUBLIC Opcodes/ACC_STATIC) "real-to-frac" "(D)J" nil nil) + _ (doto (.visitMethod =class (+ Opcodes/ACC_PUBLIC Opcodes/ACC_STATIC) "real-to-deg" "(D)J" nil nil) (.visitCode) ;; Drop any excess (.visitVarInsn Opcodes/DLOAD 0) @@ -856,9 +856,9 @@ (.visitInsn Opcodes/DREM) (.visitLdcInsn (double (Math/pow 2 32))) (.visitInsn Opcodes/DMUL) - ;; Turn it into a frac + ;; Turn it into a deg (.visitInsn Opcodes/D2L) - ;; Turn the upper half into frac too + ;; Turn the upper half into deg too swap2 (.visitInsn Opcodes/D2L) ;; Combine both pieces @@ -908,10 +908,10 @@ (.visitEnd))) _ (let [$loop-start (new Label) $do-a-round (new Label)] - (doto (.visitMethod =class (+ Opcodes/ACC_PUBLIC Opcodes/ACC_STATIC) "frac_digit_power" "(I)[B" nil nil) + (doto (.visitMethod =class (+ Opcodes/ACC_PUBLIC Opcodes/ACC_STATIC) "deg_digit_power" "(I)[B" nil nil) (.visitCode) ;; Initialize digits array. - (.visitLdcInsn (int frac-bits)) + (.visitLdcInsn (int deg-bits)) (.visitIntInsn Opcodes/NEWARRAY Opcodes/T_BYTE) ;; {digits} (.visitInsn Opcodes/DUP) (.visitVarInsn Opcodes/ILOAD 0) @@ -945,11 +945,11 @@ (.visitEnd))) _ (let [$loop-start (new Label) $do-a-round (new Label)] - (doto (.visitMethod =class (+ Opcodes/ACC_PUBLIC Opcodes/ACC_STATIC) "add_frac_digit_powers" "([B[B)[B" nil nil) + (doto (.visitMethod =class (+ Opcodes/ACC_PUBLIC Opcodes/ACC_STATIC) "add_deg_digit_powers" "([B[B)[B" nil nil) (.visitCode) - (.visitLdcInsn (int (dec frac-bits))) + (.visitLdcInsn (int (dec deg-bits))) (.visitVarInsn Opcodes/ISTORE 2) ;; Index - (.visitLdcInsn (int frac-bits)) + (.visitLdcInsn (int deg-bits)) (.visitIntInsn Opcodes/NEWARRAY Opcodes/T_BYTE) (.visitVarInsn Opcodes/ASTORE 3) ;; added_digits (.visitLdcInsn (int 0)) ;; {carry} @@ -996,9 +996,9 @@ (.visitEnd))) _ (let [$loop-start (new Label) $do-a-round (new Label)] - (doto (.visitMethod =class (+ Opcodes/ACC_PUBLIC Opcodes/ACC_STATIC) "frac_digits_to_text" "([B)Ljava/lang/String;" nil nil) + (doto (.visitMethod =class (+ Opcodes/ACC_PUBLIC Opcodes/ACC_STATIC) "deg_digits_to_text" "([B)Ljava/lang/String;" nil nil) (.visitCode) - (.visitLdcInsn (int (dec frac-bits))) + (.visitLdcInsn (int (dec deg-bits))) (.visitVarInsn Opcodes/ISTORE 1) ;; Index (.visitLdcInsn "") ;; {text} ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -1034,7 +1034,7 @@ $not-set (new Label) $next-iteration (new Label) $normal-path (new Label)] - (doto (.visitMethod =class (+ Opcodes/ACC_PUBLIC Opcodes/ACC_STATIC) "encode_frac" "(J)Ljava/lang/String;" nil nil) + (doto (.visitMethod =class (+ Opcodes/ACC_PUBLIC Opcodes/ACC_STATIC) "encode_deg" "(J)Ljava/lang/String;" nil nil) (.visitCode) ;; A quick corner-case to handle. (.visitVarInsn Opcodes/LLOAD 0) @@ -1045,9 +1045,9 @@ (.visitInsn Opcodes/ARETURN) (.visitLabel $normal-path) ;; Normal case - (.visitLdcInsn (int (dec frac-bits))) + (.visitLdcInsn (int (dec deg-bits))) (.visitVarInsn Opcodes/ISTORE 2) ;; Index - (.visitLdcInsn (int frac-bits)) + (.visitLdcInsn (int deg-bits)) (.visitIntInsn Opcodes/NEWARRAY Opcodes/T_BYTE) (.visitVarInsn Opcodes/ASTORE 3) ;; digits ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -1058,7 +1058,7 @@ (.visitJumpInsn Opcodes/IFGE $do-a-round) ;; Prepare text to return. (.visitVarInsn Opcodes/ALOAD 3) - (.visitMethodInsn Opcodes/INVOKESTATIC "lux/LuxRT" "frac_digits_to_text" "([B)Ljava/lang/String;") + (.visitMethodInsn Opcodes/INVOKESTATIC "lux/LuxRT" "deg_digits_to_text" "([B)Ljava/lang/String;") (.visitLdcInsn ".") (.visitInsn Opcodes/SWAP) (.visitMethodInsn Opcodes/INVOKEVIRTUAL "java/lang/String" "concat" "(Ljava/lang/String;)Ljava/lang/String;") @@ -1076,12 +1076,12 @@ (.visitVarInsn Opcodes/ILOAD 2) bit-set-64? (.visitJumpInsn Opcodes/IFEQ $next-iteration) - (.visitLdcInsn (int (dec frac-bits))) + (.visitLdcInsn (int (dec deg-bits))) (.visitVarInsn Opcodes/ILOAD 2) (.visitInsn Opcodes/ISUB) - (.visitMethodInsn Opcodes/INVOKESTATIC "lux/LuxRT" "frac_digit_power" "(I)[B") + (.visitMethodInsn Opcodes/INVOKESTATIC "lux/LuxRT" "deg_digit_power" "(I)[B") (.visitVarInsn Opcodes/ALOAD 3) - (.visitMethodInsn Opcodes/INVOKESTATIC "lux/LuxRT" "add_frac_digit_powers" "([B[B)[B") + (.visitMethodInsn Opcodes/INVOKESTATIC "lux/LuxRT" "add_deg_digit_powers" "([B[B)[B") (.visitVarInsn Opcodes/ASTORE 3) (.visitJumpInsn Opcodes/GOTO $next-iteration) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -1104,14 +1104,14 @@ $do-a-round (new Label) $not-set (new Label) $next-iteration (new Label)] - (doto (.visitMethod =class (+ Opcodes/ACC_PUBLIC Opcodes/ACC_STATIC) "frac_text_to_digits" "(Ljava/lang/String;)[B" nil nil) + (doto (.visitMethod =class (+ Opcodes/ACC_PUBLIC Opcodes/ACC_STATIC) "deg_text_to_digits" "(Ljava/lang/String;)[B" nil nil) (.visitCode) (.visitVarInsn Opcodes/ALOAD 0) (.visitMethodInsn Opcodes/INVOKEVIRTUAL "java/lang/String" "length" "()I") (.visitLdcInsn (int 1)) (.visitInsn Opcodes/ISUB) (.visitVarInsn Opcodes/ISTORE 1) ;; Index - (.visitLdcInsn (int frac-bits)) + (.visitLdcInsn (int deg-bits)) (.visitIntInsn Opcodes/NEWARRAY Opcodes/T_BYTE) (.visitVarInsn Opcodes/ASTORE 2) ;; digits ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -1152,7 +1152,7 @@ $is-less-than (new Label) $is-equal (new Label)] ;; [B0 <= [B1 - (doto (.visitMethod =class (+ Opcodes/ACC_PUBLIC Opcodes/ACC_STATIC) "frac_digits_lt" "([B[B)Z" nil nil) + (doto (.visitMethod =class (+ Opcodes/ACC_PUBLIC Opcodes/ACC_STATIC) "deg_digits_lt" "([B[B)Z" nil nil) (.visitCode) (.visitLdcInsn (int 0)) (.visitVarInsn Opcodes/ISTORE 2) ;; Index @@ -1161,7 +1161,7 @@ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (.visitLabel $loop-start) (.visitVarInsn Opcodes/ILOAD 2) - (.visitLdcInsn (int frac-bits)) + (.visitLdcInsn (int deg-bits)) (.visitJumpInsn Opcodes/IF_ICMPLT $do-a-round) (.visitLdcInsn false) (.visitInsn Opcodes/IRETURN) @@ -1204,7 +1204,7 @@ _ (let [$loop-start (new Label) $do-a-round (new Label) $simple-sub (new Label)] - (doto (.visitMethod =class (+ Opcodes/ACC_PUBLIC Opcodes/ACC_STATIC) "frac_digits_sub_once" "([BBI)[B" nil nil) + (doto (.visitMethod =class (+ Opcodes/ACC_PUBLIC Opcodes/ACC_STATIC) "deg_digits_sub_once" "([BBI)[B" nil nil) (.visitCode) (.visitLabel $loop-start) (.visitVarInsn Opcodes/ALOAD 0) @@ -1252,9 +1252,9 @@ (.visitEnd))) _ (let [$loop-start (new Label) $do-a-round (new Label)] - (doto (.visitMethod =class (+ Opcodes/ACC_PUBLIC Opcodes/ACC_STATIC) "frac_digits_sub" "([B[B)[B" nil nil) + (doto (.visitMethod =class (+ Opcodes/ACC_PUBLIC Opcodes/ACC_STATIC) "deg_digits_sub" "([B[B)[B" nil nil) (.visitCode) - (.visitLdcInsn (int (dec frac-bits))) + (.visitLdcInsn (int (dec deg-bits))) (.visitVarInsn Opcodes/ISTORE 2) ;; Index ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -1273,7 +1273,7 @@ (.visitVarInsn Opcodes/ILOAD 2) (.visitInsn Opcodes/BALOAD) ;; {target-digits, param-digit} (.visitVarInsn Opcodes/ILOAD 2) ;; {target-digits, param-digit, idx} - (.visitMethodInsn Opcodes/INVOKESTATIC "lux/LuxRT" "frac_digits_sub_once" "([BBI)[B") + (.visitMethodInsn Opcodes/INVOKESTATIC "lux/LuxRT" "deg_digits_sub_once" "([BBI)[B") (.visitVarInsn Opcodes/ASTORE 0) ;; Update target digits ;; Decrement index (.visitVarInsn Opcodes/ILOAD 2) @@ -1292,7 +1292,7 @@ $skip-power (new Label) $iterate (new Label) $bad-format (new Label)] - (doto (.visitMethod =class (+ Opcodes/ACC_PUBLIC Opcodes/ACC_STATIC) "decode_frac" "(Ljava/lang/String;)Ljava/lang/Object;" nil nil) + (doto (.visitMethod =class (+ Opcodes/ACC_PUBLIC Opcodes/ACC_STATIC) "decode_deg" "(Ljava/lang/String;)Ljava/lang/Object;" nil nil) (.visitCode) ;; Check prefix (.visitVarInsn Opcodes/ALOAD 0) @@ -1302,7 +1302,7 @@ ;; Check if size is valid (.visitVarInsn Opcodes/ALOAD 0) (.visitMethodInsn Opcodes/INVOKEVIRTUAL "java/lang/String" "length" "()I") - (.visitLdcInsn (int (inc frac-bits))) ;; It's increased, to account for the prefix . + (.visitLdcInsn (int (inc deg-bits))) ;; It's increased, to account for the prefix . (.visitJumpInsn Opcodes/IF_ICMPGT $bad-format) ;; Initialization (.visitTryCatchBlock $from $to $handler "java/lang/Exception") @@ -1311,7 +1311,7 @@ (.visitMethodInsn Opcodes/INVOKEVIRTUAL "java/lang/String" "substring" "(I)Ljava/lang/String;") (.visitMethodInsn Opcodes/INVOKESTATIC "lux/LuxRT" "clean_separators" "(Ljava/lang/String;)Ljava/lang/String;") (.visitLabel $from) - (.visitMethodInsn Opcodes/INVOKESTATIC "lux/LuxRT" "frac_text_to_digits" "(Ljava/lang/String;)[B") + (.visitMethodInsn Opcodes/INVOKESTATIC "lux/LuxRT" "deg_text_to_digits" "(Ljava/lang/String;)[B") (.visitLabel $to) (.visitVarInsn Opcodes/ASTORE 0) ;; From test to digits... (.visitLdcInsn (int 0)) @@ -1323,7 +1323,7 @@ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (.visitLabel $loop-start) (.visitVarInsn Opcodes/ILOAD 1) - (.visitLdcInsn (int frac-bits)) + (.visitLdcInsn (int deg-bits)) (.visitJumpInsn Opcodes/IF_ICMPLT $do-a-round) (.visitVarInsn Opcodes/LLOAD 2) &&/wrap-long @@ -1335,18 +1335,18 @@ (.visitLabel $do-a-round) (.visitVarInsn Opcodes/ALOAD 0) (.visitVarInsn Opcodes/ILOAD 1) - (.visitMethodInsn Opcodes/INVOKESTATIC "lux/LuxRT" "frac_digit_power" "(I)[B") + (.visitMethodInsn Opcodes/INVOKESTATIC "lux/LuxRT" "deg_digit_power" "(I)[B") (.visitInsn Opcodes/DUP2) - (.visitMethodInsn Opcodes/INVOKESTATIC "lux/LuxRT" "frac_digits_lt" "([B[B)Z") + (.visitMethodInsn Opcodes/INVOKESTATIC "lux/LuxRT" "deg_digits_lt" "([B[B)Z") (.visitJumpInsn Opcodes/IFNE $skip-power) ;; Subtract power - (.visitMethodInsn Opcodes/INVOKESTATIC "lux/LuxRT" "frac_digits_sub" "([B[B)[B") + (.visitMethodInsn Opcodes/INVOKESTATIC "lux/LuxRT" "deg_digits_sub" "([B[B)[B") (.visitVarInsn Opcodes/ASTORE 0) ;; Set bit on output (.visitVarInsn Opcodes/LLOAD 2) (.visitLdcInsn (long 1)) (.visitVarInsn Opcodes/ILOAD 1) - (.visitLdcInsn (int (dec frac-bits))) + (.visitLdcInsn (int (dec deg-bits))) (.visitInsn Opcodes/SWAP) (.visitInsn Opcodes/ISUB) (.visitInsn Opcodes/LSHL) @@ -1760,7 +1760,7 @@ (compile-LuxRT-pm-methods) (compile-LuxRT-adt-methods) (compile-LuxRT-nat-methods) - (compile-LuxRT-frac-methods))]] + (compile-LuxRT-deg-methods))]] (&&/save-class! (second (string/split &&/lux-utils-class #"/")) (.toByteArray (doto =class .visitEnd))))) @@ -2441,10 +2441,10 @@ ^:private compile-nat-sub Opcodes/LSUB "java.lang.Long" "longValue" "()J" &&/wrap-long ^:private compile-nat-mul Opcodes/LMUL "java.lang.Long" "longValue" "()J" &&/wrap-long - ^:private compile-frac-add Opcodes/LADD "java.lang.Long" "longValue" "()J" &&/wrap-long - ^:private compile-frac-sub Opcodes/LSUB "java.lang.Long" "longValue" "()J" &&/wrap-long - ^:private compile-frac-rem Opcodes/LSUB "java.lang.Long" "longValue" "()J" &&/wrap-long - ^:private compile-frac-scale Opcodes/LMUL "java.lang.Long" "longValue" "()J" &&/wrap-long + ^:private compile-deg-add Opcodes/LADD "java.lang.Long" "longValue" "()J" &&/wrap-long + ^:private compile-deg-sub Opcodes/LSUB "java.lang.Long" "longValue" "()J" &&/wrap-long + ^:private compile-deg-rem Opcodes/LSUB "java.lang.Long" "longValue" "()J" &&/wrap-long + ^:private compile-deg-scale Opcodes/LMUL "java.lang.Long" "longValue" "()J" &&/wrap-long ) (do-template [ ] @@ -2497,8 +2497,8 @@ ^:private compile-nat-eq 0 - ^:private compile-frac-eq 0 - ^:private compile-frac-lt -1 + ^:private compile-deg-eq 0 + ^:private compile-deg-lt -1 ) (let [+wrapper-class+ (&host-generics/->bytecode-class-name "java.lang.Long")] @@ -2538,8 +2538,8 @@ ^:private compile-nat-min-value (.visitLdcInsn 0) &&/wrap-long ^:private compile-nat-max-value (.visitLdcInsn -1) &&/wrap-long - ^:private compile-frac-min-value (.visitLdcInsn 0) &&/wrap-long - ^:private compile-frac-max-value (.visitLdcInsn -1) &&/wrap-long + ^:private compile-deg-min-value (.visitLdcInsn 0) &&/wrap-long + ^:private compile-deg-max-value (.visitLdcInsn -1) &&/wrap-long ) (do-template [ ] @@ -2563,7 +2563,7 @@ (return nil))))) ^:private compile-nat-encode "encode_nat" ^:private compile-nat-decode "decode_nat" - ^:private compile-frac-encode "encode_frac" ^:private compile-frac-decode "decode_frac" + ^:private compile-deg-encode "encode_deg" ^:private compile-deg-decode "decode_deg" ) (do-template [ ] @@ -2584,8 +2584,8 @@ &&/wrap-long)]] (return nil))) - ^:private compile-frac-mul "mul_frac" - ^:private compile-frac-div "div_frac" + ^:private compile-deg-mul "mul_deg" + ^:private compile-deg-div "div_deg" ) (do-template [ ] @@ -2600,8 +2600,8 @@ )]] (return nil)))) - ^:private compile-frac-to-real "java.lang.Long" "frac-to-real" "(J)D" &&/unwrap-long &&/wrap-double - ^:private compile-real-to-frac "java.lang.Double" "real-to-frac" "(D)J" &&/unwrap-double &&/wrap-long + ^: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 ) (let [widen (fn [^MethodVisitor *writer*] @@ -2674,21 +2674,21 @@ "to-char" (compile-nat-to-char compile ?values special-args) ) - "frac" + "deg" (case proc-name - "+" (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) - "max-value" (compile-frac-max-value compile ?values special-args) - "min-value" (compile-frac-min-value compile ?values special-args) - "to-real" (compile-frac-to-real compile ?values special-args) - "scale" (compile-frac-scale compile ?values special-args) + "+" (compile-deg-add compile ?values special-args) + "-" (compile-deg-sub compile ?values special-args) + "*" (compile-deg-mul compile ?values special-args) + "/" (compile-deg-div compile ?values special-args) + "%" (compile-deg-rem compile ?values special-args) + "=" (compile-deg-eq compile ?values special-args) + "<" (compile-deg-lt compile ?values special-args) + "encode" (compile-deg-encode compile ?values special-args) + "decode" (compile-deg-decode 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) + "scale" (compile-deg-scale compile ?values special-args) ) "int" @@ -2698,7 +2698,7 @@ "real" (case proc-name - "to-frac" (compile-real-to-frac compile ?values special-args) + "to-deg" (compile-real-to-deg compile ?values special-args) ) "char" diff --git a/luxc/src/lux/compiler/lux.clj b/luxc/src/lux/compiler/lux.clj index 3d7c4aa7b..fd4130707 100644 --- a/luxc/src/lux/compiler/lux.clj +++ b/luxc/src/lux/compiler/lux.clj @@ -44,7 +44,7 @@ compile-nat "java/lang/Long" "J" long compile-int "java/lang/Long" "J" long - compile-frac "java/lang/Long" "J" long + compile-deg "java/lang/Long" "J" long compile-real "java/lang/Double" "D" double compile-char "java/lang/Character" "C" char ) @@ -260,7 +260,7 @@ (|do [module-name &/get-module-name class-loader &/loader] (|case (&a-meta/meta-get &a-meta/alias-tag ?meta) - (&/$Some (&/$IdentM [r-module r-name])) + (&/$Some (&/$IdentA [r-module r-name])) (if (= 1 (&/|length ?meta)) (|do [:let [current-class (&host-generics/->class-name (str (&host/->module-class r-module) "/" (&host/def-name r-name))) def-class (&&/load-class! class-loader current-class) @@ -311,7 +311,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 (&/$BoolM true)) + (&/$Some (&/$BoolA true)) true _ @@ -323,7 +323,7 @@ _ (&/without-repl-closure (&a-module/define module-name ?name def-type def-meta def-value)) _ (|case (&/T [is-type? (&a-meta/meta-get &a-meta/tags-tag def-meta)]) - [true (&/$Some (&/$ListM tags*))] + [true (&/$Some (&/$ListA tags*))] (|do [:let [was-exported? (|case (&a-meta/meta-get &a-meta/export?-tag def-meta) (&/$Some _) true @@ -332,7 +332,7 @@ false)] tags (&/map% (fn [tag*] (|case tag* - (&/$TextM tag) + (&/$TextA tag) (return tag) _ @@ -382,7 +382,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 (&/$BoolM true)) + (&/$Some (&/$BoolA true)) true _ @@ -394,7 +394,7 @@ _ (&/without-repl-closure (&a-module/define module-name ?name def-type def-meta def-value)) _ (|case (&/T [is-type? (&a-meta/meta-get &a-meta/tags-tag def-meta)]) - [true (&/$Some (&/$ListM tags*))] + [true (&/$Some (&/$ListA tags*))] (|do [:let [was-exported? (|case (&a-meta/meta-get &a-meta/export?-tag def-meta) (&/$Some _) true @@ -403,7 +403,7 @@ false)] tags (&/map% (fn [tag*] (|case tag* - (&/$TextM tag) + (&/$TextA tag) (return tag) _ diff --git a/luxc/src/lux/lexer.clj b/luxc/src/lux/lexer.clj index 819c130f0..9dc77b411 100644 --- a/luxc/src/lux/lexer.clj +++ b/luxc/src/lux/lexer.clj @@ -17,7 +17,7 @@ ("Bool" 1) ("Nat" 1) ("Int" 1) - ("Frac" 1) + ("Deg" 1) ("Real" 1) ("Char" 1) ("Text" 1) @@ -158,7 +158,7 @@ (|do [[meta _ token] (&reader/read-regex )] (return (&/T [meta ( token)])))) - lex-bool $Bool #"^(true|false)" + lex-bool $Bool #"^(true|false)" ) (do-template [ ] @@ -166,10 +166,10 @@ (|do [[meta _ token] (&reader/read-regex )] (return (&/T [meta ( (string/replace token #"_" ""))])))) - lex-nat $Nat #"^\+(0|[1-9][0-9_]*)" - lex-int $Int #"^-?(0|[1-9][0-9_]*)" - lex-frac $Frac #"^(\.[0-9_]+)" - lex-real $Real #"^-?(0\.[0-9_]+|[1-9][0-9_]*\.[0-9_]+)(e-?[1-9][0-9_]*)?" + 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_]*)?" ) (def lex-char @@ -245,7 +245,7 @@ lex-bool lex-nat lex-real - lex-frac + lex-deg lex-int lex-char lex-text diff --git a/luxc/src/lux/optimizer.clj b/luxc/src/lux/optimizer.clj index 5c30dc44f..8ce8fc20e 100644 --- a/luxc/src/lux/optimizer.clj +++ b/luxc/src/lux/optimizer.clj @@ -13,7 +13,7 @@ ("bool" 1) ("nat" 1) ("int" 1) - ("frac" 1) + ("deg" 1) ("real" 1) ("char" 1) ("text" 1) @@ -75,8 +75,8 @@ ("NatPM" 1) ;; Compare the CDN with an integer value. ("IntPM" 1) - ;; Compare the CDN with a fractional value. - ("FracPM" 1) + ;; Compare the CDN with a degree value. + ("DegPM" 1) ;; Compare the CDN with a real value. ("RealPM" 1) ;; Compare the CDN with a character value. @@ -192,8 +192,8 @@ (&/|list ($IntPM _value) $PopPM) - (&a-case/$FracTestAC _value) - (&/|list ($FracPM _value) + (&a-case/$DegTestAC _value) + (&/|list ($DegPM _value) $PopPM) (&a-case/$RealTestAC _value) @@ -287,8 +287,8 @@ ($IntPM _value) (str "($IntPM " (pr-str _value) ")") - ($FracPM _value) - (str "($FracPM " (pr-str _value) ")") + ($DegPM _value) + (str "($DegPM " (pr-str _value) ")") ($RealPM _value) (str "($RealPM " (pr-str _value) ")") @@ -351,9 +351,9 @@ ($IntPM _pre-value) ($AltPM pre post)) - [($FracPM _pre-value) ($FracPM _post-value)] + [($DegPM _pre-value) ($DegPM _post-value)] (if (= _pre-value _post-value) - ($FracPM _pre-value) + ($DegPM _pre-value) ($AltPM pre post)) [($RealPM _pre-value) ($RealPM _post-value)] @@ -1079,8 +1079,8 @@ (&a/$int value) (&/T [meta ($int value)]) - (&a/$frac value) - (&/T [meta ($frac value)]) + (&a/$deg value) + (&/T [meta ($deg value)]) (&a/$real value) (&/T [meta ($real value)]) diff --git a/luxc/src/lux/parser.clj b/luxc/src/lux/parser.clj index ceafcd92e..c32528096 100644 --- a/luxc/src/lux/parser.clj +++ b/luxc/src/lux/parser.clj @@ -82,8 +82,8 @@ (&lexer/$Int ?value) (return (&/|list (&/T [meta (&/$IntS (Long/parseLong ?value))]))) - (&lexer/$Frac ?value) - (return (&/|list (&/T [meta (&/$FracS (&/decode-frac ?value))]))) + (&lexer/$Deg ?value) + (return (&/|list (&/T [meta (&/$DegS (&/decode-deg ?value))]))) (&lexer/$Real ?value) (return (&/|list (&/T [meta (&/$RealS (Double/parseDouble ?value))]))) diff --git a/luxc/src/lux/type.clj b/luxc/src/lux/type.clj index ba1dd0d70..099682775 100644 --- a/luxc/src/lux/type.clj +++ b/luxc/src/lux/type.clj @@ -30,7 +30,7 @@ (def Bool (&/$NamedT (&/T ["lux" "Bool"]) (&/$HostT "java.lang.Boolean" &/$Nil))) (def Nat (&/$NamedT (&/T ["lux" "Nat"]) (&/$HostT &&host/nat-data-tag &/$Nil))) -(def Frac (&/$NamedT (&/T ["lux" "Frac"]) (&/$HostT &&host/frac-data-tag &/$Nil))) +(def Deg (&/$NamedT (&/T ["lux" "Deg"]) (&/$HostT &&host/deg-data-tag &/$Nil))) (def Int (&/$NamedT (&/T ["lux" "Int"]) (&/$HostT "java.lang.Long" &/$Nil))) (def Real (&/$NamedT (&/T ["lux" "Real"]) (&/$HostT "java.lang.Double" &/$Nil))) (def Char (&/$NamedT (&/T ["lux" "Char"]) (&/$HostT "java.lang.Character" &/$Nil))) @@ -120,33 +120,33 @@ (let [Ann-Value (&/$AppT (&/$BoundT 0) (&/$BoundT 1))] (&/$AppT (&/$UnivQ empty-env (&/$SumT - ;; BoolM + ;; BoolA Bool (&/$SumT - ;; NatM + ;; NatA Nat (&/$SumT - ;; IntM + ;; IntA Int (&/$SumT - ;; FracM - Frac + ;; DegA + Deg (&/$SumT - ;; RealM + ;; RealA Real (&/$SumT - ;; CharM + ;; CharA Char (&/$SumT - ;; TextM + ;; TextA Text (&/$SumT - ;; IdentM + ;; IdentA Ident (&/$SumT - ;; ListM + ;; ListA (&/$AppT List Ann-Value) - ;; DictM + ;; DictA (&/$AppT List (&/$ProdT Text Ann-Value))))))))))) ) &/$VoidT)))) diff --git a/luxc/src/lux/type/host.clj b/luxc/src/lux/type/host.clj index 462e1aebe..33073fa34 100644 --- a/luxc/src/lux/type/host.clj +++ b/luxc/src/lux/type/host.clj @@ -17,7 +17,7 @@ (def array-data-tag "#Array") (def null-data-tag "#Null") (def nat-data-tag "#Nat") -(def frac-data-tag "#Frac") +(def deg-data-tag "#Deg") ;; [Utils] (defn ^:private trace-lineage* [^Class super-class ^Class sub-class] @@ -262,8 +262,8 @@ (try (cond (or (= "java.lang.Object" e!name) (and (= nat-data-tag e!name) (= nat-data-tag a!name)) - (and (= frac-data-tag e!name) - (= frac-data-tag a!name)) + (and (= deg-data-tag e!name) + (= deg-data-tag a!name)) (and (= null-data-tag e!name) (= null-data-tag a!name)) (and (not (primitive-type? e!name)) @@ -273,7 +273,7 @@ (or (and (= array-data-tag e!name) (not= array-data-tag a!name)) (= nat-data-tag e!name) (= nat-data-tag a!name) - (= frac-data-tag e!name) (= frac-data-tag a!name) + (= deg-data-tag e!name) (= deg-data-tag a!name) (= null-data-tag e!name) (= null-data-tag a!name)) (check-error "" (&/$HostT e!name e!params) (&/$HostT a!name a!params)) -- cgit v1.2.3