From fb72b937aba7886ce204379e97aa06c327a4029f Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Sun, 6 May 2018 23:27:12 -0400 Subject: - Implemented Nat functionality in pure Lux. --- .../translation/python/procedure/common.jvm.lux | 36 ++----------------- .../luxc/lang/translation/python/runtime.jvm.lux | 40 ---------------------- 2 files changed, 3 insertions(+), 73 deletions(-) (limited to 'new-luxc/source/luxc/lang/translation/python') 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 c201c417c..69b4aede4 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 @@ -228,9 +228,6 @@ Nullary ( ))] - [nat//min 0 python.int] - [nat//max -1 python.int] - [frac//smallest Double::MIN_VALUE python.float] [frac//min (f/* -1.0 Double::MAX_VALUE) python.float] [frac//max Double::MAX_VALUE python.float] @@ -269,10 +266,6 @@ [int//sub python.-] [int//mul python.*] - [nat//add python.+] - [nat//sub python.-] - [nat//mul python.*] - [deg//add python.+] [deg//sub python.-] [deg//rem python.-] @@ -288,9 +281,6 @@ [int//div python./] [int//rem python.%] - [nat//div runtimeT.nat///] - [nat//rem runtimeT.nat//%] - [deg//mul runtimeT.deg//*] [deg//div runtimeT.deg///] [deg//reciprocal python./] @@ -318,14 +308,11 @@ Binary ( paramO subjectO))] - [nat//= python.=] - [nat//< runtimeT.nat//<] - [int//= python.=] [int//< python.<] [deg//= python.=] - [deg//< runtimeT.nat//<] + [deg//< python.<] ) (def: (apply1 func) @@ -347,22 +334,6 @@ (python.global "float"))] ) -(def: nat-procs - Bundle - (<| (prefix "nat") - (|> (dict.new text.Hash) - (install "+" (binary nat//add)) - (install "-" (binary nat//sub)) - (install "*" (binary nat//mul)) - (install "/" (binary nat//div)) - (install "%" (binary nat//rem)) - (install "=" (binary nat//=)) - (install "<" (binary nat//<)) - (install "min" (nullary nat//min)) - (install "max" (nullary nat//max)) - (install "to-int" (unary id)) - (install "char" (unary (apply1 (python.global "chr"))))))) - (def: int-procs Bundle (<| (prefix "int") @@ -376,8 +347,8 @@ (install "<" (binary int//<)) (install "min" (nullary int//min)) (install "max" (nullary int//max)) - (install "to-nat" (unary id)) - (install "to-frac" (unary (apply1 (python.global "float"))))))) + (install "to-frac" (unary (apply1 (python.global "float")))) + (install "char" (unary (apply1 (python.global "chr"))))))) (def: deg-procs Bundle @@ -558,7 +529,6 @@ (<| (prefix "lux") (|> lux-procs (dict.merge bit-procs) - (dict.merge nat-procs) (dict.merge int-procs) (dict.merge deg-procs) (dict.merge frac-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 65e864d91..3457cc49b 100644 --- a/new-luxc/source/luxc/lang/translation/python/runtime.jvm.lux +++ b/new-luxc/source/luxc/lang/translation/python/runtime.jvm.lux @@ -285,45 +285,6 @@ (def: high (-> Expression Expression) (bit//logical-right-shift (python.int 32))) (def: low (-> Expression Expression) (python.bit-and full-32-bits)) -(runtime: (nat//< param subject) - (with-vars [ph sh] - ($_ python.then! - (python.set! (list ph) (..high param)) - (python.set! (list sh) (..high subject)) - (python.return! (python.or (python.< (@@ ph) (@@ sh)) - (python.and (python.= (@@ ph) (@@ sh)) - (python.< (low param) (low subject)))))))) - -(runtime: (nat/// param subject) - (with-vars [quotient remainder] - (python.if! (python.< (python.int 0) param) - (python.if! (nat//< param subject) - (python.return! (python.int 0)) - (python.return! (python.int 1))) - ($_ python.then! - (python.set! (list quotient) (|> subject - (python.bit-shr (python.int 1)) - (python./ param) - (python.bit-shl (python.int 1)))) - (let [remainder (python.- (python.* param (@@ quotient)) - subject)] - (python.if! (python.not (nat//< param remainder)) - (python.return! (python.+ (python.int 1) (@@ quotient))) - (python.return! (@@ quotient)))))))) - -(runtime: (nat//% param subject) - (let [flat (|> subject - (nat/// param) - (python.* param))] - (python.return! (|> subject (python.- flat))))) - -(def: runtime//nat - Runtime - ($_ python.then! - @@nat//< - @@nat/// - @@nat//%)) - (runtime: (deg//* param subject) (with-vars [$sL $sH $pL $pH $bottom $middle $top] ($_ python.then! @@ -561,7 +522,6 @@ runtime//lux runtime//adt runtime//bit - runtime//nat runtime//deg runtime//frac runtime//text -- cgit v1.2.3