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

(do-template [<register> <prefix>]
  [(def: #export <register>
     (-> Register Var)
     (|>> (:coerce Int) %i (format <prefix>) _.var))]

  [closure  "c"]
  [variable "v"])

(def: #export (local var)
  (-> Variable Var)
  (if (variableL.captured? var)
    (closure (variableL.captured-register var))
    (variable (:coerce Nat var))))

(def: #export global
  (-> Ident Var)
  (|>> //.definition-name _.var))

(do-template [<name> <input> <converter>]
  [(def: #export <name>
     (-> <input> (Meta Var))
     (|>> <converter> (:: macro.Monad<Meta> wrap)))]

  [translate-variable   Variable local]
  [translate-definition Ident    global]
  )