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/function.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/function.jvm.lux | 13 |
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 ";" |