aboutsummaryrefslogtreecommitdiff
path: root/new-luxc/source/luxc/lang/translation/lua/statement.jvm.lux
diff options
context:
space:
mode:
authorEduardo Julian2018-03-06 01:07:43 -0400
committerEduardo Julian2018-03-06 01:07:43 -0400
commit38bd6f35d81705ab0c04c85601ac5b236b62605a (patch)
tree4c2fd4f6369067965017aeea18ba68b1f658344d /new-luxc/source/luxc/lang/translation/lua/statement.jvm.lux
parent9bf491a18e4b772505c3767cf0249eb24f0a822b (diff)
- Initial Lua backend implementation.
Diffstat (limited to '')
-rw-r--r--new-luxc/source/luxc/lang/translation/lua/statement.jvm.lux48
1 files changed, 48 insertions, 0 deletions
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<Meta>
+ [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);"))
+ )