aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/method/reset.lux
blob: faff66f47c8b3b9978bd4afe7f6f8cbeb01359c7 (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
(.require
 [library
  [lux (.except Type type)
   [data
    [collection
     ["[0]" list (.use "[1]#[0]" functor)]]]
   [target
    [jvm
     ["[0]" method (.only Method)]
     ["_" bytecode (.only Bytecode)]
     [constant
      [pool (.only Resource)]]
     ["[0]" type (.only Type)
      ["[0]" category (.only Class)]]]]]]
 ["[0]" // (.only)
  ["[1][0]" new]
  ["/[1]" //
   [field
    [variable
     ["[1][0]" foreign]]]
   ["/[1]" //
    ["[1][0]" reference]
    [////
     [analysis (.only Environment)]
     [synthesis (.only Synthesis)]
     [///
      ["[0]" arity (.only Arity)]]]]]])

(def .public name "reset")

(def .public (type class)
  (-> (Type Class) (Type category.Method))
  (type.method [(list) (list) class (list)]))

(def (current_environment class)
  (-> (Type Class) (Environment Synthesis) (List (Bytecode Any)))
  (|>> list.size
       list.indices
       (list#each (///foreign.get class))))

(def .public (method class environment arity)
  (-> (Type Class) (Environment Synthesis) Arity (Resource Method))
  (method.method //.modifier ..name
                 #0 (..type class)
                 (list)
                 {.#Some (all _.composite
                              (if (arity.multiary? arity)
                                (//new.instance' (..current_environment class environment) class environment arity)
                                ////reference.this)
                              _.areturn)}))