diff options
Diffstat (limited to 'new-luxc/source/luxc/lang/translation/r/case.jvm.lux')
-rw-r--r-- | new-luxc/source/luxc/lang/translation/r/case.jvm.lux | 29 |
1 files changed, 18 insertions, 11 deletions
diff --git a/new-luxc/source/luxc/lang/translation/r/case.jvm.lux b/new-luxc/source/luxc/lang/translation/r/case.jvm.lux index 67de862e8..6ceae3842 100644 --- a/new-luxc/source/luxc/lang/translation/r/case.jvm.lux +++ b/new-luxc/source/luxc/lang/translation/r/case.jvm.lux @@ -25,9 +25,10 @@ [valueO (translate valueS) bodyO (translate bodyS) #let [$register (referenceT.variable register)]] - (wrap ($_ r.then - (r.set! $register valueO) - bodyO)))) + (wrap (r.block + ($_ r.then + (r.set! $register valueO) + bodyO))))) (def: #export (translate-record-get translate valueS pathP) (-> (-> Synthesis (Meta Expression)) Synthesis (List [Nat Bool]) @@ -73,7 +74,7 @@ (def: cursor-top Expression - (top (@@ $cursor))) + (|> (@@ $cursor) (r.nth (top (@@ $cursor))))) (def: pop-cursor! Expression @@ -115,13 +116,18 @@ [_ (<tag> value)] (meta/wrap (r.when (r.not (r.= (|> value <format>) cursor-top)) fail-pm!))) - ([#.Nat (<| runtimeT.int (:! Int))] - [#.Int runtimeT.int] - [#.Deg (<| runtimeT.int (:! Int))] - [#.Bool r.bool] + ([#.Bool r.bool] [#.Frac r.float] [#.Text r.string]) + (^template [<tag> <format>] + [_ (<tag> value)] + (meta/wrap (r.when (r.not (runtimeT.int//= (|> value <format>) cursor-top)) + fail-pm!))) + ([#.Nat (<| runtimeT.int (:! Int))] + [#.Int runtimeT.int] + [#.Deg (<| runtimeT.int (:! Int))]) + (^template [<pm> <getter>] (^code (<pm> (~ [_ (#.Nat idx)]))) (meta/wrap (push-cursor! (<getter> cursor-top (r.int (:! Int idx)))))) @@ -183,6 +189,7 @@ (do macro.Monad<Meta> [valueO (translate valueS) pattern-matching! (translate-pattern-matching translate pathP)] - (wrap ($_ r.then - (initialize-pattern-matching! valueO) - pattern-matching!)))) + (wrap (r.block + ($_ r.then + (initialize-pattern-matching! valueO) + pattern-matching!))))) |