From febfa99c2823219c2e76d2c73b1fd8db8f6c9918 Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Mon, 7 May 2018 01:37:38 -0400 Subject: - Implemented Deg functionality in pure Lux. --- .../luxc/lang/translation/python/runtime.jvm.lux | 72 ---------------------- 1 file changed, 72 deletions(-) (limited to 'new-luxc/source/luxc/lang/translation/python/runtime.jvm.lux') 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 -- cgit v1.2.3