From 07c70ad15ba4a8c9b00773a0a14eade28fe06569 Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Mon, 7 May 2018 21:43:19 -0400 Subject: - Implemented bit-count in pure Lux. --- .../translation/python/procedure/common.jvm.lux | 1 - .../luxc/lang/translation/python/runtime.jvm.lux | 31 ---------------------- 2 files changed, 32 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 0f5a3fdc9..7a907edb0 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 @@ -179,7 +179,6 @@ Bundle (<| (prefix "bit") (|> (dict.new text.Hash) - (install "count" (unary runtimeT.bit//count)) (install "and" (binary bit//and)) (install "or" (binary bit//or)) (install "xor" (binary bit//xor)) 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) -- cgit v1.2.3