diff options
author | Eduardo Julian | 2018-05-07 01:37:38 -0400 |
---|---|---|
committer | Eduardo Julian | 2018-05-07 01:37:38 -0400 |
commit | febfa99c2823219c2e76d2c73b1fd8db8f6c9918 (patch) | |
tree | f521419a80b04f465c6c9c5020c2063e2e555895 /new-luxc/source/luxc/lang/translation/python | |
parent | 3e2fddc6bfdda56dbe6947c476f85760b0811654 (diff) |
- Implemented Deg functionality in pure Lux.
Diffstat (limited to '')
-rw-r--r-- | new-luxc/source/luxc/lang/translation/python/procedure/common.jvm.lux | 43 | ||||
-rw-r--r-- | new-luxc/source/luxc/lang/translation/python/runtime.jvm.lux | 72 |
2 files changed, 0 insertions, 115 deletions
diff --git a/new-luxc/source/luxc/lang/translation/python/procedure/common.jvm.lux b/new-luxc/source/luxc/lang/translation/python/procedure/common.jvm.lux index 69b4aede4..0f5a3fdc9 100644 --- a/new-luxc/source/luxc/lang/translation/python/procedure/common.jvm.lux +++ b/new-luxc/source/luxc/lang/translation/python/procedure/common.jvm.lux @@ -231,9 +231,6 @@ [frac//smallest Double::MIN_VALUE python.float] [frac//min (f/* -1.0 Double::MAX_VALUE) python.float] [frac//max Double::MAX_VALUE python.float] - - [deg//min 0 python.int] - [deg//max -1 python.int] ) (do-template [<name> <expression>] @@ -265,11 +262,6 @@ [int//add python.+] [int//sub python.-] [int//mul python.*] - - [deg//add python.+] - [deg//sub python.-] - [deg//rem python.-] - [deg//scale python.*] ) (do-template [<name> <op>] @@ -280,10 +272,6 @@ [int//div python./] [int//rem python.%] - - [deg//mul runtimeT.deg//*] - [deg//div runtimeT.deg///] - [deg//reciprocal python./] ) (do-template [<name> <op>] @@ -310,9 +298,6 @@ [int//= python.=] [int//< python.<] - - [deg//= python.=] - [deg//< python.<] ) (def: (apply1 func) @@ -325,15 +310,6 @@ (function (_ object) (python.send (list) method object))) -(do-template [<name> <divisor>] - [(def: (<name> inputO) - Unary - (|> inputO (python./ <divisor>)))] - - [deg//to-frac (python.apply (list (|> (python.int 1) (python.bit-shl (python.int 32)))) - (python.global "float"))] - ) - (def: int-procs Bundle (<| (prefix "int") @@ -350,23 +326,6 @@ (install "to-frac" (unary (apply1 (python.global "float")))) (install "char" (unary (apply1 (python.global "chr"))))))) -(def: deg-procs - Bundle - (<| (prefix "deg") - (|> (dict.new text.Hash<Text>) - (install "+" (binary deg//add)) - (install "-" (binary deg//sub)) - (install "*" (binary deg//mul)) - (install "/" (binary deg//div)) - (install "%" (binary deg//rem)) - (install "=" (binary deg//=)) - (install "<" (binary deg//<)) - (install "scale" (binary deg//scale)) - (install "reciprocal" (binary deg//reciprocal)) - (install "min" (nullary deg//min)) - (install "max" (nullary deg//max)) - (install "to-frac" (unary deg//to-frac))))) - (def: frac-procs Bundle (<| (prefix "frac") @@ -384,7 +343,6 @@ (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-deg" (unary runtimeT.deg//from-frac)) (install "to-int" (unary (apply1 (python.global "int")))) (install "encode" (unary (apply1 (python.global "repr")))) (install "decode" (unary runtimeT.frac//decode))))) @@ -530,7 +488,6 @@ (|> lux-procs (dict.merge bit-procs) (dict.merge int-procs) - (dict.merge deg-procs) (dict.merge frac-procs) (dict.merge text-procs) (dict.merge array-procs) diff --git a/new-luxc/source/luxc/lang/translation/python/runtime.jvm.lux b/new-luxc/source/luxc/lang/translation/python/runtime.jvm.lux index 3457cc49b..9bcc46680 100644 --- a/new-luxc/source/luxc/lang/translation/python/runtime.jvm.lux +++ b/new-luxc/source/luxc/lang/translation/python/runtime.jvm.lux @@ -282,77 +282,6 @@ @@bit//count @@bit//logical-right-shift)) -(def: high (-> Expression Expression) (bit//logical-right-shift (python.int 32))) -(def: low (-> Expression Expression) (python.bit-and full-32-bits)) - -(runtime: (deg//* param subject) - (with-vars [$sL $sH $pL $pH $bottom $middle $top] - ($_ python.then! - (python.set! (list $sL) (..low subject)) - (python.set! (list $sH) (high subject)) - (python.set! (list $pL) (..low param)) - (python.set! (list $pH) (high param)) - (python.set! (list $bottom) (bit//logical-right-shift (python.int 32) - (python.* (@@ $pL) (@@ $sL)))) - (python.set! (list $middle) (python.+ (python.* (@@ $pL) (@@ $sH)) - (python.* (@@ $pH) (@@ $sL)))) - (python.set! (list $top) (python.* (@@ $pH) (@@ $sH))) - (python.return! (|> (@@ $bottom) - (python.+ (@@ $middle)) - high - (python.+ (@@ $top))))))) - -(runtime: (deg//leading-zeroes input) - (with-vars [zeroes remaining] - ($_ python.then! - (python.set! (list zeroes) (python.int 64)) - (python.set! (list remaining) input) - (python.while! (python.not (python.= (python.int 0) (@@ remaining))) - ($_ python.then! - (python.set! (list zeroes) (python.- (python.int 1) (@@ zeroes))) - (python.set! (list remaining) (bit//logical-right-shift (python.int 1) (@@ remaining))))) - (python.return! (@@ zeroes))))) - -(runtime: (deg/// param subject) - (with-vars [min-shift] - (python.if! (python.= param subject) - (python.return! (python.int -1)) - ($_ python.then! - (python.set! (list min-shift) - (python.apply (list (deg//leading-zeroes param) - (deg//leading-zeroes subject)) - (python.global "min"))) - (python.return! (|> (python.bit-shl (@@ min-shift) subject) - (python./ (|> param (python.bit-shl (@@ min-shift)) ..low)) - (python.bit-shl (python.int 32)))))))) - -(def: (float-to-int float) - (-> Expression Expression) - (python.apply (list float) (python.global "int"))) - -(runtime: (deg//from-frac input) - (with-vars [two32 shifted] - ($_ python.then! - (python.set! (list two32) (|> (python.float 2.0) - (python.** (python.float 32.0)))) - (python.set! (list shifted) (|> input - (python.% (python.float 1.0)) - (python.* (@@ two32)))) - (let [low (|> (@@ shifted) - (python.% (python.float 1.0)) - (python.* (@@ two32)) - float-to-int) - high (|> (@@ shifted) float-to-int (python.bit-shl (python.int 32)))] - (python.return! (|> low (python.+ high))))))) - -(def: runtime//deg - Runtime - ($_ python.then! - @@deg//* - @@deg//leading-zeroes - @@deg/// - @@deg//from-frac)) - (runtime: (frac//decode input) (let [$ex (python.var "ex")] (python.try! @@ -522,7 +451,6 @@ runtime//lux runtime//adt runtime//bit - runtime//deg runtime//frac runtime//text runtime//array |