Skip to content

Commit

Permalink
Re-named Frac to Dec.
Browse files Browse the repository at this point in the history
  • Loading branch information
eduardoejp committed Aug 19, 2023
1 parent 9b6682b commit 6fff522
Show file tree
Hide file tree
Showing 221 changed files with 2,269 additions and 2,179 deletions.
10 changes: 5 additions & 5 deletions licentia/source/program/licentia/input.lux
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
[number
["n" nat]
["i" int]
["f" frac]]]]]
["d" dec]]]]]
["[0]" //
["[1]" license (.only Identification
Termination
Expand Down Expand Up @@ -47,18 +47,18 @@
(exception.report
(list ["Amount" (<format> it)])))

[cannot_use_fractional_amount Frac %.frac]
[cannot_use_fractional_amount Dec %.dec]
[cannot_use_negative_amount Int %.int]
)

(the amount
(Parser Nat)
(do <>.monad
[amountF <json>.number
#let [amountI (f.int amountF)]
#let [amountI (d.int amountF)]
_ (<>.assert (exception.construct ..cannot_use_fractional_amount [amountF])
(f.= amountF
(i.frac amountI)))
(d.= amountF
(i.dec amountI)))
_ (<>.assert (exception.construct ..cannot_use_negative_amount [amountI])
(i.> +0 amountI))]
(wrap (.nat amountI))))
Expand Down
6 changes: 3 additions & 3 deletions lux-bootstrapper/src/lux/analyser.clj
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@
(|do [_ (&type/check exo-type &type/Rev)]
(return (&/|list (&&/|meta exo-type location (&&/$rev ?value)))))

(&/$Frac ?value)
(|do [_ (&type/check exo-type &type/Frac)]
(return (&/|list (&&/|meta exo-type location (&&/$frac ?value)))))
(&/$Dec ?value)
(|do [_ (&type/check exo-type &type/Dec)]
(return (&/|list (&&/|meta exo-type location (&&/$dec ?value)))))

(&/$Text ?value)
(|do [_ (&type/check exo-type &type/Text)]
Expand Down
2 changes: 1 addition & 1 deletion lux-bootstrapper/src/lux/analyser/base.clj
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
("nat" 1)
("int" 1)
("rev" 1)
("frac" 1)
("dec" 1)
("text" 1)
("variant" 3)
("tuple" 1)
Expand Down
30 changes: 15 additions & 15 deletions lux-bootstrapper/src/lux/analyser/case.clj
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
("NatTotal" 2)
("IntTotal" 2)
("RevTotal" 2)
("FracTotal" 2)
("DecTotal" 2)
("TextTotal" 2)
("TupleTotal" 2)
("VariantTotal" 2))
Expand All @@ -31,7 +31,7 @@
("NatTestAC" 1)
("IntTestAC" 1)
("RevTestAC" 1)
("FracTestAC" 1)
("DecTestAC" 1)
("TextTestAC" 1)
("TupleTestAC" 1)
("VariantTestAC" 1))
Expand Down Expand Up @@ -335,10 +335,10 @@
=kont kont]
(return (&/T [($RevTestAC ?value) =kont])))

