aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/library/lux/meta/compiler/target/jvm/attribute/code/exception.lux
blob: ec6056b61a89856512c9c6d8cc6455bfd3ff2b6b (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
... 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)
   [abstract
    [equivalence (.only Equivalence)]]
   [data
    ["[0]" product]
    [binary
     ["[0]" \\format (.only Format)]]]
   [math
    [number
     ["n" nat]]]]]
 ["[0]" //
  ["//[1]" ///
   [constant (.only Class)]
   ["[1][0]" index (.only Index)]
   [bytecode
    ["[1][0]" address (.only Address)]]
   [encoding
    ["[1][0]" unsigned (.only U2)]]]])

(type .public Exception
  (Record
   [#start Address
    #end Address
    #handler Address
    #catch (Index Class)]))

(def .public equivalence
  (Equivalence Exception)
  (all product.equivalence
       ////address.equivalence
       ////address.equivalence
       ////address.equivalence
       ////index.equivalence
       ))

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

(def .public format
  (Format Exception)
  (all \\format.and
       ////address.format
       ////address.format
       ////address.format
       ////index.format
       ))