From feacd79496ae9c76492d5a12d30b78724b642654 Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Tue, 26 Jul 2022 18:08:04 -0400 Subject: Made inlined functions into first-class macros. --- stdlib/source/unsafe/lux/data/binary.lux | 56 +++++++++++++++++--------------- 1 file changed, 29 insertions(+), 27 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 e90aa4b39..d3b824dfb 100644 --- a/stdlib/source/unsafe/lux/data/binary.lux +++ b/stdlib/source/unsafe/lux/data/binary.lux @@ -306,26 +306,27 @@ (again ("lux i64 +" 1 index))))))))])))) ... TODO: Turn into a template ASAP. -(`` (inlined .public (copy! bytes source_offset source target_offset target) - (-> .Nat .Nat ..Binary Nat ..Binary ..Binary) - (with_expansions [ (java/lang/System::arraycopy source (ffi.as_int (.int source_offset)) - target (ffi.as_int (.int target_offset)) - (ffi.as_int (.int bytes))) - (.exec - - target)] - (.for (,, (.static @.old)) - (,, (.static @.jvm)) - - ... Default - (.loop (again [index 0]) - (.if ("lux i64 <" (.int bytes) (.int index)) - (.exec - (..has_8! ("lux i64 +" target_offset index) - (..bits_8 ("lux i64 +" source_offset index) source) - target) - (again ("lux i64 +" 1 index))) - target)))))) +(`` (def .public copy! + (inlined (_ bytes source_offset source target_offset target) + (-> .Nat .Nat ..Binary Nat ..Binary ..Binary) + (with_expansions [ (java/lang/System::arraycopy source (ffi.as_int (.int source_offset)) + target (ffi.as_int (.int target_offset)) + (ffi.as_int (.int bytes))) + (.exec + + target)] + (.for (,, (.static @.old)) + (,, (.static @.jvm)) + + ... Default + (.loop (again [index 0]) + (.if ("lux i64 <" (.int bytes) (.int index)) + (.exec + (..has_8! ("lux i64 +" target_offset index) + (..bits_8 ("lux i64 +" source_offset index) source) + target) + (again ("lux i64 +" 1 index))) + target))))))) ... TODO: Turn into a template ASAP. (`` (with_expansions [ (java/util/Arrays::copyOfRange binary @@ -333,10 +334,11 @@ (ffi.as_int (.int limit))) (.let [limit ("lux i64 +" size offset)] )] - (inlined .public (slice offset size binary) - (-> .Nat .Nat ..Binary ..Binary) - (.for (,, (.static @.old)) - (,, (.static @.jvm)) - - ... Default - (..copy! size offset binary 0 (..empty size)))))) + (def .public slice + (inlined (_ offset size binary) + (-> .Nat .Nat ..Binary ..Binary) + (.for (,, (.static @.old)) + (,, (.static @.jvm)) + + ... Default + (..copy! size offset binary 0 (..empty size))))))) -- cgit v1.2.3