aboutsummaryrefslogtreecommitdiff
path: root/new-luxc/source/luxc/lang/translation/python/statement.jvm.lux
diff options
context:
space:
mode:
authorEduardo Julian2018-04-04 00:56:16 -0400
committerEduardo Julian2018-04-04 00:56:16 -0400
commit787fc34a8f7c66746046a8ce0c16403cf6c2bf6c (patch)
tree31c054f4a61e784875b7d66642558e9357d91493 /new-luxc/source/luxc/lang/translation/python/statement.jvm.lux
parentb14f95ca68887d9e6cea211b47e04e5ec00c05fa (diff)
- Initial Python back-end implementation.
Diffstat (limited to '')
-rw-r--r--new-luxc/source/luxc/lang/translation/python/statement.jvm.lux48
1 files changed, 48 insertions, 0 deletions
diff --git a/new-luxc/source/luxc/lang/translation/python/statement.jvm.lux b/new-luxc/source/luxc/lang/translation/python/statement.jvm.lux
new file mode 100644
index 000000000..36fe472d3
--- /dev/null
+++ b/new-luxc/source/luxc/lang/translation/python/statement.jvm.lux
@@ -0,0 +1,48 @@
+(.module:
+ lux
+ (lux (control [monad #+ do])
+ [macro]
+ (data text/format))
+ (luxc (lang [".L" module]
+ (host [python #+ 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 (python.set! (list def-name) 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);"))
+ )