From c4bbfea18d995948012f45a6afda7a6e6ba56f84 Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Tue, 24 Nov 2020 05:18:04 -0400 Subject: Better error messages when re-using a name when making a definition. --- lux-jvm/source/luxc/lang/directive/jvm.lux | 28 +++--- lux-jvm/source/luxc/lang/translation/jvm/case.lux | 102 ++++++++++----------- .../luxc/lang/translation/jvm/extension/host.lux | 22 ++--- .../source/luxc/lang/translation/jvm/primitive.lux | 20 ++-- 4 files changed, 86 insertions(+), 86 deletions(-) (limited to 'lux-jvm') diff --git a/lux-jvm/source/luxc/lang/directive/jvm.lux b/lux-jvm/source/luxc/lang/directive/jvm.lux index 798cf8298..0ec4fb1d5 100644 --- a/lux-jvm/source/luxc/lang/directive/jvm.lux +++ b/lux-jvm/source/luxc/lang/directive/jvm.lux @@ -223,8 +223,8 @@ (-> /.Object Inst) (case instruction (^template [ ] - ( class field-name field-type) - ( class field-name field-type)) + [( class field-name field-type) + ( class field-name field-type)]) ([#/.GETSTATIC _.GETSTATIC] [#/.PUTSTATIC _.PUTSTATIC] [#/.GETFIELD _.GETFIELD] @@ -236,8 +236,8 @@ (#/.CHECKCAST type) (_.CHECKCAST type) (^template [ ] - ( class method-name method-type) - ( class method-name method-type)) + [( class method-name method-type) + ( class method-name method-type)]) ([#/.INVOKEINTERFACE _.INVOKEINTERFACE] [#/.INVOKESPECIAL _.INVOKESPECIAL] [#/.INVOKESTATIC _.INVOKESTATIC] @@ -402,9 +402,9 @@ (Re-labeler /.Branching) (case instruction (^template [] - ( label) - (let [[mapping label] (..relabel [mapping label])] - [mapping ( label)])) + [( label) + (let [[mapping label] (..relabel [mapping label])] + [mapping ( label)])]) ([#/.IF_ICMPEQ] [#/.IF_ICMPGE] [#/.IF_ICMPGT] [#/.IF_ICMPLE] [#/.IF_ICMPLT] [#/.IF_ICMPNE] [#/.IFEQ] [#/.IFNE] [#/.IFGE] [#/.IFGT] [#/.IFLE] [#/.IFLT] @@ -444,16 +444,16 @@ (Re-labeler /.Control) (case instruction (^template [ ] - ( instruction) - (let [[mapping instruction] ( [mapping instruction])] - [mapping ( instruction)])) + [( instruction) + (let [[mapping instruction] ( [mapping instruction])] + [mapping ( instruction)])]) ([#/.GOTO ..relabel] [#/.Branching ..relabel-branching] [#/.Exception ..relabel-exception]) (^template [] - ( instruction) - [mapping ( instruction)]) + [( instruction) + [mapping ( instruction)]]) ([#/.Concurrency] [#/.Return]) )) @@ -463,8 +463,8 @@ #/.NOP [mapping #/.NOP] (^template [] - ( instruction) - [mapping ( instruction)]) + [( instruction) + [mapping ( instruction)]]) ([#/.Constant] [#/.Arithmetic] [#/.Bitwise] diff --git a/lux-jvm/source/luxc/lang/translation/jvm/case.lux b/lux-jvm/source/luxc/lang/translation/jvm/case.lux index eea77aaf0..68d9b4347 100644 --- a/lux-jvm/source/luxc/lang/translation/jvm/case.lux +++ b/lux-jvm/source/luxc/lang/translation/jvm/case.lux @@ -118,27 +118,27 @@ elseG)))) (^template [ ] - ( cons) - (do {@ phase.monad} - [forkG (: (Operation Inst) - (monad.fold @ (function (_ [test thenP] elseG) - (do @ - [thenG (path' stack-depth @else @end phase archive thenP)] - (wrap (<| _.with-label (function (_ @else)) - (|>> - ( test) - - ( @else) - - thenG - (_.label @else) - elseG))))) - (|>> - (_.GOTO @else)) - (#.Cons cons)))] - (wrap (|>> peekI - - forkG)))) + [( cons) + (do {@ phase.monad} + [forkG (: (Operation Inst) + (monad.fold @ (function (_ [test thenP] elseG) + (do @ + [thenG (path' stack-depth @else @end phase archive thenP)] + (wrap (<| _.with-label (function (_ @else)) + (|>> + ( test) + + ( @else) + + thenG + (_.label @else) + elseG))))) + (|>> + (_.GOTO @else)) + (#.Cons cons)))] + (wrap (|>> peekI + + forkG)))]) ([#synthesis.I64-Fork (_.unwrap type.long) _.DUP2 _.POP2 (|>> .int _.long) _.LCMP _.IFNE] [#synthesis.F64-Fork (_.unwrap type.double) _.DUP2 _.POP2 _.double _.DCMPL _.IFNE] [#synthesis.Text-Fork (|>) _.DUP _.POP _.string @@ -153,41 +153,41 @@ (_.GOTO @end)))) (^template [ ] - (^ ( lefts)) - (operation@wrap (<| _.with-label (function (_ @success)) - _.with-label (function (_ @fail)) - (|>> peekI - (_.CHECKCAST //.$Variant) - (structure.tagI lefts ) - (structure.flagI ) - (_.INVOKESTATIC //.$Runtime "pm_variant" (type.method [(list //.$Variant runtime.$Tag runtime.$Flag) runtime.$Value (list)])) - _.DUP - (_.IFNULL @fail) - (_.GOTO @success) - (_.label @fail) - _.POP - (_.GOTO @else) - (_.label @success) - pushI)))) + [(^ ( lefts)) + (operation@wrap (<| _.with-label (function (_ @success)) + _.with-label (function (_ @fail)) + (|>> peekI + (_.CHECKCAST //.$Variant) + (structure.tagI lefts ) + (structure.flagI ) + (_.INVOKESTATIC //.$Runtime "pm_variant" (type.method [(list //.$Variant runtime.$Tag runtime.$Flag) runtime.$Value (list)])) + _.DUP + (_.IFNULL @fail) + (_.GOTO @success) + (_.label @fail) + _.POP + (_.GOTO @else) + (_.label @success) + pushI)))]) ([synthesis.side/left false] [synthesis.side/right true]) ## Extra optimization (^template [ ] - (^ ( lefts)) - (operation@wrap (|>> peekI - ( lefts) - pushI)) - - (^ (synthesis.path/seq - ( lefts) - (synthesis.!bind-top register thenP))) - (do phase.monad - [then! (path' stack-depth @else @end phase archive thenP)] - (wrap (|>> peekI - ( lefts) - (_.ASTORE register) - then!)))) + [(^ ( lefts)) + (operation@wrap (|>> peekI + ( lefts) + pushI)) + + (^ (synthesis.path/seq + ( lefts) + (synthesis.!bind-top register thenP))) + (do phase.monad + [then! (path' stack-depth @else @end phase archive thenP)] + (wrap (|>> peekI + ( lefts) + (_.ASTORE register) + then!)))]) ([synthesis.member/left ..left-projection] [synthesis.member/right ..right-projection]) 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 26db95ac1..86b814bad 100644 --- a/lux-jvm/source/luxc/lang/translation/jvm/extension/host.lux +++ b/lux-jvm/source/luxc/lang/translation/jvm/extension/host.lux @@ -822,14 +822,14 @@ (synthesis.path/then (normalize bodyS)) (^template [] - (^ ( leftP rightP)) - ( (recur leftP) (recur rightP))) + [(^ ( leftP rightP)) + ( (recur leftP) (recur rightP))]) ([#synthesis.Alt] [#synthesis.Seq]) (^template [] - (^ ( value)) - path) + [(^ ( value)) + path]) ([#synthesis.Pop] [#synthesis.Bind] [#synthesis.Access]) @@ -838,11 +838,11 @@ (#synthesis.Bit-Fork when (recur then) (maybe@map recur else)) (^template [] - ( [[test then] elses]) - ( [[test (recur then)] - (list@map (function (_ [else-test else-then]) - [else-test (recur else-then)]) - elses)])) + [( [[test then] elses]) + ( [[test (recur then)] + (list@map (function (_ [else-test else-then]) + [else-test (recur else-then)]) + elses)])]) ([#synthesis.I64-Fork] [#synthesis.F64-Fork] [#synthesis.Text-Fork]) @@ -853,8 +853,8 @@ (function (recur body) (case body (^template [] - (^ ( value)) - body) + [(^ ( value)) + body]) ([#synthesis.Primitive] [synthesis.constant]) diff --git a/lux-jvm/source/luxc/lang/translation/jvm/primitive.lux b/lux-jvm/source/luxc/lang/translation/jvm/primitive.lux index d8ab2cbee..2e0aba43e 100644 --- a/lux-jvm/source/luxc/lang/translation/jvm/primitive.lux +++ b/lux-jvm/source/luxc/lang/translation/jvm/primitive.lux @@ -34,14 +34,14 @@ (-> (I64 Any) (Operation Inst)) (case (.int value) (^template [ ] - - (operation@wrap (|>> (_.wrap type.long)))) + [ + (operation@wrap (|>> (_.wrap type.long)))]) ([+0 _.LCONST_0] [+1 _.LCONST_1]) (^template [ ] - - (operation@wrap (|>> _.I2L (_.wrap type.long)))) + [ + (operation@wrap (|>> _.I2L (_.wrap type.long)))]) ([-1 _.ICONST_M1] ## [+0 _.ICONST_0] ## [+1 _.ICONST_1] @@ -74,18 +74,18 @@ (-> Frac (Operation Inst)) (case value (^template [ ] - - (operation@wrap (|>> (_.wrap type.double)))) + [ + (operation@wrap (|>> (_.wrap type.double)))]) ([+1.0 _.DCONST_1]) (^template [ ] - - (operation@wrap (|>> _.F2D (_.wrap type.double)))) + [ + (operation@wrap (|>> _.F2D (_.wrap type.double)))]) ([+2.0 _.FCONST_2]) (^template [ ] - - (operation@wrap (|>> _.I2D (_.wrap type.double)))) + [ + (operation@wrap (|>> _.I2D (_.wrap type.double)))]) ([-1.0 _.ICONST_M1] ## [+0.0 _.ICONST_0] ## [+1.0 _.ICONST_1] -- cgit v1.2.3