aboutsummaryrefslogtreecommitdiff
path: root/luxc
diff options
context:
space:
mode:
authorEduardo Julian2017-03-28 20:50:07 -0400
committerEduardo Julian2017-03-28 20:50:07 -0400
commit27a2db0b345f9980ebc23e61a312637a0196a28f (patch)
treecf416f7e0328cdb7f932c5e165f2e89ff3253ade /luxc
parent77bdb17e48f5eaab34178db8765e41073d91c7ad (diff)
- Added ["deg" "reciprocal"] procedure.
Diffstat (limited to 'luxc')
-rw-r--r--luxc/src/lux/analyser/proc/common.clj22
-rw-r--r--luxc/src/lux/compiler/js/proc/common.clj2
-rw-r--r--luxc/src/lux/compiler/jvm/proc/common.clj2
3 files changed, 18 insertions, 8 deletions
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 [<name> <proc>]
+ (defn <name> [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 <proc>) (&/|list =x =y) (&/|list)))))))
+
+ ^:private analyse-deg-scale ["deg" "scale"]
+ ^:private analyse-deg-reciprocal ["deg" "reciprocal"]
+ )
(do-template [<encode> <encode-op> <decode> <decode-op> <type>]
(do (defn <encode> [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 [<name> <opcode>]
@@ -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"