(&/$Frac ?value)
(|do [_ (&type/check value-type &type/Frac)
(&/$Dec ?value)
(|do [_ (&type/check value-type &type/Dec)
=kont kont]
(return (&/T [($FracTestAC ?value) =kont])))
(return (&/T [($DecTestAC ?value) =kont])))

(&/$Text ?value)
(|do [_ (&type/check value-type &type/Text)
Expand Down Expand Up @@ -436,8 +436,8 @@
;; [($RevTotal total? ?values) ($NoTestAC)]
;; (return ($RevTotal true ?values))

;; [($FracTotal total? ?values) ($NoTestAC)]
;; (return ($FracTotal true ?values))
;; [($DecTotal total? ?values) ($NoTestAC)]
;; (return ($DecTotal true ?values))

;; [($TextTotal total? ?values) ($NoTestAC)]
;; (return ($TextTotal true ?values))
Expand All @@ -463,8 +463,8 @@
;; [($RevTotal total? ?values) ($StoreTestAC ?idx)]
;; (return ($RevTotal true ?values))

;; [($FracTotal total? ?values) ($StoreTestAC ?idx)]
;; (return ($FracTotal true ?values))
;; [($DecTotal total? ?values) ($StoreTestAC ?idx)]
;; (return ($DecTotal true ?values))

;; [($TextTotal total? ?values) ($StoreTestAC ?idx)]
;; (return ($TextTotal true ?values))
Expand Down Expand Up @@ -499,11 +499,11 @@
;; [($RevTotal total? ?values) ($RevTestAC ?value)]
;; (return ($RevTotal total? (&/$Item ?value ?values)))

;; [($DefaultTotal total?) ($FracTestAC ?value)]
;; (return ($FracTotal total? (&/|list ?value)))
;; [($DefaultTotal total?) ($DecTestAC ?value)]
;; (return ($DecTotal total? (&/|list ?value)))

;; [($FracTotal total? ?values) ($FracTestAC ?value)]
;; (return ($FracTotal total? (&/$Item ?value ?values)))
;; [($DecTotal total? ?values) ($DecTestAC ?value)]
;; (return ($DecTotal total? (&/$Item ?value ?values)))

;; [($DefaultTotal total?) ($TextTestAC ?value)]
;; (return ($TextTotal total? (&/|list ?value)))
Expand Down Expand Up @@ -586,8 +586,8 @@
;; (|do [_ (&type/check value-type &type/Rev)]
;; (return ?total))

;; ($FracTotal ?total _)
;; (|do [_ (&type/check value-type &type/Frac)]
;; ($DecTotal ?total _)
;; (|do [_ (&type/check value-type &type/Dec)]
;; (return ?total))

;; ($TextTotal ?total _)
Expand Down
4 changes: 2 additions & 2 deletions lux-bootstrapper/src/lux/analyser/parser.clj
Original file line number Diff line number Diff line change
Expand Up @@ -149,11 +149,11 @@
[_ (&lexer/$Int param-value*)] &lexer/lex-int]
(return (long param-value*)))

(|do [[_ (&lexer/$Frac param-value*)] &lexer/lex-frac]
(|do [[_ (&lexer/$Dec param-value*)] &lexer/lex-dec]
(return (float param-value*)))

(|do [_ (&reader/read-text "d")
[_ (&lexer/$Frac param-value*)] &lexer/lex-frac]
[_ (&lexer/$Dec param-value*)] &lexer/lex-dec]
(return (double param-value*)))

(|do [[_ (&lexer/$Text param-value*)] &lexer/lex-text]
Expand Down
28 changes: 14 additions & 14 deletions lux-bootstrapper/src/lux/analyser/proc/common.clj
Original file line number Diff line number Diff line change
Expand Up @@ -158,13 +158,13 @@
["i64" "%"] analyse-int-rem &type/Int &type/Int
["i64" "<"] analyse-int-lt &type/Int &type/Bit

["f64" "+"] analyse-f64-add &type/Frac &type/Frac
["f64" "-"] analyse-f64-sub &type/Frac &type/Frac
["f64" "*"] analyse-f64-mul &type/Frac &type/Frac
["f64" "/"] analyse-f64-div &type/Frac &type/Frac
["f64" "%"] analyse-f64-rem &type/Frac &type/Frac
["f64" "="] analyse-f64-eq &type/Frac &type/Bit
["f64" "<"] analyse-f64-lt &type/Frac &type/Bit
["f64" "+"] analyse-f64-add &type/Dec &type/Dec
["f64" "-"] analyse-f64-sub &type/Dec &type/Dec
["f64" "*"] analyse-f64-mul &type/Dec &type/Dec
["f64" "/"] analyse-f64-div &type/Dec &type/Dec
["f64" "%"] analyse-f64-rem &type/Dec &type/Dec
["f64" "="] analyse-f64-eq &type/Dec &type/Bit
["f64" "<"] analyse-f64-lt &type/Dec &type/Bit
)

(do-template [<encode> <encode-op> <decode> <decode-op> <type>]
Expand All @@ -185,7 +185,7 @@
(return (&/|list (&&/|meta exo-type _location
(&&/$proc (&/T <decode-op>) (&/|list =x) (&/|list)))))))))

analyse-f64-encode ["f64" "encode"] analyse-f64-decode ["f64" "decode"] &type/Frac
analyse-f64-encode ["f64" "encode"] analyse-f64-decode ["f64" "decode"] &type/Dec
)

(do-template [<name> <from-type> <to-type> <op>]
Expand All @@ -197,12 +197,12 @@
(return (&/|list (&&/|meta exo-type _location
(&&/$proc (&/T <op>) (&/|list =x) (&/|list)))))))

