From 971d5d8aceb5087d3b3aef9db45abe9bc9c7c844 Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Wed, 4 Jul 2018 00:03:28 -0400 Subject: - Implemented not-a-number and both infinities in pure Lux. --- luxc/src/lux/analyser/proc/common.clj | 6 ------ luxc/src/lux/compiler/jvm/proc/common.clj | 7 ------- .../lang/translation/common-lisp/procedure/common.jvm.lux | 13 ------------- .../luxc/lang/translation/js/procedure/common.jvm.lux | 11 +---------- .../luxc/lang/translation/jvm/procedure/common.jvm.lux | 11 +---------- .../luxc/lang/translation/lua/procedure/common.jvm.lux | 13 ------------- .../luxc/lang/translation/php/procedure/common.jvm.lux | 13 ------------- .../luxc/lang/translation/python/procedure/common.jvm.lux | 13 ------------- .../source/luxc/lang/translation/r/procedure/common.jvm.lux | 13 ------------- .../luxc/lang/translation/ruby/procedure/common.jvm.lux | 13 ------------- new-luxc/test/test/luxc/lang/translation/common.lux | 3 --- stdlib/source/lux/data/number.lux | 10 +++++----- .../source/lux/lang/compiler/extension/analysis/common.lux | 3 --- .../compiler/translation/scheme/extension/common.jvm.lux | 13 ------------- .../test/lux/lang/compiler/analysis/procedure/common.lux | 6 ------ 15 files changed, 7 insertions(+), 141 deletions(-) diff --git a/luxc/src/lux/analyser/proc/common.clj b/luxc/src/lux/analyser/proc/common.clj index ac5900634..0d7b6dd1e 100644 --- a/luxc/src/lux/analyser/proc/common.clj +++ b/luxc/src/lux/analyser/proc/common.clj @@ -230,9 +230,6 @@ ^:private analyse-frac-smallest &type/Frac ["frac" "smallest"] ^:private analyse-frac-min &type/Frac ["frac" "min"] ^:private analyse-frac-max &type/Frac ["frac" "max"] - ^: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 [ ] @@ -491,9 +488,6 @@ "lux frac smallest" (analyse-frac-smallest analyse exo-type ?values) "lux frac min" (analyse-frac-min analyse exo-type ?values) "lux frac max" (analyse-frac-max analyse exo-type ?values) - "lux frac not-a-number" (analyse-frac-not-a-number analyse exo-type ?values) - "lux frac positive-infinity" (analyse-frac-positive-infinity analyse exo-type ?values) - "lux frac negative-infinity" (analyse-frac-negative-infinity analyse exo-type ?values) "lux frac int" (analyse-frac-int analyse exo-type ?values) "lux math cos" (analyse-math-cos analyse exo-type ?values) diff --git a/luxc/src/lux/compiler/jvm/proc/common.clj b/luxc/src/lux/compiler/jvm/proc/common.clj index 571bbadc7..aca1921fe 100644 --- a/luxc/src/lux/compiler/jvm/proc/common.clj +++ b/luxc/src/lux/compiler/jvm/proc/common.clj @@ -248,10 +248,6 @@ ^:private compile-frac-smallest Double/MIN_VALUE ^:private compile-frac-min (* -1.0 Double/MAX_VALUE) ^:private compile-frac-max Double/MAX_VALUE - - ^:private compile-frac-not-a-number Double/NaN - ^:private compile-frac-positive-infinity Double/POSITIVE_INFINITY - ^:private compile-frac-negative-infinity Double/NEGATIVE_INFINITY ) (defn ^:private compile-frac-encode [compile ?values special-args] @@ -708,9 +704,6 @@ "smallest" (compile-frac-smallest compile ?values special-args) "max" (compile-frac-max compile ?values special-args) "min" (compile-frac-min 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) "int" (compile-frac-int compile ?values special-args) "encode" (compile-frac-encode compile ?values special-args) "decode" (compile-frac-decode compile ?values special-args) diff --git a/new-luxc/source/luxc/lang/translation/common-lisp/procedure/common.jvm.lux b/new-luxc/source/luxc/lang/translation/common-lisp/procedure/common.jvm.lux index b7dd1b58a..3f878319b 100644 --- a/new-luxc/source/luxc/lang/translation/common-lisp/procedure/common.jvm.lux +++ b/new-luxc/source/luxc/lang/translation/common-lisp/procedure/common.jvm.lux @@ -229,16 +229,6 @@ [int//max ("lux int max")] ) -(do-template [ ] - [(def: ( _) - Nullary - (_.double ))] - - [frac//not-a-number number.not-a-number] - [frac//positive-infinity number.positive-infinity] - [frac//negative-infinity number.negative-infinity] - ) - (do-template [ ] [(def: ( [subjectO paramO]) Binary @@ -304,9 +294,6 @@ (install "smallest" (nullary frac//smallest)) (install "min" (nullary frac//min)) (install "max" (nullary frac//max)) - (install "not-a-number" (nullary frac//not-a-number)) - (install "positive-infinity" (nullary frac//positive-infinity)) - (install "negative-infinity" (nullary frac//negative-infinity)) (install "to-int" (unary _.floor/1))))) ## ## [[Text]] diff --git a/new-luxc/source/luxc/lang/translation/js/procedure/common.jvm.lux b/new-luxc/source/luxc/lang/translation/js/procedure/common.jvm.lux index 1d4e0e5c4..d9e64d4a1 100644 --- a/new-luxc/source/luxc/lang/translation/js/procedure/common.jvm.lux +++ b/new-luxc/source/luxc/lang/translation/js/procedure/common.jvm.lux @@ -192,10 +192,7 @@ (host.import: java/lang/Double (#static MIN_VALUE Double) - (#static MAX_VALUE Double) - (#static NaN Double) - (#static POSITIVE_INFINITY Double) - (#static NEGATIVE_INFINITY Double)) + (#static MAX_VALUE Double)) (do-template [ ] [(def: ( _) @@ -208,9 +205,6 @@ [frac//smallest Double::MIN_VALUE runtimeT.frac] [frac//min (f/* -1.0 Double::MAX_VALUE) runtimeT.frac] [frac//max Double::MAX_VALUE runtimeT.frac] - [frac//not-a-number Double::NaN runtimeT.frac] - [frac//positive-infinity Double::POSITIVE_INFINITY runtimeT.frac] - [frac//negative-infinity Double::NEGATIVE_INFINITY runtimeT.frac] ) (do-template [ ] @@ -458,9 +452,6 @@ (install "smallest" (nullary frac//smallest)) (install "min" (nullary frac//min)) (install "max" (nullary frac//max)) - (install "not-a-number" (nullary frac//not-a-number)) - (install "positive-infinity" (nullary frac//positive-infinity)) - (install "negative-infinity" (nullary frac//negative-infinity)) (install "to-int" (unary frac//to-int)) (install "encode" (unary frac//encode)) (install "decode" (unary frac//decode))))) 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 db92bc413..c60c424f5 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 @@ -32,10 +32,7 @@ (host.import: java/lang/Double (#static MIN_VALUE Double) - (#static MAX_VALUE Double) - (#static NaN Double) - (#static POSITIVE_INFINITY Double) - (#static NEGATIVE_INFINITY Double)) + (#static MAX_VALUE Double)) ## [Types] (type: #export Translator @@ -267,9 +264,6 @@ [frac//smallest ($i.double Double::MIN_VALUE) #$.Double] [frac//min ($i.double (f/* -1.0 Double::MAX_VALUE)) #$.Double] [frac//max ($i.double Double::MAX_VALUE) #$.Double] - [frac//not-a-number ($i.double Double::NaN) #$.Double] - [frac//positive-infinity ($i.double Double::POSITIVE_INFINITY) #$.Double] - [frac//negative-infinity ($i.double Double::NEGATIVE_INFINITY) #$.Double] ) (do-template [ ] @@ -598,9 +592,6 @@ (install "smallest" (nullary frac//smallest)) (install "min" (nullary frac//min)) (install "max" (nullary frac//max)) - (install "not-a-number" (nullary frac//not-a-number)) - (install "positive-infinity" (nullary frac//positive-infinity)) - (install "negative-infinity" (nullary frac//negative-infinity)) (install "to-int" (unary frac//to-int)) (install "encode" (unary frac//encode)) (install "decode" (unary frac//decode))))) diff --git a/new-luxc/source/luxc/lang/translation/lua/procedure/common.jvm.lux b/new-luxc/source/luxc/lang/translation/lua/procedure/common.jvm.lux index 21baddcfc..b54829a62 100644 --- a/new-luxc/source/luxc/lang/translation/lua/procedure/common.jvm.lux +++ b/new-luxc/source/luxc/lang/translation/lua/procedure/common.jvm.lux @@ -203,16 +203,6 @@ [int//max "math.maxinteger"] ) -(do-template [ ] - [(def: ( _) - Nullary - )] - - [frac//not-a-number (lua./ (lua.int 0) (lua.int 0))] - [frac//positive-infinity "math.huge"] - [frac//negative-infinity (lua.* (lua.int -1) "math.huge")] - ) - (do-template [ ] [(def: ( [subjectO paramO]) Binary @@ -447,9 +437,6 @@ (install "smallest" (nullary frac//smallest)) (install "min" (nullary frac//min)) (install "max" (nullary frac//max)) - (install "not-a-number" (nullary frac//not-a-number)) - (install "positive-infinity" (nullary frac//positive-infinity)) - (install "negative-infinity" (nullary frac//negative-infinity)) (install "to-int" (unary frac//to-int)) (install "encode" (unary frac//encode)) (install "decode" (unary frac//decode))))) diff --git a/new-luxc/source/luxc/lang/translation/php/procedure/common.jvm.lux b/new-luxc/source/luxc/lang/translation/php/procedure/common.jvm.lux index 8ce6fe1ef..73185ff66 100644 --- a/new-luxc/source/luxc/lang/translation/php/procedure/common.jvm.lux +++ b/new-luxc/source/luxc/lang/translation/php/procedure/common.jvm.lux @@ -236,16 +236,6 @@ [int//max (|> (_.int 2) (_.** (_.int 63)) (_.- (_.int 1)))] ) -## (do-template [