From 7dc94b0ba528b40d13e88732ba307a1a24ac93c3 Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Mon, 20 Aug 2018 18:57:06 -0400 Subject: - Fixed ordering issue with Lux arithmetic extensions. - Fixed naming issue with extensions. --- luxc/src/lux/analyser/proc/common.clj | 4 +-- .../lang/translation/jvm/procedure/common.jvm.lux | 36 +++++++++++----------- stdlib/source/lux.lux | 22 ++++++------- .../lux/compiler/default/phase/extension.lux | 5 +-- .../default/phase/extension/analysis/common.lux | 5 ++- 5 files changed, 35 insertions(+), 37 deletions(-) diff --git a/luxc/src/lux/analyser/proc/common.clj b/luxc/src/lux/analyser/proc/common.clj index f382c2ff3..8c6bd9d88 100644 --- a/luxc/src/lux/analyser/proc/common.clj +++ b/luxc/src/lux/analyser/proc/common.clj @@ -135,9 +135,9 @@ (let [inputT outputT ] (defn [analyse exo-type ?values] - (|do [:let [(&/$Cons paramC (&/$Cons subjectC (&/$Nil))) ?values] - paramA (&&/analyse-1 analyse paramC) + (|do [:let [(&/$Cons subjectC (&/$Cons paramC (&/$Nil))) ?values] subjectA (&&/analyse-1 analyse subjectC) + paramA (&&/analyse-1 analyse paramC) _ (&type/check exo-type ) _cursor &/cursor] (return (&/|list (&&/|meta exo-type _cursor diff --git a/new-luxc/source/luxc/lang/translation/jvm/procedure/common.jvm.lux b/new-luxc/source/luxc/lang/translation/jvm/procedure/common.jvm.lux index b073aa3b7..1b784ee76 100644 --- a/new-luxc/source/luxc/lang/translation/jvm/procedure/common.jvm.lux +++ b/new-luxc/source/luxc/lang/translation/jvm/procedure/common.jvm.lux @@ -119,7 +119,7 @@ ### Bits (do-template [ ] - [(def: ( [inputI maskI]) + [(def: ( [maskI inputI]) Binary (|>> inputI (_.unwrap #$.Long) maskI (_.unwrap #$.Long) @@ -131,7 +131,7 @@ ) (do-template [ ] - [(def: ( [inputI shiftI]) + [(def: ( [shiftI inputI]) Binary (|>> inputI (_.unwrap #$.Long) shiftI jvm-intI @@ -162,11 +162,11 @@ (_.wrap )))] - [i64::+ #$.Long _.LADD] - [i64::- #$.Long _.LSUB] - [i64::* #$.Long _.LMUL] - [i64::/ #$.Long _.LDIV] - [i64::% #$.Long _.LREM] + [i64::+ #$.Long _.LADD] + [i64::- #$.Long _.LSUB] + [int::* #$.Long _.LMUL] + [int::/ #$.Long _.LDIV] + [int::% #$.Long _.LREM] [frac::+ #$.Double _.DADD] [frac::- #$.Double _.DSUB] @@ -188,7 +188,7 @@ [ +0] [ -1])] - [i64::= i64::< (_.unwrap #$.Long) _.LCMP] + [i64::= int::< (_.unwrap #$.Long) _.LCMP] [frac::= frac::< (_.unwrap #$.Double) _.DCMPG] ) @@ -197,11 +197,11 @@ Unary (|>> inputI ))] - [i64::to-frac (_.unwrap #$.Long) (<| (_.wrap #$.Double) _.L2D)] - [i64::char (_.unwrap #$.Long) + [int::frac (_.unwrap #$.Long) (<| (_.wrap #$.Double) _.L2D)] + [int::char (_.unwrap #$.Long) ((|>> _.L2I _.I2C (_.INVOKESTATIC "java.lang.Character" "toString" (_t.method (list _t.char) (#.Some $String) (list)) #0)))] - [frac::to-i64 (_.unwrap #$.Double) (<| (_.wrap #$.Long) _.D2L)] + [frac::int (_.unwrap #$.Double) (<| (_.wrap #$.Long) _.D2L)] [frac::encode (_.unwrap #$.Double) (_.INVOKESTATIC "java.lang.Double" "toString" (_t.method (list _t.double) (#.Some $String) (list)) #0)] [frac::decode ..check-stringI @@ -325,12 +325,12 @@ Bundle (<| (bundle.prefix "int") (|> (: Bundle bundle.empty) - (bundle.install "*" (binary i64::*)) - (bundle.install "/" (binary i64::/)) - (bundle.install "%" (binary i64::%)) - (bundle.install "<" (binary i64::<)) - (bundle.install "to-frac" (unary i64::to-frac)) - (bundle.install "char" (unary i64::char))))) + (bundle.install "*" (binary int::*)) + (bundle.install "/" (binary int::/)) + (bundle.install "%" (binary int::%)) + (bundle.install "<" (binary int::<)) + (bundle.install "frac" (unary int::frac)) + (bundle.install "char" (unary int::char))))) (def: bundle::frac Bundle @@ -346,7 +346,7 @@ (bundle.install "smallest" (nullary frac::smallest)) (bundle.install "min" (nullary frac::min)) (bundle.install "max" (nullary frac::max)) - (bundle.install "to-i64" (unary frac::to-i64)) + (bundle.install "int" (unary frac::int)) (bundle.install "encode" (unary frac::encode)) (bundle.install "decode" (unary frac::decode))))) diff --git a/stdlib/source/lux.lux b/stdlib/source/lux.lux index 48540c114..bf92eb4db 100644 --- a/stdlib/source/lux.lux +++ b/stdlib/source/lux.lux @@ -1138,7 +1138,7 @@ (#.Cons export-meta #.Nil)) (#Function Nat (#Function Nat Nat)) - ("lux i64 -" param subject)) + ("lux i64 -" subject param)) (def:'' (n/* param subject) (#.Cons (doc-meta "Nat(ural) multiplication.") @@ -2204,9 +2204,7 @@ (def:''' low-mask (list) I64 - (|> 1 - ("lux i64 left-shift" 32) - ("lux i64 -" 1))) + ("lux i64 -" ("lux i64 left-shift" 32 1) 1)) (def:''' (low-bits value) (list) @@ -2376,7 +2374,7 @@ flat ("lux int *" ("lux coerce" Int quotient) ("lux coerce" Int param)) - remainder ("lux i64 -" flat subject)] + remainder ("lux i64 -" subject flat)] (if (n/< param remainder) quotient ("lux i64 +" 1 quotient))))) @@ -2389,7 +2387,7 @@ flat ("lux int *" ("lux coerce" Int div) ("lux coerce" Int param))] - [div ("lux i64 -" flat subject)])) + [div ("lux i64 -" subject flat)])) (def:''' #export (n/% param subject) (list [(tag$ ["lux" "doc"]) @@ -2398,14 +2396,14 @@ (let' [flat ("lux int *" ("lux coerce" Int (n// param subject)) ("lux coerce" Int param))] - ("lux i64 -" flat subject))) + ("lux i64 -" subject flat))) (do-template [ ] [(def:''' #export ( param subject) (list [(tag$ ["lux" "doc"]) (text$ )]) (-> ) - ( param subject))] + ( subject param))] [ Int i/+ "lux i64 +" "Int(eger) addition."] [ Int i/- "lux i64 -" "Int(eger) substraction."] @@ -2476,7 +2474,7 @@ (if ("lux i64 =" +0 trailing-zeroes) [1 ("lux i64 logical-right-shift" 1 remaining)] [trailing-zeroes remaining])) - shift ("lux i64 -" trailing-zeroes 64) + shift ("lux i64 -" 64 trailing-zeroes) numerator ("lux i64 left-shift" shift 1)] ("lux coerce" Rev ("lux int *" @@ -5172,11 +5170,11 @@ )] ($_ text/compose "\"" escaped "\""))) -(do-template [ ] - [(def: #export +(do-template [ ] + [(def: #export ( value) {#.doc } (All [s] (-> (I64 s) (I64 s))) - (|>> ( 1)))] + ( value 1))] [inc "lux i64 +" "Increment function."] [dec "lux i64 -" "Decrement function."] diff --git a/stdlib/source/lux/compiler/default/phase/extension.lux b/stdlib/source/lux/compiler/default/phase/extension.lux index 99c7152c7..38ca02700 100644 --- a/stdlib/source/lux/compiler/default/phase/extension.lux +++ b/stdlib/source/lux/compiler/default/phase/extension.lux @@ -5,10 +5,10 @@ ["ex" exception (#+ exception:)]] [data ["." error (#+ Error)] - ["." text + ["." text ("text/." Order) format] [collection - [list ("list/." Functor)] + ["." list ("list/." Functor)] ["." dictionary (#+ Dictionary)]]] ["." function]] ["." //]) @@ -48,6 +48,7 @@ ["Extension" (%t name)] ["Available" (|> bundle dictionary.keys + (list.sort text/<) (list/map (|>> %t (format "\n\t"))) (text.join-with ""))])) diff --git a/stdlib/source/lux/compiler/default/phase/extension/analysis/common.lux b/stdlib/source/lux/compiler/default/phase/extension/analysis/common.lux index a55e7b2b5..690a4accb 100644 --- a/stdlib/source/lux/compiler/default/phase/extension/analysis/common.lux +++ b/stdlib/source/lux/compiler/default/phase/extension/analysis/common.lux @@ -171,7 +171,7 @@ (bundle.install "/" (binary Int Int Int)) (bundle.install "%" (binary Int Int Int)) (bundle.install "<" (binary Int Int Bit)) - (bundle.install "to-frac" (unary Int Frac)) + (bundle.install "frac" (unary Int Frac)) (bundle.install "char" (unary Int Text))))) (def: bundle::frac @@ -188,8 +188,7 @@ (bundle.install "smallest" (nullary Frac)) (bundle.install "min" (nullary Frac)) (bundle.install "max" (nullary Frac)) - (bundle.install "to-rev" (unary Frac Rev)) - (bundle.install "to-int" (unary Frac Int)) + (bundle.install "int" (unary Frac Int)) (bundle.install "encode" (unary Frac Text)) (bundle.install "decode" (unary Text (type (Maybe Frac))))))) -- cgit v1.2.3