analyse-int-char &type/Int &type/Text ["i64" "char"]
analyse-int-frac &type/Int &type/Frac ["i64" "f64"]
analyse-f64-int &type/Frac &type/Int ["f64" "i64"]
analyse-int-char &type/Int &type/Text ["i64" "char"]
analyse-int-dec &type/Int &type/Dec ["i64" "f64"]
analyse-f64-int &type/Dec &type/Int ["f64" "i64"]

analyse-io-log &type/Text &type/Any ["io" "log"]
analyse-io-error &type/Text &type/Nothing ["io" "error"]
analyse-io-log &type/Text &type/Any ["io" "log"]
analyse-io-error &type/Text &type/Nothing ["io" "error"]
)

(defn- analyse-syntax-char-case! [analyse exo-type ?values]
Expand Down Expand Up @@ -280,7 +280,7 @@
"int_%#" (analyse-int-rem analyse exo-type ?values)
"int_<#" (analyse-int-lt analyse exo-type ?values)

"int_f64#" (analyse-int-frac analyse exo-type ?values)
"int_f64#" (analyse-int-dec analyse exo-type ?values)
"int_char#" (analyse-int-char analyse exo-type ?values)

"f64_+#" (analyse-f64-add analyse exo-type ?values)
Expand Down
4 changes: 2 additions & 2 deletions lux-bootstrapper/src/lux/base.clj
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
("Nat" 1)
("Int" 1)
("Rev" 1)
("Frac" 1)
("Dec" 1)
("Text" 1)
("Identifier" 1)
("Form" 1)
Expand Down Expand Up @@ -1262,7 +1262,7 @@
[_ ($Rev ?value)]
(encode-rev ?value)

[_ ($Frac ?value)]
[_ ($Dec ?value)]
(pr-str ?value)

[_ ($Text ?value)]
Expand Down
12 changes: 6 additions & 6 deletions lux-bootstrapper/src/lux/compiler/cache/ann.clj
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@
(str "I" value stop)

[_ (&/$Rev value)]
(str "D" value stop)
(str "R" value stop)

[_ (&/$Frac value)]
(str "F" value stop)
[_ (&/$Dec value)]
(str "D" value stop)

[_ (&/$Text value)]
(str "T" value stop)
Expand Down Expand Up @@ -75,8 +75,8 @@
^: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
^:private deserialize-frac "F" &/$Frac Double/parseDouble
^:private deserialize-rev "R" &/$Rev Long/parseLong
^:private deserialize-dec "D" &/$Dec Double/parseDouble
^:private deserialize-text "T" &/$Text identity
)

Expand Down Expand Up @@ -118,7 +118,7 @@
(deserialize-nat input)
(deserialize-int input)
(deserialize-rev input)
(deserialize-frac input)
(deserialize-dec input)
(deserialize-text input)
(deserialize-identifier input)
(deserialize-form input)
Expand Down
4 changes: 2 additions & 2 deletions lux-bootstrapper/src/lux/compiler/jvm.clj
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@
(&o/$rev ?value)
(&&lux/compile-rev ?value)

(&o/$frac ?value)
(&&lux/compile-frac ?value)
(&o/$dec ?value)
(&&lux/compile-dec ?value)

(&o/$text ?value)
(&&lux/compile-text ?value)
Expand Down
2 changes: 1 addition & 1 deletion lux-bootstrapper/src/lux/compiler/jvm/case.clj
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@
(.visitInsn Opcodes/LCMP)
(.visitJumpInsn Opcodes/IFNE $else))

(&o/$FracPM _value)
(&o/$DecPM _value)
(doto writer
stack-peek
&&/unwrap-double
Expand Down
8 changes: 4 additions & 4 deletions lux-bootstrapper/src/lux/compiler/jvm/lux.clj
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@
(.visitMethodInsn Opcodes/INVOKESTATIC <class> "valueOf" (str "(" <prim> ")" (&host-generics/->type-signature <class>))))]]
(return nil)))

compile-nat "java/lang/Long" "J" long
compile-int "java/lang/Long" "J" long
compile-rev "java/lang/Long" "J" long
compile-frac "java/lang/Double" "D" double
compile-nat "java/lang/Long" "J" long
compile-int "java/lang/Long" "J" long
compile-rev "java/lang/Long" "J" long
compile-dec "java/lang/Double" "D" double
)

