aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/lux/tool/compiler/phase/generation/jvm/function/method/implementation.lux
blob: a0e60619414df8f0bf7f8ab49c26b294b0114e5c (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
(.module:
  [lux (#- Type type)
   [data
    [collection
     ["." list]]]
   [target
    [jvm
     ["." method (#+ Method)]
     ["_" bytecode (#+ Label Bytecode)]
     [constant
      [pool (#+ Resource)]]
     ["." type (#+ Type)
      ["." category]]]]]
  ["." //
   ["//#" /// #_
    ["#." type]
    [////
     [arity (#+ Arity)]]]])

(def: #export name "impl")

(def: #export (type arity)
  (-> Arity (Type category.Method))
  (type.method [(list.repeat arity ////type.value)
                ////type.value
                (list)]))

(def: #export (method' name arity @begin body)
  (-> Text Arity Label (Bytecode Any) (Resource Method))
  (method.method //.modifier name
                 (..type arity)
                 (list)
                 (#.Some ($_ _.compose
                             (_.set-label @begin)
                             body
                             _.areturn
                             ))))

(def: #export method
  (-> Arity Label (Bytecode Any) (Resource Method))
  (method' ..name))