From 6b6901b31bbec9947522a94274cd11c8e7683168 Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Sun, 28 Jan 2018 19:41:01 -0400 Subject: - Got JS backend to build with the rest of the new-luxc code. --- new-luxc/source/luxc/lang/translation/js/function.jvm.lux | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'new-luxc/source/luxc/lang/translation/js/function.jvm.lux') 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 - [[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 ";" -- cgit v1.2.3