aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/lux/target/jvm/attribute/code/exception.lux
blob: 17111c2516ee4ac08a8a4b841beddc2cf630f6d4 (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
(.module:
  [lux #*
   [abstract
    ["." equivalence (#+ Equivalence)]]
   [data
    [number
     ["n" nat]]
    [format
     [".F" binary (#+ Writer)]]]]
  ["." // #_
   ["//#" /// #_
    [constant (#+ Class)]
    ["#." index (#+ Index)]
    [instruction
     ["#." jump (#+ Jump)]]
    [encoding
     ["#." unsigned (#+ U2)]]]])

(type: #export Exception
  {#start-pc Jump
   #end-pc Jump
   #handler-pc Jump
   #catch-type (Index Class)})

(def: #export equivalence
  (Equivalence Exception)
  ($_ equivalence.product
      ////jump.equivalence
      ////jump.equivalence
      ////jump.equivalence
      ////index.equivalence
      ))

## https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-4.html#jvms-4.7.3
(def: #export length
  Nat
  ($_ n.+
      ## u2 start_pc;
      ////unsigned.u2-bytes
      ## u2 end_pc;
      ////unsigned.u2-bytes
      ## u2 handler_pc;
      ////unsigned.u2-bytes
      ## u2 catch_type;
      ////unsigned.u2-bytes
      ))

(def: #export writer
  (Writer Exception)
  ($_ binaryF.and
      ////jump.writer
      ////jump.writer
      ////jump.writer
      ////index.writer
      ))