(defn compile-text [?value]
Expand Down
46 changes: 23 additions & 23 deletions lux-bootstrapper/src/lux/compiler/jvm/proc/common.clj
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,11 @@
^:private compile-int-div Opcodes/LDIV &&/unwrap-long &&/wrap-long
^:private compile-int-rem Opcodes/LREM &&/unwrap-long &&/wrap-long

^: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
^:private compile-dec-add Opcodes/DADD &&/unwrap-double &&/wrap-double
^:private compile-dec-sub Opcodes/DSUB &&/unwrap-double &&/wrap-double
^:private compile-dec-mul Opcodes/DMUL &&/unwrap-double &&/wrap-double
^:private compile-dec-div Opcodes/DDIV &&/unwrap-double &&/wrap-double
^:private compile-dec-rem Opcodes/DREM &&/unwrap-double &&/wrap-double
)

(do-template [<name> <cmpcode> <cmp-output> <unwrap>]
Expand Down Expand Up @@ -145,11 +145,11 @@

^:private compile-int-lt Opcodes/LCMP -1 &&/unwrap-long

^:private compile-frac-eq Opcodes/DCMPG 0 &&/unwrap-double
^:private compile-frac-lt Opcodes/DCMPG -1 &&/unwrap-double
^:private compile-dec-eq Opcodes/DCMPG 0 &&/unwrap-double
^:private compile-dec-lt Opcodes/DCMPG -1 &&/unwrap-double
)

(defn ^:private compile-frac-encode [compile ?values special-args]
(defn ^:private compile-dec-encode [compile ?values special-args]
(|do [:let [(&/$Item ?input (&/$End)) ?values]
^MethodVisitor *writer* &/get-writer
_ (compile ?input)
Expand All @@ -158,13 +158,13 @@
(.visitMethodInsn Opcodes/INVOKESTATIC "java/lang/Double" "toString" "(D)Ljava/lang/String;"))]]
(return nil)))

(defn ^:private compile-frac-decode [compile ?values special-args]
(defn ^:private compile-dec-decode [compile ?values special-args]
(|do [:let [(&/$Item ?input (&/$End)) ?values]
^MethodVisitor *writer* &/get-writer
_ (compile ?input)
:let [_ (doto *writer*
(.visitTypeInsn Opcodes/CHECKCAST "java/lang/String")
(.visitMethodInsn Opcodes/INVOKESTATIC &rt/runtime-class "decode_frac" "(Ljava/lang/String;)[Ljava/lang/Object;"))]]
(.visitMethodInsn Opcodes/INVOKESTATIC &rt/runtime-class "decode_dec" "(Ljava/lang/String;)[Ljava/lang/Object;"))]]
(return nil)))

(defn ^:private compile-int-char [compile ?values special-args]
Expand All @@ -189,8 +189,8 @@
<wrap>)]]
(return nil)))

^:private compile-frac-int &&/unwrap-double Opcodes/D2L &&/wrap-long
^:private compile-int-frac &&/unwrap-long Opcodes/L2D &&/wrap-double
^:private compile-dec-int &&/unwrap-double Opcodes/D2L &&/wrap-long
^:private compile-int-dec &&/unwrap-long Opcodes/L2D &&/wrap-double
)

(defn ^:private compile-text-eq [compile ?values special-args]
Expand Down Expand Up @@ -445,22 +445,22 @@
"/" (compile-int-div compile ?values special-args)
"%" (compile-int-rem compile ?values special-args)
"<" (compile-int-lt compile ?values special-args)
"f64" (compile-int-frac compile ?values special-args)
"f64" (compile-int-dec compile ?values special-args)
"char" (compile-int-char compile ?values special-args)
)

"f64"
(case proc
"+" (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)
"i64" (compile-frac-int compile ?values special-args)
"encode" (compile-frac-encode compile ?values special-args)
"decode" (compile-frac-decode compile ?values special-args)
"+" (compile-dec-add compile ?values special-args)
"-" (compile-dec-sub compile ?values special-args)
"*" (compile-dec-mul compile ?values special-args)
"/" (compile-dec-div compile ?values special-args)
"%" (compile-dec-rem compile ?values special-args)
"=" (compile-dec-eq compile ?values special-args)
"<" (compile-dec-lt compile ?values special-args)
"i64" (compile-dec-int compile ?values special-args)
"encode" (compile-dec-encode compile ?values special-args)
"decode" (compile-dec-decode compile ?values special-args)
)

;; else
Expand Down
Loading

0 comments on commit 6fff522

Please sign in to comment.