diff options
Diffstat (limited to 'new-luxc/source/luxc/lang/translation/js/case.jvm.lux')
-rw-r--r-- | new-luxc/source/luxc/lang/translation/js/case.jvm.lux | 43 |
1 files changed, 22 insertions, 21 deletions
diff --git a/new-luxc/source/luxc/lang/translation/js/case.jvm.lux b/new-luxc/source/luxc/lang/translation/js/case.jvm.lux index cbb0e6c77..7c624c102 100644 --- a/new-luxc/source/luxc/lang/translation/js/case.jvm.lux +++ b/new-luxc/source/luxc/lang/translation/js/case.jvm.lux @@ -6,15 +6,16 @@ (coll [list "list/" Fold<List>])) [macro #+ "meta/" Monad<Meta>]) (luxc [lang] - (lang ["ls" synthesis])) + (lang ["ls" synthesis] + (host [js #+ JS Expression Statement]))) [//] (// [".T" runtime] [".T" primitive] [".T" reference])) (def: #export (translate-let translate register valueS bodyS) - (-> (-> ls.Synthesis (Meta //.Expression)) Nat ls.Synthesis ls.Synthesis - (Meta //.Expression)) + (-> (-> ls.Synthesis (Meta Expression)) Nat ls.Synthesis ls.Synthesis + (Meta Expression)) (do macro.Monad<Meta> [valueJS (translate valueS) bodyJS (translate bodyS)] @@ -24,8 +25,8 @@ "})()")))) (def: #export (translate-record-get translate valueS path) - (-> (-> ls.Synthesis (Meta //.Expression)) ls.Synthesis (List [Nat Bool]) - (Meta //.Expression)) + (-> (-> ls.Synthesis (Meta Expression)) ls.Synthesis (List [Nat Bool]) + (Meta Expression)) (do macro.Monad<Meta> [valueJS (translate valueS)] (wrap (list/fold (function [[idx tail?] source] @@ -35,50 +36,50 @@ path)))) (def: #export (translate-if testJS thenJS elseJS) - (-> //.Expression //.Expression //.Expression - //.Expression) + (-> Expression Expression Expression + Expression) (format "(" testJS " ? " thenJS " : " elseJS ")")) (def: savepoint - //.Expression + Expression "pm_cursor_savepoint") (def: cursor - //.Expression + Expression "pm_cursor") (def: (push-cursor value) - (-> //.Expression //.Expression) + (-> Expression Expression) (format cursor ".push(" value ");")) (def: save-cursor - //.Statement + Statement (format savepoint ".push(" cursor ".slice());")) (def: restore-cursor - //.Statement + Statement (format cursor " = " savepoint ".pop();")) (def: peek-cursor - //.Expression + Expression (format cursor "[" cursor ".length - 1]")) (def: pop-cursor - //.Statement + Statement (format cursor ".pop();")) (def: pm-error - //.Expression + Expression (%t "PM-ERROR")) (def: fail-pattern-matching - //.Statement + Statement (format "throw " pm-error ";")) (exception: #export Unrecognized-Path) (def: (translate-pattern-matching' translate path) - (-> (-> ls.Synthesis (Meta //.Expression)) Code (Meta //.Expression)) + (-> (-> ls.Synthesis (Meta Expression)) Code (Meta Expression)) (case path (^code ("lux case exec" (~ bodyS))) (do macro.Monad<Meta> @@ -154,7 +155,7 @@ )) (def: report-pattern-matching-error - //.Statement + Statement (format "if(ex === " pm-error ") {" "throw \"Invalid expression for pattern-matching.\";" "}" @@ -163,7 +164,7 @@ "}")) (def: (translate-pattern-matching translate path) - (-> (-> ls.Synthesis (Meta //.Expression)) Code (Meta //.Expression)) + (-> (-> ls.Synthesis (Meta Expression)) Code (Meta Expression)) (do macro.Monad<Meta> [pmJS (translate-pattern-matching' translate path)] (wrap (format "try {" pmJS "}" @@ -172,13 +173,13 @@ "}")))) (def: (initialize-pattern-matching stack-init) - (-> //.Expression //.Statement) + (-> Expression Statement) (format "var temp;" "var " cursor " = [" stack-init "];" "var " savepoint " = [];")) (def: #export (translate-case translate valueS path) - (-> (-> ls.Synthesis (Meta //.Expression)) ls.Synthesis Code (Meta //.Expression)) + (-> (-> ls.Synthesis (Meta Expression)) ls.Synthesis Code (Meta Expression)) (do macro.Monad<Meta> [valueJS (translate valueS) pmJS (translate-pattern-matching translate path)] |