aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/jvm/function/method/implementation.lux
blob: 80491cbe481b78eff8213a809b87eb69415e32aa (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
57
58
59
60
61
62
63
... This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
... If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.

(.require
 [library
  [lux (.except Type Label type)
   [data
    [collection
     ["[0]" list]]]
   [math
    [number
     ["n" nat]]]
   [meta
    [compiler
     [target
      [jvm
       ["_" bytecode (.only Label Bytecode)]
       ["[0]" modifier (.only Modifier) (.use "[1]#[0]" monoid)]
       ["[0]" method (.only Method)]
       [constant
        [pool (.only Resource)]]
       ["[0]" type (.only Type)
        ["[0]" category (.only Class)]]]]]]]]
 ["[0]" // (.only)
  ["//[1]" ///
   ["[0]" runtime]
   ["[1][0]" type]
   [//////
    [arity (.only Arity)]
    [meta
     [archive
      ["[0]" unit]]]]]])

(def .public name "impl")

(def .public (type :it: arity)
  (-> (Type Class) Arity (Type category.Method))
  (type.method [(list)
                (list.partial :it: (list.repeated arity ////type.value))
                ////type.value
                (list)]))

(def modifier
  (all modifier#composite
       method.static
       //.modifier
       ))

(def .public (method :it: arity @begin body)
  (-> (Type Class) Arity Label (Bytecode Any) (Resource Method))
  (method.method ..modifier
    ..name
    false (..type :it: arity)
    (list)
    {.#Some (all _.composite
                 (_.set_label @begin)
                 body
                 (_.when_continuous _.areturn)
                 )}))

(def .public (call :it: arity)
  (-> (Type Class) Arity (Bytecode Any))
  (_.invokestatic :it: ..name (..type :it: arity)))