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/loop.jvm.lux | |
parent | 6e829294381d504656d904dc71b7c6729750db5e (diff) |
- Got JS backend to build with the rest of the new-luxc code.
Diffstat (limited to 'new-luxc/source/luxc/lang/translation/js/loop.jvm.lux')
-rw-r--r-- | new-luxc/source/luxc/lang/translation/js/loop.jvm.lux | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/new-luxc/source/luxc/lang/translation/js/loop.jvm.lux b/new-luxc/source/luxc/lang/translation/js/loop.jvm.lux index 64b2e5b39..9315508e8 100644 --- a/new-luxc/source/luxc/lang/translation/js/loop.jvm.lux +++ b/new-luxc/source/luxc/lang/translation/js/loop.jvm.lux @@ -5,27 +5,30 @@ text/format (coll [list "list/" Functor<List>])) [macro]) - (luxc (lang ["ls" synthesis])) + (luxc [lang] + (lang ["ls" synthesis])) [//] (// [".T" reference])) -(def: #export loop-name Text "_loop") - (def: #export (translate-loop translate offset initsS+ bodyS) (-> (-> ls.Synthesis (Meta //.Expression)) Nat (List ls.Synthesis) ls.Synthesis (Meta //.Expression)) (do macro.Monad<Meta> - [initsJS+ (monad.map @ translate initsS+) - bodyJS (translate bodyS) + [loop-name (:: @ map (|>> %code lang.normalize-name) + (macro.gensym "loop")) + initsJS+ (monad.map @ translate initsS+) + bodyJS (//.with-anchor [loop-name offset] + (translate bodyS)) #let [registersJS+ (|> (list.n/range +0 (n/dec (list.size initsS+))) (list/map (|>> (n/+ offset) referenceT.variable)))]] (wrap (format "(function " loop-name "(" (text.join-with "," registersJS+) ") {" "return " bodyJS ";" "})(" (text.join-with "," initsJS+) ")")))) -(def: #export (translate-iter translate offset argsS+) - (-> (-> ls.Synthesis (Meta //.Expression)) Nat (List ls.Synthesis) +(def: #export (translate-recur translate argsS+) + (-> (-> ls.Synthesis (Meta //.Expression)) (List ls.Synthesis) (Meta //.Expression)) (do macro.Monad<Meta> - [argsJS+ (monad.map @ translate argsS+)] + [[loop-name offset] //.anchor + argsJS+ (monad.map @ translate argsS+)] (wrap (format loop-name "(" (text.join-with "," argsJS+) ")")))) |