From 8eb86ed366b2305751f2e831c7a081ffcca82c89 Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Wed, 30 Mar 2022 21:25:53 -0400 Subject: De-sigil-ification: / --- stdlib/source/unsafe/lux/data/binary.lux | 96 ++++++++++++++++---------------- 1 file changed, 48 insertions(+), 48 deletions(-) (limited to 'stdlib/source/unsafe') diff --git a/stdlib/source/unsafe/lux/data/binary.lux b/stdlib/source/unsafe/lux/data/binary.lux index 33d217c40..a32d5e4f2 100644 --- a/stdlib/source/unsafe/lux/data/binary.lux +++ b/stdlib/source/unsafe/lux/data/binary.lux @@ -124,7 +124,7 @@ (.|> (.as .I64) ("lux i64 and" ))] - (template: .public (bytes/1 index it) + (template: .public (bits_8 index it) [(.<| (.as .I64) (.is (.I64 .Any)) (`` (.for (~~ (.static @.old)) (~~ ) @@ -150,40 +150,40 @@ (.i64 0) (array.item )))))])) -(template: .public (bytes/2 index' it') +(template: .public (bits_16 index' it') [(.<| (.let [index (.is Nat index') it (.is ..Binary it')]) (.as .I64) (.is (.I64 .Any)) (.$_ "lux i64 or" - ("lux i64 left-shift" 8 (..bytes/1 index it)) - (..bytes/1 ("lux i64 +" 1 index) it)))]) + ("lux i64 left-shift" 8 (..bits_8 index it)) + (..bits_8 ("lux i64 +" 1 index) it)))]) -(template: .public (bytes/4 index' it') +(template: .public (bits_32 index' it') [(.<| (.let [index (.is Nat index') it (.is ..Binary it')]) (.as .I64) (.is (.I64 .Any)) (.$_ "lux i64 or" - ("lux i64 left-shift" 24 (..bytes/1 index it)) - ("lux i64 left-shift" 16 (..bytes/1 ("lux i64 +" 1 index) it)) - ("lux i64 left-shift" 8 (..bytes/1 ("lux i64 +" 2 index) it)) - (..bytes/1 ("lux i64 +" 3 index) it)))]) + ("lux i64 left-shift" 24 (..bits_8 index it)) + ("lux i64 left-shift" 16 (..bits_8 ("lux i64 +" 1 index) it)) + ("lux i64 left-shift" 8 (..bits_8 ("lux i64 +" 2 index) it)) + (..bits_8 ("lux i64 +" 3 index) it)))]) -(template: .public (bytes/8 index' it') +(template: .public (bits_64 index' it') [(.<| (.let [index (.is Nat index') it (.is ..Binary it')]) (.as .I64) (.is (.I64 .Any)) (.$_ "lux i64 or" - ("lux i64 left-shift" 56 (..bytes/1 index it)) - ("lux i64 left-shift" 48 (..bytes/1 ("lux i64 +" 1 index) it)) - ("lux i64 left-shift" 40 (..bytes/1 ("lux i64 +" 2 index) it)) - ("lux i64 left-shift" 32 (..bytes/1 ("lux i64 +" 3 index) it)) - ("lux i64 left-shift" 24 (..bytes/1 ("lux i64 +" 4 index) it)) - ("lux i64 left-shift" 16 (..bytes/1 ("lux i64 +" 5 index) it)) - ("lux i64 left-shift" 8 (..bytes/1 ("lux i64 +" 6 index) it)) - (..bytes/1 ("lux i64 +" 7 index) it)))]) + ("lux i64 left-shift" 56 (..bits_8 index it)) + ("lux i64 left-shift" 48 (..bits_8 ("lux i64 +" 1 index) it)) + ("lux i64 left-shift" 40 (..bits_8 ("lux i64 +" 2 index) it)) + ("lux i64 left-shift" 32 (..bits_8 ("lux i64 +" 3 index) it)) + ("lux i64 left-shift" 24 (..bits_8 ("lux i64 +" 4 index) it)) + ("lux i64 left-shift" 16 (..bits_8 ("lux i64 +" 5 index) it)) + ("lux i64 left-shift" 8 (..bits_8 ("lux i64 +" 6 index) it)) + (..bits_8 ("lux i64 +" 7 index) it)))]) (with_expansions [ (hex "FF") (.is ..Binary it) @@ -198,7 +198,7 @@ (ffi.long_to_byte ) (ffi.write! )] - (`` (template: .public (has/1! index value it) + (`` (template: .public (has_8! index value it) [(.is ..Binary (.for (~~ (.static @.old)) (~~ (.static @.jvm)) @@ -230,47 +230,47 @@ ... Default (array.has! (.|> .int ("lux i64 and" (.int ))) )))]))) -(template: .public (has/2! index' value' it) +(template: .public (has_16! index' value' it) [(.let [index (.is .Nat index') value (.is (.I64 .Any) value')] (.|> it - (..has/1! index ("lux i64 right-shift" 8 value)) - (..has/1! ("lux i64 +" 1 index) value)))]) + (..has_8! index ("lux i64 right-shift" 8 value)) + (..has_8! ("lux i64 +" 1 index) value)))]) -(template: .public (has/4! index' value' it) +(template: .public (has_32! index' value' it) [(.let [index (.is .Nat index') value (.is (.I64 .Any) value')] (.|> it - (..has/1! index ("lux i64 right-shift" 24 value)) - (..has/1! ("lux i64 +" 1 index) ("lux i64 right-shift" 16 value)) - (..has/1! ("lux i64 +" 2 index) ("lux i64 right-shift" 8 value)) - (..has/1! ("lux i64 +" 3 index) value)))]) + (..has_8! index ("lux i64 right-shift" 24 value)) + (..has_8! ("lux i64 +" 1 index) ("lux i64 right-shift" 16 value)) + (..has_8! ("lux i64 +" 2 index) ("lux i64 right-shift" 8 value)) + (..has_8! ("lux i64 +" 3 index) value)))]) -(`` (template: .public (has/8! index' value' it) +(`` (template: .public (has_64! index' value' it) [(.let [index (.is .Nat index') value (.is (.I64 .Any) value')] (.for (~~ (.static @.scheme)) (.let [write_high (.is (.-> ..Binary ..Binary) - (.|>> (..has/1! index ("lux i64 right-shift" 56 value)) - (..has/1! ("lux i64 +" 1 index) ("lux i64 right-shift" 48 value)) - (..has/1! ("lux i64 +" 2 index) ("lux i64 right-shift" 40 value)) - (..has/1! ("lux i64 +" 3 index) ("lux i64 right-shift" 32 value)))) + (.|>> (..has_8! index ("lux i64 right-shift" 56 value)) + (..has_8! ("lux i64 +" 1 index) ("lux i64 right-shift" 48 value)) + (..has_8! ("lux i64 +" 2 index) ("lux i64 right-shift" 40 value)) + (..has_8! ("lux i64 +" 3 index) ("lux i64 right-shift" 32 value)))) write_low (.is (.-> ..Binary ..Binary) - (.|>> (..has/1! ("lux i64 +" 4 index) ("lux i64 right-shift" 24 value)) - (..has/1! ("lux i64 +" 5 index) ("lux i64 right-shift" 16 value)) - (..has/1! ("lux i64 +" 6 index) ("lux i64 right-shift" 8 value)) - (..has/1! ("lux i64 +" 7 index) value)))] + (.|>> (..has_8! ("lux i64 +" 4 index) ("lux i64 right-shift" 24 value)) + (..has_8! ("lux i64 +" 5 index) ("lux i64 right-shift" 16 value)) + (..has_8! ("lux i64 +" 6 index) ("lux i64 right-shift" 8 value)) + (..has_8! ("lux i64 +" 7 index) value)))] (.|> it write_high write_low)) (.|> it - (..has/1! index ("lux i64 right-shift" 56 value)) - (..has/1! ("lux i64 +" 1 index) ("lux i64 right-shift" 48 value)) - (..has/1! ("lux i64 +" 2 index) ("lux i64 right-shift" 40 value)) - (..has/1! ("lux i64 +" 3 index) ("lux i64 right-shift" 32 value)) - (..has/1! ("lux i64 +" 4 index) ("lux i64 right-shift" 24 value)) - (..has/1! ("lux i64 +" 5 index) ("lux i64 right-shift" 16 value)) - (..has/1! ("lux i64 +" 6 index) ("lux i64 right-shift" 8 value)) - (..has/1! ("lux i64 +" 7 index) value))))])) + (..has_8! index ("lux i64 right-shift" 56 value)) + (..has_8! ("lux i64 +" 1 index) ("lux i64 right-shift" 48 value)) + (..has_8! ("lux i64 +" 2 index) ("lux i64 right-shift" 40 value)) + (..has_8! ("lux i64 +" 3 index) ("lux i64 right-shift" 32 value)) + (..has_8! ("lux i64 +" 4 index) ("lux i64 right-shift" 24 value)) + (..has_8! ("lux i64 +" 5 index) ("lux i64 right-shift" 16 value)) + (..has_8! ("lux i64 +" 6 index) ("lux i64 right-shift" 8 value)) + (..has_8! ("lux i64 +" 7 index) value))))])) (with_expansions [ (.is ..Binary reference') (.is ..Binary sample') @@ -287,8 +287,8 @@ (.if ("lux i64 =" limit index) .true (.and ("lux i64 =" - (..bytes/1 index reference) - (..bytes/1 index sample)) + (..bits_8 index reference) + (..bits_8 index sample)) (again ("lux i64 +" 1 index))))))))]))) ... TODO: Turn into a template ASAP. @@ -307,8 +307,8 @@ (.loop (again [index 0]) (.if ("lux i64 <" (.int bytes) (.int index)) (.exec - (..has/1! ("lux i64 +" target_offset index) - (..bytes/1 ("lux i64 +" source_offset index) source) + (..has_8! ("lux i64 +" target_offset index) + (..bits_8 ("lux i64 +" source_offset index) source) target) (again ("lux i64 +" 1 index))) target)))))) -- cgit v1.2.3