From 27a2db0b345f9980ebc23e61a312637a0196a28f Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Tue, 28 Mar 2017 20:50:07 -0400 Subject: - Added ["deg" "reciprocal"] procedure. --- luxc/src/lux/analyser/proc/common.clj | 22 ++++++++++++++-------- luxc/src/lux/compiler/js/proc/common.clj | 2 ++ luxc/src/lux/compiler/jvm/proc/common.clj | 2 ++ 3 files changed, 18 insertions(+), 8 deletions(-) (limited to 'luxc/src') diff --git a/luxc/src/lux/analyser/proc/common.clj b/luxc/src/lux/analyser/proc/common.clj index ff85600ab..b2a9528c1 100644 --- a/luxc/src/lux/analyser/proc/common.clj +++ b/luxc/src/lux/analyser/proc/common.clj @@ -222,14 +222,19 @@ ^:private analyse-char-lt ["char" "<"] &type/Char &type/Bool ) -(defn ^:private analyse-deg-scale [analyse exo-type ?values] - (|do [:let [(&/$Cons x (&/$Cons y (&/$Nil))) ?values] - =x (&&/analyse-1 analyse &type/Deg x) - =y (&&/analyse-1 analyse &type/Nat y) - _ (&type/check exo-type &type/Deg) - _cursor &/cursor] - (return (&/|list (&&/|meta exo-type _cursor - (&&/$proc (&/T ["deg" "scale"]) (&/|list =x =y) (&/|list))))))) +(do-template [ ] + (defn [analyse exo-type ?values] + (|do [:let [(&/$Cons x (&/$Cons y (&/$Nil))) ?values] + =x (&&/analyse-1 analyse &type/Deg x) + =y (&&/analyse-1 analyse &type/Nat y) + _ (&type/check exo-type &type/Deg) + _cursor &/cursor] + (return (&/|list (&&/|meta exo-type _cursor + (&&/$proc (&/T ) (&/|list =x =y) (&/|list))))))) + + ^:private analyse-deg-scale ["deg" "scale"] + ^:private analyse-deg-reciprocal ["deg" "reciprocal"] + ) (do-template [ ] (do (defn [analyse exo-type ?values] @@ -579,6 +584,7 @@ "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) + "reciprocal" (analyse-deg-reciprocal analyse exo-type ?values) ) "real" diff --git a/luxc/src/lux/compiler/js/proc/common.clj b/luxc/src/lux/compiler/js/proc/common.clj index f6591c8fa..03ce5e936 100644 --- a/luxc/src/lux/compiler/js/proc/common.clj +++ b/luxc/src/lux/compiler/js/proc/common.clj @@ -122,6 +122,7 @@ ^:private compile-deg-eq "eqI64" ^:private compile-deg-lt "ltD64" ^:private compile-deg-scale "mulI64" + ^:private compile-deg-reciprocal "divI64" ) (do-template [ ] @@ -540,6 +541,7 @@ "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) + "reciprocal" (compile-deg-reciprocal compile ?values special-args) ) "real" diff --git a/luxc/src/lux/compiler/jvm/proc/common.clj b/luxc/src/lux/compiler/jvm/proc/common.clj index c8623985a..323213170 100644 --- a/luxc/src/lux/compiler/jvm/proc/common.clj +++ b/luxc/src/lux/compiler/jvm/proc/common.clj @@ -217,6 +217,7 @@ ^:private compile-deg-sub Opcodes/LSUB &&/unwrap-long &&/wrap-long ^:private compile-deg-rem Opcodes/LSUB &&/unwrap-long &&/wrap-long ^: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 @@ -968,6 +969,7 @@ "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) + "reciprocal" (compile-deg-reciprocal compile ?values special-args) ) "int" -- cgit v1.2.3