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-lua/source/program.lux | 54 +++++++++++++++++++++++----------------------- 1 file changed, 27 insertions(+), 27 deletions(-) (limited to 'lux-lua') diff --git a/lux-lua/source/program.lux b/lux-lua/source/program.lux index 1ff6e2e57..04f566788 100644 --- a/lux-lua/source/program.lux +++ b/lux-lua/source/program.lux @@ -170,7 +170,7 @@ (let [re_wrap (: (-> java/lang/Object java/lang/Object) (function (_ unwrapped) (case (ffi.check [java/lang/Object] unwrapped) - (#.Some sub_value) + {#.Some sub_value} (|> sub_value (:as (Array java/lang/Object)) lux_structure (:as java/lang/Object)) #.None @@ -194,14 +194,14 @@ (net/sandius/rembulan/impl/DefaultTable [] (rawget self [field java/lang/Object]) java/lang/Object (case (ffi.check net/sandius/rembulan/ByteString field) - (#.Some field) + {#.Some field} (case (net/sandius/rembulan/ByteString::decode field) (^ (static runtime.variant_tag_field)) (|> value (array.read! 0) maybe.trusted) (^ (static runtime.variant_flag_field)) (case (array.read! 1 value) - (#.Some _) + {#.Some _} (:as java/lang/Object "") #.None @@ -215,7 +215,7 @@ #.None (case (ffi.check java/lang/Long field) - (#.Some idx) + {#.Some idx} (|> value (array.read! (|> idx (:as Nat) --)) maybe.trusted re_wrap) #.None @@ -230,14 +230,14 @@ (case [(net/sandius/rembulan/Table::get_key (:as java/lang/Object runtime.variant_tag_field) host_object) (net/sandius/rembulan/Table::get_key (:as java/lang/Object runtime.variant_flag_field) host_object) (net/sandius/rembulan/Table::get_key (:as java/lang/Object runtime.variant_value_field) host_object)] - (^multi [(#.Some tag) ?flag (#.Some value)] + (^multi [{#.Some tag} ?flag {#.Some value}] [(read value) - (#try.Success value)]) - (#try.Success [(: Any (|> tag (:as java/lang/Long) java/lang/Long::intValue)) + {#try.Success value}]) + {#try.Success [(: Any (|> tag (:as java/lang/Long) java/lang/Long::intValue)) (: Any (case ?flag - (#.Some _) (: Any "") + {#.Some _} (: Any "") #.None (:as Any (ffi.null)))) - (: Any value)]) + (: Any value)]} _ (exception.except ..unknown_kind_of_object [(:as java/lang/Object host_object)]))) @@ -254,14 +254,14 @@ #.None (recur num_keys (++ idx) output) - (#.Some member) + {#.Some member} (case (read member) - (#try.Success parsed_member) + {#try.Success parsed_member} (recur num_keys (++ idx) (array.write! idx (:as java/lang/Object parsed_member) output)) - (#try.Failure error) - (#try.Failure error))) - (#try.Success output))))) + {#try.Failure error} + {#try.Failure error})) + {#try.Success output})))) (exception: .public nil_has_no_lux_representation) @@ -271,7 +271,7 @@ (exception.except ..nil_has_no_lux_representation [])) (~~ (template [ ] [(case (ffi.check host_object) - (#.Some typed_object) + {#.Some typed_object} (|> typed_object ) _)] @@ -285,12 +285,12 @@ [program/StructureValue (<| #try.Success program/StructureValue::getValue)] )) (case (ffi.check net/sandius/rembulan/impl/DefaultTable host_object) - (#.Some typed_object) + {#.Some typed_object} (case (read_variant read typed_object) - (#try.Success value) - (#try.Success value) + {#try.Success value} + {#try.Success value} - (#try.Failure error) + {#try.Failure error} (read_tuple read typed_object)) _) @@ -327,15 +327,15 @@ (def: (expander baggage macro inputs lux) (-> Baggage Expander) (case (..ensure_function macro) - (#.Some macro) + {#.Some macro} (case (..call_macro baggage inputs lux macro) - (#try.Success output) + {#try.Success output} (|> output (:as (Try [Lux (List Code)])) #try.Success) - (#try.Failure error) - (#try.Failure error)) + {#try.Failure error} + {#try.Failure error}) #.None (exception.except ..cannot_apply_a_non_function (:as java/lang/Object macro)))))] @@ -345,7 +345,7 @@ @.lua (def: (expander macro inputs lux) Expander - (#try.Success ((:as Macro' macro) inputs lux)))])) + {#try.Success ((:as Macro' macro) inputs lux)})])) (with_expansions [ (as_is (with_expansions [$var_args (_.var "...") $str_rel_to_abs (_.var "_utf8_str_rel_to_abs") @@ -555,7 +555,7 @@ #.None (in []) - (#.Some value) + {#.Some value} (read value))))) _ (try.trusted (run! ..rembulan_prelude))] [[state_context executor] @@ -596,9 +596,9 @@ (do try.monad [lua_function (..load (_.code code))] (let [output ("lua apply" lua_function)] - (#try.Success (if ("lua object nil?" output) + {#try.Success (if ("lua object nil?" output) [] - output))))))] + output)}))))] (: (Host _.Expression _.Statement) (implementation (def: (evaluate! context code) -- cgit v1.2.3