diff options
author | Eduardo Julian | 2019-02-19 22:52:52 -0400 |
---|---|---|
committer | Eduardo Julian | 2019-02-19 22:52:52 -0400 |
commit | 2b105c8694b87a63bd151cd0966c9d5dcfaae672 (patch) | |
tree | 6264e1fceee61337b631ac0569c23d24a5f89149 /new-luxc/source/luxc/lang/translation/js/loop.jvm.lux | |
parent | 8892e902809e680a067da9c85d54cae2acc82ce8 (diff) |
Moved looping machinery over.
Diffstat (limited to '')
-rw-r--r-- | new-luxc/source/luxc/lang/translation/js/loop.jvm.lux | 35 |
1 files changed, 0 insertions, 35 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 deleted file mode 100644 index c63cb2d32..000000000 --- a/new-luxc/source/luxc/lang/translation/js/loop.jvm.lux +++ /dev/null @@ -1,35 +0,0 @@ -(.module: - lux - (lux (control [monad #+ do]) - (data [text] - text/format - (coll [list "list/" Functor<List>])) - [macro]) - (luxc [lang] - (lang ["ls" synthesis] - (host [js #+ JS Expression Statement]))) - [//] - (// [".T" reference])) - -(def: #export (translate-loop translate offset initsS+ bodyS) - (-> (-> ls.Synthesis (Meta Expression)) Nat (List ls.Synthesis) ls.Synthesis - (Meta Expression)) - (do macro.Monad<Meta> - [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 (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-recur translate argsS+) - (-> (-> ls.Synthesis (Meta Expression)) (List ls.Synthesis) - (Meta Expression)) - (do macro.Monad<Meta> - [[loop-name offset] //.anchor - argsJS+ (monad.map @ translate argsS+)] - (wrap (format loop-name "(" (text.join-with "," argsJS+) ")")))) |