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-jvm/source/luxc/lang/translation/jvm.lux | 12 +-- lux-jvm/source/luxc/lang/translation/jvm/case.lux | 20 ++--- .../source/luxc/lang/translation/jvm/common.lux | 40 +++++----- .../luxc/lang/translation/jvm/expression.lux | 2 +- .../luxc/lang/translation/jvm/extension/common.lux | 4 +- .../luxc/lang/translation/jvm/extension/host.lux | 88 +++++++++++----------- .../source/luxc/lang/translation/jvm/function.lux | 4 +- .../source/luxc/lang/translation/jvm/reference.lux | 4 +- 8 files changed, 87 insertions(+), 87 deletions(-) (limited to 'lux-jvm/source/luxc/lang/translation') diff --git a/lux-jvm/source/luxc/lang/translation/jvm.lux b/lux-jvm/source/luxc/lang/translation/jvm.lux index db7b5b3fa..6a641f0ee 100644 --- a/lux-jvm/source/luxc/lang/translation/jvm.lux +++ b/lux-jvm/source/luxc/lang/translation/jvm.lux @@ -83,20 +83,20 @@ (def: (class_value class_name class) (-> Text (java/lang/Class java/lang/Object) (Try Any)) (case (java/lang/Class::getField ..value_field class) - (#try.Success field) + {#try.Success field} (case (java/lang/reflect/Field::get #.None field) - (#try.Success ?value) + {#try.Success ?value} (case ?value - (#.Some value) - (#try.Success value) + {#.Some value} + {#try.Success value} #.None (exception.except ..invalid_value class_name)) - (#try.Failure error) + {#try.Failure error} (exception.except ..cannot_load [class_name error])) - (#try.Failure error) + {#try.Failure error} (exception.except ..invalid_field [class_name ..value_field error]))) (def: class_path_separator ".") diff --git a/lux-jvm/source/luxc/lang/translation/jvm/case.lux b/lux-jvm/source/luxc/lang/translation/jvm/case.lux index a6d0a725f..0959130a3 100644 --- a/lux-jvm/source/luxc/lang/translation/jvm/case.lux +++ b/lux-jvm/source/luxc/lang/translation/jvm/case.lux @@ -106,15 +106,15 @@ #synthesis.Pop (operation@in ..popI) - (#synthesis.Bind register) + {#synthesis.Bind register} (operation@in (|>> peekI (_.ASTORE register))) - (#synthesis.Bit_Fork when thenP elseP) + {#synthesis.Bit_Fork when thenP elseP} (do phase.monad [thenG (path' stack_depth @else @end phase archive thenP) elseG (.case elseP - (#.Some elseP) + {#.Some elseP} (path' stack_depth @else @end phase archive elseP) #.None @@ -129,7 +129,7 @@ elseG)))) (^template [ ] - [( cons) + [{ cons} (do [@ phase.monad] [forkG (: (Operation Inst) (monad.mix @ (function (_ [test thenP] elseG) @@ -146,7 +146,7 @@ elseG))))) (|>> (_.GOTO @else)) - (#.Item cons)))] + {#.Item cons}))] (in (|>> peekI forkG)))]) @@ -156,7 +156,7 @@ (_.INVOKEVIRTUAL (type.class "java.lang.Object" (list)) "equals" ..equalsJT) _.IFEQ]) - (#synthesis.Then bodyS) + {#synthesis.Then bodyS} (do phase.monad [bodyI (phase archive bodyS)] (in (|>> (pop_altI stack_depth) @@ -202,14 +202,14 @@ ([synthesis.member/left ..left_projection] [synthesis.member/right ..right_projection]) - (#synthesis.Seq leftP rightP) + {#synthesis.Seq leftP rightP} (do phase.monad [leftI (path' stack_depth @else @end phase archive leftP) rightI (path' stack_depth @else @end phase archive rightP)] (in (|>> leftI rightI))) - (#synthesis.Alt leftP rightP) + {#synthesis.Alt leftP rightP} (do phase.monad [@alt_else _.make_label leftI (path' (++ stack_depth) @alt_else @end phase archive leftP) @@ -268,10 +268,10 @@ [recordG (phase archive recordS)] (in (list@mix (function (_ step so_far) (.let [next (.case step - (#.Left lefts) + {#.Left lefts} (..left_projection lefts) - (#.Right lefts) + {#.Right lefts} (..right_projection lefts))] (|>> so_far next))) recordG diff --git a/lux-jvm/source/luxc/lang/translation/jvm/common.lux b/lux-jvm/source/luxc/lang/translation/jvm/common.lux index 8db12bd7e..2dade7a97 100644 --- a/lux-jvm/source/luxc/lang/translation/jvm/common.lux +++ b/lux-jvm/source/luxc/lang/translation/jvm/common.lux @@ -32,21 +32,21 @@ ... (All (_ a) (-> (Meta a) (Meta [Artifacts a]))) ... (function (_ state) ... (case (action (revised@ #.host -... (|>> (:coerce Host) -... (with@ #artifacts (dictionary.new text.hash)) -... (:coerce Nothing)) -... state)) -... (#try.Success [state' output]) -... (#try.Success [(revised@ #.host -... (|>> (:coerce Host) -... (with@ #artifacts (|> (value@ #.host state) (:coerce Host) (value@ #artifacts))) -... (:coerce Nothing)) -... state') -... [(|> state' (value@ #.host) (:coerce Host) (value@ #artifacts)) -... output]]) +... (|>> (:coerce Host) +... (with@ #artifacts (dictionary.new text.hash)) +... (:coerce Nothing)) +... state)) +... {#try.Success [state' output]} +... {#try.Success [(revised@ #.host +... (|>> (:coerce Host) +... (with@ #artifacts (|> (value@ #.host state) (:coerce Host) (value@ #artifacts))) +... (:coerce Nothing)) +... state') +... [(|> state' (value@ #.host) (:coerce Host) (value@ #artifacts)) +... output]]} -... (#try.Failure error) -... (#try.Failure error)))) +... {#try.Failure error} +... {#try.Failure error}))) ... (def: .public (load-definition state) ... (-> Lux (-> Name Binary (Try Any))) @@ -60,14 +60,14 @@ ... (case (do try.monad ... [field (Class::getField [..value-field] class)] ... (Field::get [#.None] field)) -... (#try.Success (#.Some def-value)) +... {#try.Success {#.Some def-value}} ... (wrap def-value) -... (#try.Success #.None) +... {#try.Success #.None} ... (phase.throw invalid-definition-value (%name def-name)) -... (#try.Failure error) +... {#try.Failure error} ... (phase.throw cannot-load-definition -... (format "Definition: " (%name def-name) "\n" -... "Error:\n" -... error)))))))) +... (format "Definition: " (%name def-name) "\n" +... "Error:\n" +... error)))))))) diff --git a/lux-jvm/source/luxc/lang/translation/jvm/expression.lux b/lux-jvm/source/luxc/lang/translation/jvm/expression.lux index 087ebfaff..a460ad96b 100644 --- a/lux-jvm/source/luxc/lang/translation/jvm/expression.lux +++ b/lux-jvm/source/luxc/lang/translation/jvm/expression.lux @@ -72,5 +72,5 @@ (^ (synthesis.function/abstraction data)) (function.function translate archive data) - (#synthesis.Extension extension) + {#synthesis.Extension extension} (extension.apply archive translate extension))) diff --git a/lux-jvm/source/luxc/lang/translation/jvm/extension/common.lux b/lux-jvm/source/luxc/lang/translation/jvm/extension/common.lux index e3ac4141b..8d92a68eb 100644 --- a/lux-jvm/source/luxc/lang/translation/jvm/extension/common.lux +++ b/lux-jvm/source/luxc/lang/translation/jvm/extension/common.lux @@ -48,10 +48,10 @@ Handler)) (function (_ extension_name phase archive input) (case (.result parser input) - (#try.Success input') + {#try.Success input'} (handler extension_name phase archive input') - (#try.Failure error) + {#try.Failure error} (phase.except extension.invalid_syntax [extension_name %synthesis input])))) (import: java/lang/Double diff --git a/lux-jvm/source/luxc/lang/translation/jvm/extension/host.lux b/lux-jvm/source/luxc/lang/translation/jvm/extension/host.lux index 131ff0968..8535c3b35 100644 --- a/lux-jvm/source/luxc/lang/translation/jvm/extension/host.lux +++ b/lux-jvm/source/luxc/lang/translation/jvm/extension/host.lux @@ -96,9 +96,9 @@ (do <>.monad [arrayJT (.then parser.array .text)] (case (parser.array? arrayJT) - (#.Some elementJT) + {#.Some elementJT} (case (parser.object? elementJT) - (#.Some elementJT) + {#.Some elementJT} (in elementJT) #.None @@ -629,7 +629,7 @@ (do phase.monad [] (case (dictionary.value unboxed ..primitives) - (#.Some primitive) + {#.Some primitive} (in (_.GETSTATIC (type.class class (list)) field primitive)) #.None @@ -644,7 +644,7 @@ [valueI (generate archive valueS) .let [$class (type.class class (list))]] (case (dictionary.value unboxed ..primitives) - (#.Some primitive) + {#.Some primitive} (in (|>> valueI (_.PUTSTATIC $class field primitive) (_.string synthesis.unit))) @@ -664,7 +664,7 @@ [objectI (generate archive objectS) .let [$class (type.class class (list)) getI (case (dictionary.value unboxed ..primitives) - (#.Some primitive) + {#.Some primitive} (_.GETFIELD $class field primitive) #.None @@ -683,7 +683,7 @@ objectI (generate archive objectS) .let [$class (type.class class (list)) putI (case (dictionary.value unboxed ..primitives) - (#.Some primitive) + {#.Some primitive} (_.PUTFIELD $class field primitive) #.None @@ -709,10 +709,10 @@ (do phase.monad [valueI (generate archive valueS)] (case (type.primitive? valueT) - (#.Right valueT) + {#.Right valueT} (in [valueT valueI]) - (#.Left valueT) + {#.Left valueT} (in [valueT (|>> valueI (_.CHECKCAST valueT))])))) @@ -722,10 +722,10 @@ (def: (prepare_output outputT) (-> (Type Return) Inst) (case (type.void? outputT) - (#.Right outputT) + {#.Right outputT} ..voidI - (#.Left outputT) + {#.Left outputT} function.identity)) (def: invoke::static @@ -814,26 +814,26 @@ [0 _] body [1 _] body - [2 (#synthesis.Control (#synthesis.Branch (#synthesis.Let _ 2 hidden)))] + [2 {#synthesis.Control {#synthesis.Branch {#synthesis.Let _ 2 hidden}}}] hidden - [_ (#synthesis.Control (#synthesis.Branch (#synthesis.Case _ path)))] + [_ {#synthesis.Control {#synthesis.Branch {#synthesis.Case _ path}}}] (loop [path path] (case path (^or #synthesis.Pop - (#synthesis.Access _) - (#synthesis.Bind _) - (#synthesis.Bit_Fork _) - (#synthesis.I64_Fork _) - (#synthesis.F64_Fork _) - (#synthesis.Text_Fork _) - (#synthesis.Alt _)) + {#synthesis.Access _} + {#synthesis.Bind _} + {#synthesis.Bit_Fork _} + {#synthesis.I64_Fork _} + {#synthesis.F64_Fork _} + {#synthesis.Text_Fork _} + {#synthesis.Alt _}) body - (#synthesis.Seq _ next) + {#synthesis.Seq _ next} (recur next) - (#synthesis.Then hidden) + {#synthesis.Then hidden} hidden)) _ @@ -873,27 +873,27 @@ (synthesis.path/then (normalize bodyS)) (^template [] - [(^ ( leftP rightP)) - ( (recur leftP) (recur rightP))]) + [(^ { leftP rightP}) + { (recur leftP) (recur rightP)}]) ([#synthesis.Alt] [#synthesis.Seq]) (^template [] - [(^ ( value)) + [(^ { value}) path]) ([#synthesis.Pop] [#synthesis.Bind] [#synthesis.Access]) - (#synthesis.Bit_Fork when then else) - (#synthesis.Bit_Fork when (recur then) (maybe\each recur else)) + {#synthesis.Bit_Fork when then else} + {#synthesis.Bit_Fork when (recur then) (maybe\each recur else)} (^template [] - [( [[test then] elses]) - ( [[test (recur then)] + [{ [[test then] elses]} + { [[test (recur then)] (list\each (function (_ [else_test else_then]) [else_test (recur else_then)]) - elses)])]) + elses)]}]) ([#synthesis.I64_Fork] [#synthesis.F64_Fork] [#synthesis.Text_Fork]) @@ -903,11 +903,11 @@ (-> (Dictionary Synthesis Variable) Synthesis Synthesis) (function (recur body) (case body - (^template [] - [(^ ( value)) - body]) - ([#synthesis.Primitive] - [synthesis.constant]) + (^ {#synthesis.Primitive value}) + body + + (^ {synthesis.constant value}) + body (^ (synthesis.variant [lefts right? sub])) (synthesis.variant [lefts right? (recur sub)]) @@ -957,8 +957,8 @@ (^ (synthesis.function/apply [functionS inputsS+])) (synthesis.function/apply [(recur functionS) (list\each recur inputsS+)]) - (#synthesis.Extension [name inputsS+]) - (#synthesis.Extension [name (list\each recur inputsS+)])))) + {#synthesis.Extension [name inputsS+]} + {#synthesis.Extension [name (list\each recur inputsS+)]}))) (def: $Object (type.class "java.lang.Object" (list))) @@ -999,14 +999,14 @@ (def: (prepare_argument lux_register argumentT jvm_register) (-> Register (Type Value) Register [Register Inst]) (case (type.primitive? argumentT) - (#.Left argumentT) + {#.Left argumentT} [(n.+ 1 jvm_register) (if (n.= lux_register jvm_register) (|>>) (|>> (_.ALOAD jvm_register) (_.ASTORE lux_register)))] - (#.Right argumentT) + {#.Right argumentT} (template.let [(wrap_primitive ) [[(n.+ jvm_register) (|>> ( jvm_register) @@ -1040,21 +1040,21 @@ (def: .public (returnI returnT) (-> (Type Return) Inst) (case (type.void? returnT) - (#.Right returnT) + {#.Right returnT} _.RETURN - (#.Left returnT) + {#.Left returnT} (case (type.primitive? returnT) - (#.Left returnT) + {#.Left returnT} (case (type.class? returnT) - (#.Some class_name) + {#.Some class_name} (|>> (_.CHECKCAST returnT) _.ARETURN) #.None _.ARETURN) - (#.Right returnT) + {#.Right returnT} (template.let [(unwrap_primitive ) [(|>> (_.unwrap ) )]] @@ -1102,7 +1102,7 @@ ... Give them names as "foreign" variables. list.enumeration (list\each (function (_ [id capture]) - [capture (#variable.Foreign id)])) + [capture {#variable.Foreign id}])) (dictionary.of_list synthesis.hash)) normalized_methods (list\each (function (_ [environment [ownerT name diff --git a/lux-jvm/source/luxc/lang/translation/jvm/function.lux b/lux-jvm/source/luxc/lang/translation/jvm/function.lux index 2a202fbcd..7630191e9 100644 --- a/lux-jvm/source/luxc/lang/translation/jvm/function.lux +++ b/lux-jvm/source/luxc/lang/translation/jvm/function.lux @@ -308,7 +308,7 @@ (do [! phase.monad] [@begin _.make_label [function_context bodyI] (case forced_context - (#.Some function_context) + {#.Some function_context} (do ! [without_context (generation.with_anchor [@begin 1] (generate archive bodyS))] @@ -331,7 +331,7 @@ #.None (generation.save! (product.right function_context) #.None directive) - (#.Some function_context) + {#.Some function_context} (in []))] (in instanceI))) diff --git a/lux-jvm/source/luxc/lang/translation/jvm/reference.lux b/lux-jvm/source/luxc/lang/translation/jvm/reference.lux index 9b0feeb78..3c76f44c0 100644 --- a/lux-jvm/source/luxc/lang/translation/jvm/reference.lux +++ b/lux-jvm/source/luxc/lang/translation/jvm/reference.lux @@ -53,10 +53,10 @@ (def: .public (variable archive variable) (-> Archive Variable (Operation Inst)) (case variable - (#variable.Local variable) + {#variable.Local variable} (operation@in (local variable)) - (#variable.Foreign variable) + {#variable.Foreign variable} (foreign archive variable))) (def: .public (constant archive name) -- cgit v1.2.3