diff options
author | Eduardo Julian | 2022-03-30 21:25:53 -0400 |
---|---|---|
committer | Eduardo Julian | 2022-03-30 21:25:53 -0400 |
commit | 8eb86ed366b2305751f2e831c7a081ffcca82c89 (patch) | |
tree | f8da5967f61d115414b3655dd9045cef370c8d5b /stdlib/source/unsafe | |
parent | 4326d69ab717683449bf37bf8dd170c83455c0c0 (diff) |
De-sigil-ification: /
Diffstat (limited to 'stdlib/source/unsafe')
-rw-r--r-- | stdlib/source/unsafe/lux/data/binary.lux | 96 |
1 files changed, 48 insertions, 48 deletions
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 @@ <jvm> (.|> <jvm> (.as .I64) ("lux i64 and" <byte_mask>))] - (template: .public (bytes/1 index it) + (template: .public (bits_8 index it) [(.<| (.as .I64) (.is (.I64 .Any)) (`` (.for (~~ (.static @.old)) (~~ <jvm>) @@ -150,40 +150,40 @@ (.i64 0) (array.item <index> <it>)))))])) -(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 [<byte> (hex "FF") <it> (.is ..Binary it) @@ -198,7 +198,7 @@ <jvm_value> <jvm_value> <jvm_value> (ffi.long_to_byte <jvm_value>) <jvm> (ffi.write! <index> <jvm_value> <it>)] - (`` (template: .public (has/1! index value it) + (`` (template: .public (has_8! index value it) [(.is ..Binary (.for (~~ (.static @.old)) <jvm> (~~ (.static @.jvm)) <jvm> @@ -230,47 +230,47 @@ ... Default (array.has! <index> (.|> <value> .int ("lux i64 and" (.int <byte>))) <it>)))]))) -(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 [<reference> (.is ..Binary reference') <sample> (.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)))))) |