aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/lux/tool/compiler/phase/generation/jvm/function/method/init.lux
blob: 5a53ff9e084efee67888a2a3e731ea843a6d1816 (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
(.module:
  [lux (#- type)
   [target
    [jvm
     ["." descriptor (#+ Descriptor Value Return)]
     ["_" instruction (#+ Instruction)]
     [encoding
      ["." unsigned]]]]]
  ["." /// #_
   ["#." abstract]
   ["#." arity]
   ["/#" // #_
    [////
     ["." arity (#+ Arity)]]]])

(def: #export type
  [(List (Descriptor Value))
   (Descriptor (Return Any))]
  [(list ///arity.type) descriptor.void])

(def: #export (instruction environment-size arity)
  (-> Nat Arity (Instruction Any))
  (let [arity-register (inc environment-size)]
    ($_ _.compose
        (if (arity.unary? arity)
          (_.bipush (unsigned.u1 0))
          (_.iload (unsigned.u1 arity-register)))
        (_.invokespecial ///abstract.class "<init>" ..type))))