From 38bd6f35d81705ab0c04c85601ac5b236b62605a Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Tue, 6 Mar 2018 01:07:43 -0400 Subject: - Initial Lua backend implementation. --- .../luxc/lang/translation/lua/statement.jvm.lux | 48 ++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 new-luxc/source/luxc/lang/translation/lua/statement.jvm.lux (limited to 'new-luxc/source/luxc/lang/translation/lua/statement.jvm.lux') diff --git a/new-luxc/source/luxc/lang/translation/lua/statement.jvm.lux b/new-luxc/source/luxc/lang/translation/lua/statement.jvm.lux new file mode 100644 index 000000000..eb181d160 --- /dev/null +++ b/new-luxc/source/luxc/lang/translation/lua/statement.jvm.lux @@ -0,0 +1,48 @@ +(.module: + lux + (lux (control [monad #+ do]) + [macro] + (data text/format)) + (luxc (lang [".L" module] + (host [lua #+ Lua Expression Statement]))) + [//] + (// [".T" runtime] + [".T" reference] + [".T" eval])) + +(def: #export (translate-def name expressionT expressionO metaV) + (-> Text Type Expression Code (Meta Unit)) + (do macro.Monad + [current-module macro.current-module-name + #let [def-ident [current-module name]]] + (case (macro.get-symbol-ann (ident-for #.alias) metaV) + (#.Some real-def) + (do @ + [[realT realA realV] (macro.find-def real-def) + _ (moduleL.define def-ident [realT metaV realV])] + (wrap [])) + + _ + (do @ + [#let [def-name (referenceT.global def-ident)] + _ (//.save (lua.global! def-name (#.Some expressionO))) + expressionV (evalT.eval def-name) + _ (moduleL.define def-ident [expressionT metaV expressionV]) + _ (if (macro.type? metaV) + (case (macro.declared-tags metaV) + #.Nil + (wrap []) + + tags + (moduleL.declare-tags tags (macro.export? metaV) (:! Type expressionV))) + (wrap [])) + #let [_ (log! (format "DEF " (%ident def-ident)))]] + (wrap [])) + ))) + +(def: #export (translate-program programO) + (-> Expression (Meta Statement)) + (macro.fail "translate-program NOT IMPLEMENTED YET") + ## (hostT.save (format "var " (referenceT.variable +0) " = " runtimeT.lux//program-args "();" + ## "(" programO ")(null);")) + ) -- cgit v1.2.3