aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/lux/language/compiler/translation/scheme/reference.jvm.lux
blob: e1cb6a6429707124758fd8a5617b4636923daa01 (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
49
50
51
52
53
54
(.module:
  lux
  (lux (control pipe)
       (data text/format))
  (///// [reference #+ Register Variable Reference]
         [name]
         (host ["_" scheme #+ Expression Var])
         [compiler "operation/" Monad<Operation>]
         (compiler [analysis #+ Variant Tuple]
                   [synthesis #+ Synthesis]))
  [//runtime #+ Operation Translator]
  [//primitive])

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

  [local'   "l"]
  [foreign' "f"]
  )

(def: #export variable'
  (-> Variable Var)
  (|>> (case> (#reference.Local register)
              (local' register)
              
              (#reference.Foreign register)
              (foreign' register))))

(def: #export variable
  (-> Variable (Operation Var))
  (|>> ..variable'
       operation/wrap))

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

(def: #export constant
  (-> Ident (Operation Var))
  (|>> constant' operation/wrap))

(def: #export reference'
  (-> Reference Expression)
  (|>> (case> (#reference.Constant value)
              (..constant' value)
              
              (#reference.Variable value)
              (..variable' value))))

(def: #export reference
  (-> Reference (Operation Expression))
  (|>> reference' operation/wrap))