From cd71a864ad5be13ed6ec6d046e0a2cb1087bdf94 Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Fri, 10 Sep 2021 01:21:23 -0400 Subject: Migrated variants to the new syntax. --- lux-scheme/source/program.lux | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) (limited to 'lux-scheme/source') diff --git a/lux-scheme/source/program.lux b/lux-scheme/source/program.lux index ee5b95952..1eac52eeb 100644 --- a/lux-scheme/source/program.lux +++ b/lux-scheme/source/program.lux @@ -134,14 +134,14 @@ (def: (variant? value) (-> Any Bit) (case (ffi.check [java/lang/Object] (:as java/lang/Object value)) - (#.Some array) + {#.Some array} ... TODO: Get rid of this coercion ASAP. (let [array (:as (Array java/lang/Object) array)] (and (n.= 3 (array.size array)) (case (array.read! 0 array) - (#.Some tag) + {#.Some tag} (case (ffi.check java/lang/Integer tag) - (#.Some _) + {#.Some _} true #.None @@ -177,7 +177,7 @@ [] (getCar self []) java/lang/Object (if cdr? (case (array.read! 1 value) - (#.Some flag_is_set) + {#.Some flag_is_set} true #.None @@ -243,7 +243,7 @@ (def: (lux_value value) (-> java/lang/Object java/lang/Object) (<| (case (ffi.check [java/lang/Object] value) - (#.Some value) + {#.Some value} ... TODO: Get rid of the coercions below. (if (variant? value) (variant_value lux_value false (:as (Array java/lang/Object) value)) @@ -269,7 +269,7 @@ [tag (read (gnu/lists/Pair::getCar host_object)) #let [host_object (:as gnu/lists/Pair (gnu/lists/Pair::getCdr host_object)) flag (case (ffi.check java/lang/Boolean (gnu/lists/Pair::getCar host_object)) - (#.Some flag) + {#.Some flag} (:as Bit flag) #.None @@ -285,19 +285,19 @@ (array.new size))] (if (n.< size idx) (case (read (gnu/lists/FVector::getRaw (.int idx) host_object)) - (#try.Failure error) - (#try.Failure error) + {#try.Failure error} + {#try.Failure error} - (#try.Success lux_value) + {#try.Success lux_value} (recur (++ idx) (array.write! idx (: Any lux_value) output))) - (#try.Success output))))) + {#try.Success output})))) (def: (read host_object) (Reader java/lang/Object) (`` (<| (~~ (template [] [(case (ffi.check host_object) - (#.Some host_object) - (#try.Success host_object) + {#.Some host_object} + {#try.Success host_object} #.None)] [java/lang/Boolean] [java/lang/Long] [java/lang/Double] [java/lang/String] @@ -305,8 +305,8 @@ )) (~~ (template [ ] [(case (ffi.check host_object) - (#.Some host_object) - (#try.Success (<| host_object)) + {#.Some host_object} + {#try.Success (<| host_object)} #.None)] [java/lang/Integer java/lang/Integer::longValue] @@ -321,11 +321,11 @@ [program/TupleValue program/TupleValue::getValue] )) (case (ffi.check gnu/lists/Pair host_object) - (#.Some host_object) + {#.Some host_object} (read_variant read host_object) #.None) (case (ffi.check gnu/lists/FVector host_object) - (#.Some host_object) + {#.Some host_object} (read_tuple read (:as (gnu/lists/FVector java/lang/Object) host_object)) #.None) ... else @@ -338,17 +338,17 @@ (def: (expander macro inputs lux) Expander (case (..ensure_macro macro) - (#.Some macro) + {#.Some macro} (case (gnu/mapping/Procedure::apply2 (lux_value (:as java/lang/Object inputs)) (lux_value (:as java/lang/Object lux)) macro) - (#try.Success output) + {#try.Success output} (|> output ..read (:as (Try (Try [Lux (List Code)])))) - (#try.Failure error) - (#try.Failure error)) + {#try.Failure error} + {#try.Failure error}) #.None (exception.throw ..cannot_apply_a_non_function (:as java/lang/Object macro))) -- cgit v1.2.3