aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/field/variable.lux
blob: aa200182d3ef0b11a66a56f84c050804752b1c16 (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:
  [library
   [lux (#- Type type)
    [data
     [collection
      ["." list ("#\." functor)]
      ["." row]]]
    [target
     [jvm
      ["." modifier (#+ Modifier) ("#\." monoid)]
      ["." field (#+ Field)]
      ["_" bytecode (#+ Bytecode)]
      [type (#+ Type)
       [category (#+ Value Class)]]
      [constant
       [pool (#+ Resource)]]]]]]
  ["." //// #_
   ["#." type]
   ["#." reference]
   [//////
    [reference
     [variable (#+ Register)]]]])

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

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

(def: #export (put naming class register value)
  (-> (-> Register Text) (Type Class) Register (Bytecode Any) (Bytecode 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) (Resource Field))
  (field.field ..modifier name type (row.row)))

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