diff options
Diffstat (limited to 'lux-lua')
-rw-r--r-- | lux-lua/source/program.lux | 246 |
1 files changed, 123 insertions, 123 deletions
diff --git a/lux-lua/source/program.lux b/lux-lua/source/program.lux index 445357774..f644f6189 100644 --- a/lux-lua/source/program.lux +++ b/lux-lua/source/program.lux @@ -177,7 +177,7 @@ unwrapped))] (ffi.object [] net/sandius/rembulan/impl/DefaultTable [program/StructureValue] [] - ## Methods + ... Methods (program/StructureValue [] (getValue self) java/lang/Object (:as (Array java/lang/Object) value)) @@ -312,11 +312,11 @@ [output (net/sandius/rembulan/exec/DirectCallExecutor::call state_context (:as java/lang/Object macro) (|> (array.new 2) - (array.write! 0 ## (:as java/lang/Object inputs) - ## (net/sandius/rembulan/impl/ImmutableTable$Builder::build (net/sandius/rembulan/impl/ImmutableTable$Builder::new)) + (array.write! 0 ... (:as java/lang/Object inputs) + ... (net/sandius/rembulan/impl/ImmutableTable$Builder::build (net/sandius/rembulan/impl/ImmutableTable$Builder::new)) (:as java/lang/Object (lux_structure (:as (Array java/lang/Object) inputs)))) - (array.write! 1 ## (:as java/lang/Object lux) - ## (net/sandius/rembulan/impl/ImmutableTable$Builder::build (net/sandius/rembulan/impl/ImmutableTable$Builder::new)) + (array.write! 1 ... (:as java/lang/Object lux) + ... (net/sandius/rembulan/impl/ImmutableTable$Builder::build (net/sandius/rembulan/impl/ImmutableTable$Builder::new)) (:as java/lang/Object (lux_structure (:as (Array java/lang/Object) lux))))) executor)] (|> output (array.read 0) maybe.assume (:as java/lang/Object) ..read))) @@ -379,24 +379,24 @@ (_.concat (_.string " to char (out of range)"))) (_.int +2)))) (<| (_.if (_.< (!int "80") $v) - ## Single-byte sequence + ... Single-byte sequence (_.statement (|> (_.var "string.char") (_.apply/* (list $v)) (table/insert $buffer)))) (_.if (_.< (!int "800") $v) - ## Two-byte sequence + ... Two-byte sequence (_.statement (|> (_.var "string.char") (_.apply/* (list (!&|< "C0" "1F" +6 $v) (!&| "80" "3F" $v))) (table/insert $buffer)))) (_.if (_.< (!int "10000") $v) - ## Three-byte sequence + ... Three-byte sequence (_.statement (|> (_.var "string.char") (_.apply/* (list (!&|< "E0" "0F" +12 $v) (!&|< "80" "3F" +6 $v) (!&| "80" "3F" $v))) (table/insert $buffer)))) - ## Four-byte sequence + ... Four-byte sequence (_.statement (|> (_.var "string.char") (_.apply/* (list (!&|< "F0" "07" +18 $v) (!&|< "80" "3F" +12 $v) @@ -407,113 +407,113 @@ (_.return (_.apply/2 (_.var "table.concat") $buffer (_.string ""))) )))) - ## (def: rembulan//str_rel_to_abs - ## (let [$string (_.var "string") - ## $args (_.var "args") - ## $k (_.var "k") - ## $v (_.var "v")] - ## (<| (_.local_function $str_rel_to_abs (list $string $var_args)) - ## ($_ _.then - ## (_.local/1 $args (_.array (list $var_args))) - ## (<| (_.for_in (list $k $v) (_.ipairs/1 $args)) - ## ($_ _.then - ## (_.if (_.> (_.int +0) $v) - ## (_.set (list $v) $v) - ## (_.set (list $v) (|> $v (_.+ (_.length $string)) (_.+ (_.int +1))))) - ## (_.when (_.or (_.< (_.int +1) $v) - ## (_.> (_.length $string) $v)) - ## (_.statement (_.error/2 (_.string "bad index to string (out of range)") (_.int +3)))) - ## (_.set (list (_.nth $k $args)) $v))) - ## (_.return (_.apply/1 (_.var "table.unpack") $args)) - ## )))) - - ## (def: rembulan//decode - ## (let [$string (_.var "string") - ## $start (_.var "start") - ## $b1 (_.var "b1") - ## $idx (_.var "idx") - ## $bx (_.var "bx") - ## $end (_.var "_end")] - ## (<| (_.local_function $decode (list $string $start)) - ## ($_ _.then - ## (_.set (list $start) (_.apply/2 $str_rel_to_abs $string (_.or (_.int +1) $start))) - ## (_.local/1 $b1 (_.do "byte" (list $start $start) $string)) - ## (<| (_.if (_.< (!int "80") $b1) - ## ## Single-byte sequence - ## (_.return (_.multi (list $start $start)))) - ## ## Validate first byte of multi-byte sequence - ## (_.if (_.or (_.> (!int "F4") $b1) - ## (_.< (!int "C2") $b1)) - ## (_.return _.nil)) - ## ## Get 'supposed' amount of continuation bytes from primary byte - ## ($_ _.then - ## (_.local/1 $end (|> (|> $b1 (_.>= (!int "F0")) (_.and (_.int +3))) - ## (_.or (|> $b1 (_.>= (!int "E0")) (_.and (_.int +2)))) - ## (_.or (|> $b1 (_.>= (!int "C0")) (_.and (_.int +1)))) - ## (_.+ $start))) - ## ## Validate our continuation bytes - ## (<| (_.for_in (list $idx $bx) (_.ipairs/1 (_.array (list (_.do "byte" - ## (list (_.+ (_.int +1) $start) $end) - ## $string))))) - ## (_.when (|> $bx - ## (_.bit_and (!int "C0")) - ## (_.= (!int "80")) - ## _.not) - ## (_.return _.nil))) - ## (_.return (_.multi (list $start $end))) - ## )) - ## )))) - - ## (def: rembulan//codes - ## (let [$string (_.var "string") - ## $i (_.var "i") - ## $start (_.var "start") - ## $end (_.var "_end")] - ## (_.function (_.var "utf8.codes") (list $string) - ## ($_ _.then - ## (_.local/1 $i (_.int +1)) - ## (_.return (<| (_.closure (list)) - ## (_.if (_.> (_.length $string) $i) - ## (_.return _.nil) - ## ($_ _.then - ## (_.let (list $start $end) (_.apply/2 $decode $string $i)) - ## (_.if (_.not $start) - ## (_.statement (_.error/2 (_.string "invalid UTF-8 code") (_.int +2))) - ## ($_ _.then - ## (_.set (list $i) (_.+ (_.int +1) $end)) - ## (_.return (_.multi (list $start (_.do "sub" (list $start $end) $string)))) - ## )) - ## )))) - ## )))) - - ## (def: rembulan//len - ## (let [$string (_.var "string") - ## $start (_.var "start") - ## $end (_.var "_end") - ## $seq_start (_.var "seq_start") - ## $seq_end (_.var "seq_end") - ## $size (_.var "size")] - ## (_.function (_.var "utf8.len") (list $string $start $end) - ## ($_ _.then - ## (_.set (list $start $end) (_.apply/3 $str_rel_to_abs $string (_.or (_.int +1) $start) (_.or (_.int -1) $end))) - ## (_.local/1 $size (_.int +0)) - ## (_.repeat (_.>= $end $seq_end) - ## ($_ _.then - ## (_.let (list $seq_start $seq_end) (_.apply/2 $decode $string $start)) - ## (_.if (_.not $seq_start) - ## ## Hit an invalid sequence! - ## (_.return (_.multi (list (_.bool false) $start))) - ## ($_ _.then - ## (_.set (list $start) (_.+ (_.int +1) $seq_end)) - ## (_.set (list $size) (_.+ (_.int +1) $size)) - ## )) - ## )) - ## (_.return $size) - ## )))) + ... (def: rembulan//str_rel_to_abs + ... (let [$string (_.var "string") + ... $args (_.var "args") + ... $k (_.var "k") + ... $v (_.var "v")] + ... (<| (_.local_function $str_rel_to_abs (list $string $var_args)) + ... ($_ _.then + ... (_.local/1 $args (_.array (list $var_args))) + ... (<| (_.for_in (list $k $v) (_.ipairs/1 $args)) + ... ($_ _.then + ... (_.if (_.> (_.int +0) $v) + ... (_.set (list $v) $v) + ... (_.set (list $v) (|> $v (_.+ (_.length $string)) (_.+ (_.int +1))))) + ... (_.when (_.or (_.< (_.int +1) $v) + ... (_.> (_.length $string) $v)) + ... (_.statement (_.error/2 (_.string "bad index to string (out of range)") (_.int +3)))) + ... (_.set (list (_.nth $k $args)) $v))) + ... (_.return (_.apply/1 (_.var "table.unpack") $args)) + ... )))) + + ... (def: rembulan//decode + ... (let [$string (_.var "string") + ... $start (_.var "start") + ... $b1 (_.var "b1") + ... $idx (_.var "idx") + ... $bx (_.var "bx") + ... $end (_.var "_end")] + ... (<| (_.local_function $decode (list $string $start)) + ... ($_ _.then + ... (_.set (list $start) (_.apply/2 $str_rel_to_abs $string (_.or (_.int +1) $start))) + ... (_.local/1 $b1 (_.do "byte" (list $start $start) $string)) + ... (<| (_.if (_.< (!int "80") $b1) + ... ... Single-byte sequence + ... (_.return (_.multi (list $start $start)))) + ... ... Validate first byte of multi-byte sequence + ... (_.if (_.or (_.> (!int "F4") $b1) + ... (_.< (!int "C2") $b1)) + ... (_.return _.nil)) + ... ... Get 'supposed' amount of continuation bytes from primary byte + ... ($_ _.then + ... (_.local/1 $end (|> (|> $b1 (_.>= (!int "F0")) (_.and (_.int +3))) + ... (_.or (|> $b1 (_.>= (!int "E0")) (_.and (_.int +2)))) + ... (_.or (|> $b1 (_.>= (!int "C0")) (_.and (_.int +1)))) + ... (_.+ $start))) + ... ... Validate our continuation bytes + ... (<| (_.for_in (list $idx $bx) (_.ipairs/1 (_.array (list (_.do "byte" + ... (list (_.+ (_.int +1) $start) $end) + ... $string))))) + ... (_.when (|> $bx + ... (_.bit_and (!int "C0")) + ... (_.= (!int "80")) + ... _.not) + ... (_.return _.nil))) + ... (_.return (_.multi (list $start $end))) + ... )) + ... )))) + + ... (def: rembulan//codes + ... (let [$string (_.var "string") + ... $i (_.var "i") + ... $start (_.var "start") + ... $end (_.var "_end")] + ... (_.function (_.var "utf8.codes") (list $string) + ... ($_ _.then + ... (_.local/1 $i (_.int +1)) + ... (_.return (<| (_.closure (list)) + ... (_.if (_.> (_.length $string) $i) + ... (_.return _.nil) + ... ($_ _.then + ... (_.let (list $start $end) (_.apply/2 $decode $string $i)) + ... (_.if (_.not $start) + ... (_.statement (_.error/2 (_.string "invalid UTF-8 code") (_.int +2))) + ... ($_ _.then + ... (_.set (list $i) (_.+ (_.int +1) $end)) + ... (_.return (_.multi (list $start (_.do "sub" (list $start $end) $string)))) + ... )) + ... )))) + ... )))) + + ... (def: rembulan//len + ... (let [$string (_.var "string") + ... $start (_.var "start") + ... $end (_.var "_end") + ... $seq_start (_.var "seq_start") + ... $seq_end (_.var "seq_end") + ... $size (_.var "size")] + ... (_.function (_.var "utf8.len") (list $string $start $end) + ... ($_ _.then + ... (_.set (list $start $end) (_.apply/3 $str_rel_to_abs $string (_.or (_.int +1) $start) (_.or (_.int -1) $end))) + ... (_.local/1 $size (_.int +0)) + ... (_.repeat (_.>= $end $seq_end) + ... ($_ _.then + ... (_.let (list $seq_start $seq_end) (_.apply/2 $decode $string $start)) + ... (_.if (_.not $seq_start) + ... ... Hit an invalid sequence! + ... (_.return (_.multi (list (_.bool false) $start))) + ... ($_ _.then + ... (_.set (list $start) (_.+ (_.int +1) $seq_end)) + ... (_.set (list $size) (_.+ (_.int +1) $size)) + ... )) + ... )) + ... (_.return $size) + ... )))) - ## (def: rembulan//charpattern - ## (_.set (list (_.var "utf8.charpattern")) - ## (_.string "[%z\x01-\x7F\xC2-\xF4][\x80-\xBF]*"))) + ... (def: rembulan//charpattern + ... (_.set (list (_.var "utf8.charpattern")) + ... (_.string "[%z\x01-\x7F\xC2-\xF4][\x80-\xBF]*"))) (def: rembulan_prelude _.Statement @@ -521,13 +521,13 @@ (_.function (_.var "os.time") (list) (_.return (_.int +0))) - ## Ported from https://github.com/meepen/Lua-5.1-UTF-8 + ... Ported from https://github.com/meepen/Lua-5.1-UTF-8 ..rembulan//char - ## ..rembulan//str_rel_to_abs - ## ..rembulan//decode - ## ..rembulan//codes - ## ..rembulan//len - ## ..rembulan//charpattern + ... ..rembulan//str_rel_to_abs + ... ..rembulan//decode + ... ..rembulan//codes + ... ..rembulan//len + ... ..rembulan//charpattern ))))) (def: host @@ -643,7 +643,7 @@ java/lang/Object)) (ffi.object [] net/sandius/rembulan/runtime/LuaFunction [] [] - ## Methods + ... Methods (net/sandius/rembulan/runtime/LuaFunction [] (invoke self {% net/sandius/rembulan/runtime/ExecutionContext}) @@ -725,7 +725,7 @@ (def: (extender [state_context executor] phase_wrapper) (-> Baggage (-> platform.Phase_Wrapper Extender)) - ## TODO: Stop relying on coercions ASAP. + ... TODO: Stop relying on coercions ASAP. (<| (:as Extender) (function (@self handler)) (:as Handler) |