From 0bd93d82eb7a50b9ce8be42800c388e87e6ca9bf Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Fri, 23 Feb 2018 23:10:28 -0400 Subject: - Added a code-generation utility module for JS. --- new-luxc/source/luxc/lang/translation/js/function.jvm.lux | 11 ++++++----- 1 file changed, 6 insertions(+), 5 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 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 [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 [[function-name bodyJS] (//.with-sub-context (do @ -- cgit v1.2.3