aboutsummaryrefslogtreecommitdiff
path: root/new-luxc/source/luxc/lang/translation/js/statement.jvm.lux
diff options
context:
space:
mode:
authorEduardo Julian2018-01-21 12:58:48 -0400
committerEduardo Julian2018-01-21 12:58:48 -0400
commit498af2e0123c1ce65e46bf15fe3854266ad58f53 (patch)
treee8235092c959b91c4328c838450a9ac391e0cbcc /new-luxc/source/luxc/lang/translation/js/statement.jvm.lux
parent002ee0418195afccd1a1b500a36cc5b2adc44791 (diff)
- WIP: Host procedures for JS.
Diffstat (limited to '')
-rw-r--r--new-luxc/source/luxc/lang/translation/js/statement.jvm.lux47
1 files changed, 47 insertions, 0 deletions
diff --git a/new-luxc/source/luxc/lang/translation/js/statement.jvm.lux b/new-luxc/source/luxc/lang/translation/js/statement.jvm.lux
new file mode 100644
index 000000000..e430d22ae
--- /dev/null
+++ b/new-luxc/source/luxc/lang/translation/js/statement.jvm.lux
@@ -0,0 +1,47 @@
+(.module:
+ lux
+ (lux (control [monad #+ do])
+ [macro]
+ (data text/format))
+ (luxc (lang [".L" module]))
+ [//]
+ (// [".T" runtime]
+ [".T" reference]))
+
+(def: #export (translate-def name expressionT expressionJS 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)]
+ ## _ (hostT.save (format "var " def-name " = " expressionJS ";"))
+ #let [expressionV (: Top [])]
+ ## expressionV (hostT.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 programJS)
+ (-> //.Expression (Meta //.Statement))
+ (macro.fail "translate-program NOT IMPLEMENTED YET")
+ ## (hostT.save (format "var " (referenceT.variable +0) " = " runtimeT.lux//program-args "();"
+ ## "(" programJS ")(null);"))
+ )