diff options
author | Eduardo Julian | 2018-01-28 19:41:01 -0400 |
---|---|---|
committer | Eduardo Julian | 2018-01-28 19:41:01 -0400 |
commit | 6b6901b31bbec9947522a94274cd11c8e7683168 (patch) | |
tree | ac984159a7c23bbdfab8a2fa1ddde1f625d7dae0 /new-luxc/source/luxc/lang/translation/js/expression.jvm.lux | |
parent | 6e829294381d504656d904dc71b7c6729750db5e (diff) |
- Got JS backend to build with the rest of the new-luxc code.
Diffstat (limited to '')
-rw-r--r-- | new-luxc/source/luxc/lang/translation/js/expression.jvm.lux | 32 |
1 files changed, 21 insertions, 11 deletions
diff --git a/new-luxc/source/luxc/lang/translation/js/expression.jvm.lux b/new-luxc/source/luxc/lang/translation/js/expression.jvm.lux index a25013305..4634497a1 100644 --- a/new-luxc/source/luxc/lang/translation/js/expression.jvm.lux +++ b/new-luxc/source/luxc/lang/translation/js/expression.jvm.lux @@ -2,9 +2,15 @@ lux (lux (control [monad #+ do] ["ex" exception #+ exception:] - ["p" parser])) + ["p" parser]) + (data ["e" error] + text/format) + [macro] + (macro ["s" syntax])) (luxc ["&" lang] - (lang ["ls" synthesis])) + (lang [".L" variable #+ Variable Register] + [".L" extension] + ["ls" synthesis])) [//] (// [".T" runtime] [".T" primitive] @@ -12,15 +18,17 @@ [".T" reference] [".T" function] [".T" loop] - [".T" case])) + [".T" case] + [".T" procedure])) +(exception: #export Invalid-Function-Syntax) (exception: #export Unrecognized-Synthesis) (def: #export (translate synthesis) (-> ls.Synthesis (Meta //.Expression)) (case synthesis (^code []) - (wrap runtimeT.unit) + (:: macro.Monad<Meta> wrap runtimeT.unit) (^code [(~ singleton)]) (translate singleton) @@ -42,22 +50,24 @@ (structureT.translate-tuple translate members) (^ [_ (#.Form (list [_ (#.Int var)]))]) - (if (variableL.captured? var) - (referenceT.translate-captured var) - (referenceT.translate-local var)) + (referenceT.translate-variable var) [_ (#.Symbol definition)] (referenceT.translate-definition definition) (^code ("lux let" (~ [_ (#.Nat register)]) (~ inputS) (~ exprS))) - (caseT.translate-let translate register inputS exprS) + (caseT.translate-let translate inputS register exprS) (^code ("lux case" (~ inputS) (~ pathPS))) (caseT.translate-case translate inputS pathPS) - (^multi (^code ("lux function" (~ [_ (#.Nat arity)]) [(~+ environment)] (~ bodyS))) - [(s.run environment (p.some s.int)) (#e.Success environment)]) - (functionT.translate-function translate environment arity bodyS) + (^code ("lux function" (~ [_ (#.Nat arity)]) [(~+ environment)] (~ bodyS))) + (case (s.run environment (p.some s.int)) + (#e.Success environment) + (functionT.translate-function translate environment arity bodyS) + + _ + (&.throw Invalid-Function-Syntax (%code synthesis))) (^code ("lux call" (~ functionS) (~+ argsS))) (functionT.translate-apply translate functionS argsS) |