aboutsummaryrefslogtreecommitdiff
path: root/new-luxc/source/luxc/lang/translation/js/function.jvm.lux
diff options
context:
space:
mode:
authorEduardo Julian2018-02-23 23:10:28 -0400
committerEduardo Julian2018-02-23 23:10:28 -0400
commit0bd93d82eb7a50b9ce8be42800c388e87e6ca9bf (patch)
tree847453417dbf6bf76be82efd498074029162d38b /new-luxc/source/luxc/lang/translation/js/function.jvm.lux
parentc8e2898611fa759cbe7c2ac84738b5b403575664 (diff)
- Added a code-generation utility module for JS.
Diffstat (limited to '')
-rw-r--r--new-luxc/source/luxc/lang/translation/js/function.jvm.lux11
1 files changed, 6 insertions, 5 deletions
diff --git a/new-luxc/source/luxc/lang/translation/js/function.jvm.lux b/new-luxc/source/luxc/lang/translation/js/function.jvm.lux
index b0865a16e..b3c6761cd 100644
--- a/new-luxc/source/luxc/lang/translation/js/function.jvm.lux
+++ b/new-luxc/source/luxc/lang/translation/js/function.jvm.lux
@@ -7,13 +7,14 @@
[macro])
(luxc ["&" lang]
(lang ["ls" synthesis]
- [".L" variable #+ Variable]))
+ [".L" variable #+ Variable]
+ (host [js #+ JS Expression Statement])))
[//]
(// [".T" reference]
[".T" loop]))
(def: #export (translate-apply translate functionS argsS+)
- (-> (-> ls.Synthesis (Meta //.Expression)) ls.Synthesis (List ls.Synthesis) (Meta //.Expression))
+ (-> (-> ls.Synthesis (Meta Expression)) ls.Synthesis (List ls.Synthesis) (Meta Expression))
(do macro.Monad<Meta>
[functionJS (translate functionS)
argsJS+ (monad.map @ translate argsS+)]
@@ -23,7 +24,7 @@
(format "var " (referenceT.variable (n/inc register)) " = arguments[" (|> register nat-to-int %i) "];"))
(def: (with-closure inits function)
- (-> (List //.Expression) //.Expression //.Expression)
+ (-> (List Expression) Expression Expression)
(let [closure (case inits
#.Nil
(list)
@@ -36,9 +37,9 @@
";})(" (text.join-with "," inits) ")")))
(def: #export (translate-function translate env arity bodyS)
- (-> (-> ls.Synthesis (Meta //.Expression))
+ (-> (-> ls.Synthesis (Meta Expression))
(List Variable) ls.Arity ls.Synthesis
- (Meta //.Expression))
+ (Meta Expression))
(do macro.Monad<Meta>
[[function-name bodyJS] (//.with-sub-context
(do @