aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/lux/tool/compiler/phase/generation/jvm/function/field/variable.lux
blob: cbff8ea5e31673abe05a5d6e0c78d57d74c85a70 (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
55
56
(.module:
  [lux (#- Type type)
   [control
    [state (#+ State)]]
   [data
    [collection
     ["." list ("#@." functor)]
     ["." row]]]
   [target
    [jvm
     ["." modifier (#+ Modifier) ("#@." monoid)]
     ["." field (#+ Field)]
     ["_" instruction (#+ Instruction)]
     [type (#+ Type)
      [category (#+ Value Class)]]
     [constant
      [pool (#+ Pool)]]]]]
  ["." //// #_
   ["#." type]
   ["#." reference]
   [////
    [reference (#+ Register)]]])

(def: #export type ////type.value)

(def: #export (get class name)
  (-> (Type Class) Text (Instruction Any))
  ($_ _.compose
      ////reference.this
      (_.getfield class name ..type)
      ))

(def: #export (put naming class register value)
  (-> (-> Register Text) (Type Class) Register (Instruction Any) (Instruction Any))
  ($_ _.compose
      ////reference.this
      value
      (_.putfield class (naming register) ..type)))

(def: modifier
  (Modifier Field)
  ($_ modifier@compose
      field.private
      field.final
      ))

(def: #export (variable name type)
  (-> Text (Type Value) (State Pool Field))
  (field.field ..modifier name type (row.row)))

(def: #export (variables naming amount)
  (-> (-> Register Text) Nat (List (State Pool Field)))
  (|> amount
      list.indices
      (list@map (function (_ register)
                  (..variable (naming register) ..type)))))