aboutsummaryrefslogtreecommitdiff
path: root/new-luxc/source/luxc/lang/translation/js/function.jvm.lux
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--new-luxc/source/luxc/lang/translation/js/function.jvm.lux13
1 files changed, 7 insertions, 6 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 4debb077b..b0865a16e 100644
--- a/new-luxc/source/luxc/lang/translation/js/function.jvm.lux
+++ b/new-luxc/source/luxc/lang/translation/js/function.jvm.lux
@@ -40,22 +40,23 @@
(List Variable) ls.Arity ls.Synthesis
(Meta //.Expression))
(do macro.Monad<Meta>
- [[function-name bodyJS] (hostL.with-sub-context
- (translate bodyS))
- closureJS+ (monad.map @ translate env)
+ [[function-name bodyJS] (//.with-sub-context
+ (do @
+ [function-name //.context]
+ (//.with-anchor [function-name +1]
+ (translate bodyS))))
+ closureJS+ (monad.map @ referenceT.translate-variable env)
#let [args-initsJS+ (|> (list.n/range +0 (n/dec arity))
(list/map input-declaration)
(text.join-with ""))
selfJS (format "var " (referenceT.variable +0) " = " function-name ";")
- loop-startJs (format "var " loopT.loop-name " = " function-name ";")
arityJS (|> arity nat-to-int %i)]]
(wrap (<| (with-closure closureJS+)
(format "(function " function-name "() {"
"\"use strict\";"
"var num_args = arguments.length;"
- "if(num_args == " arity ") {"
+ "if(num_args == " arityJS ") {"
selfJS
- loop-startJs
args-initsJS+
(format "while(true) {"
"return " bodyJS ";"