diff options
author | Eduardo Julian | 2018-05-07 21:43:19 -0400 |
---|---|---|
committer | Eduardo Julian | 2018-05-07 21:43:19 -0400 |
commit | 07c70ad15ba4a8c9b00773a0a14eade28fe06569 (patch) | |
tree | 18d6e938cb0a79ecffddd64da1958de47d75ee0f /new-luxc/source/luxc/lang/translation/python/runtime.jvm.lux | |
parent | febfa99c2823219c2e76d2c73b1fd8db8f6c9918 (diff) |
- Implemented bit-count in pure Lux.
Diffstat (limited to '')
-rw-r--r-- | new-luxc/source/luxc/lang/translation/python/runtime.jvm.lux | 31 |
1 files changed, 0 insertions, 31 deletions
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 9bcc46680..a7bd45ff8 100644 --- a/new-luxc/source/luxc/lang/translation/python/runtime.jvm.lux +++ b/new-luxc/source/luxc/lang/translation/python/runtime.jvm.lux @@ -220,23 +220,6 @@ @@product//right @@sum//get)) -(def: full-32-bits (python.code "0xFFFFFFFF")) - -(runtime: (bit//32 input) - (with-vars [capped] - (python.cond! (list [(|> input (python.> full-32-bits)) - (python.return! (|> input (python.bit-and full-32-bits) bit//32))] - [(|> input (python.> (python.code "0x7FFFFFFF"))) - ($_ python.then! - (python.set! (list capped) - (python.apply (list (|> (python.code "0x100000000") - (python.- input))) - (python.global "int"))) - (python.if! (|> (@@ capped) (python.<= (python.int 2147483647))) - (python.return! (|> (@@ capped) (python.* (python.int -1)))) - (python.return! (python.int -2147483648))))]) - (python.return! input)))) - (def: full-64-bits (python.code "0xFFFFFFFFFFFFFFFF")) (runtime: (bit//64 input) @@ -254,18 +237,6 @@ (python.return! (python.code "-9223372036854775808L"))))]) (python.return! input)))) -(runtime: (bit//count subject) - (with-vars [count remaining] - ($_ python.then! - (python.set! (list count) (python.int 0)) - (python.set! (list remaining) subject) - (python.while! (|> (@@ remaining) (python.> (python.int 0))) - ($_ python.then! - (let [last-bit (|> (@@ remaining) (python.% (python.int 2)))] - (python.set! (list count) (|> (@@ count) (python.+ last-bit)))) - (python.set! (list remaining) (|> (@@ remaining) (python./ (python.int 2)))))) - (python.return! (@@ count))))) - (runtime: (bit//logical-right-shift param subject) (let [mask (|> (python.int 1) (python.bit-shl (python.- param (python.int 64))) @@ -277,9 +248,7 @@ (def: runtime//bit Runtime ($_ python.then! - @@bit//32 @@bit//64 - @@bit//count @@bit//logical-right-shift)) (runtime: (frac//decode input) |