aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/lux/host/jvm/constant/tag.lux
blob: 0339489f9129f1e0f142133d49961bfbfd737b51 (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
(.module:
  [lux #*
   [control
    [equivalence (#+ Equivalence)]]
   [data
    [format
     ["." binary (#+ Format)]]]
   [type
    abstract]]
  [///
   ["." encoding (#+ U1) ("u1/." u1-equivalence)]])

(abstract: #export Tag
  {}

  U1

  (structure: #export equivalence (Equivalence Tag)
    (def: (= reference sample)
      (u1/= (:representation reference)
            (:representation sample))))

  (template [<code> <name>]
    [(def: #export <name>
       Tag
       (:abstraction (encoding.to-u1 <code>)))]

    [01 utf8]
    [03 integer]
    [04 float]
    [05 long]
    [06 double]
    [07 class]
    [08 string]
    [09 field]
    [10 method]
    [11 interface-method]
    [12 name-and-type]
    [15 method-handle]
    [16 method-type]
    [18 invoke-dynamic]
    )

  (def: #export format
    (Format Tag)
    (binary.adapt (|>> :abstraction)
                  (|>> :representation)
                  encoding.u1-format))
  )