aboutsummaryrefslogtreecommitdiff
path: root/new-luxc/source/luxc/lang/translation/js/reference.jvm.lux
blob: 66d3409499a2088f481c9617650cbea12ab6d557 (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
(.module:
  lux
  (lux [macro]
       (data [text]
             text/format))
  (luxc ["&" lang]
        (lang [".L" variable #+ Variable Register]))
  [//]
  (// [".T" runtime]))

(do-template [<register> <translation> <prefix>]
  [(def: #export (<register> register)
     (-> Register //.Expression)
     (format <prefix> (%n register)))
   
   (def: #export (<translation> register)
     (-> Register (Meta //.Expression))
     (:: macro.Monad<Meta> wrap (<register> register)))]

  [closure  translate-captured "c"]
  [variable translate-local    "v"])

(def: #export (translate-variable var)
  (-> Variable (Meta //.Expression))
  (if (variableL.captured? var)
    (translate-captured (int-to-nat var))
    (translate-local (int-to-nat var))))

(def: #export global
  (-> Ident //.Expression)
  //.definition-name)

(def: #export (translate-definition name)
  (-> Ident (Meta //.Expression))
  (:: macro.Monad<Meta> wrap (global name)))