aboutsummaryrefslogtreecommitdiff
path: root/new-luxc/source/luxc/lang/translation/ruby/statement.jvm.lux
blob: 135a0903905f726c50e3c758bfbd08b6f1b6f08c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
(.module:
  lux
  (lux (control [monad #+ do])
       [macro]
       (data text/format))
  (luxc (lang [".L" module]
              (host [ruby #+ Ruby Expression Statement])))
  [//]
  (// [".T" runtime]
      [".T" reference]
      [".T" eval]))

(def: #export (translate-def name expressionT expressionO metaV)
  (-> Text Type Expression Code (Meta Any))
  (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 (ruby.global! def-name expressionO))
         expressionV (evalT.eval (ruby.global 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);"))
  )