Skip to content
← Back

src/ir/wasmgc/wasmgc_finally_exits.ghul

1
namespace IR.WasmGC is
2
use IR.Program
3
4
/// The exits that leave the protected body of a try with a finally.
5
/// Wasm has no branch that runs a finally on its way out, so an exit
6
/// stores its number in `selector` and branches to the finally; after
7
/// the finally each numbered exit is taken again from there.
8
class WASMGC_FINALLY_EXITS is
9
_numbering: EXIT_NUMBERING
10
11
/// The local holding the number of the exit being taken, 0 for
12
/// none.
13
selector: int
14
15
/// The position on the label stack of the block an exit branches
16
/// to, after which the finally runs.
17
finally_label: int public
18
19
/// One of each kind of exit numbered so far, the exit numbered
20
/// `n` at `n - 1`.
21
exits: Collections.List[Values.Exit] => _numbering.exits
22
23
/// - selector: the local the exit's number is stored in
24
init(selector: int) is
25
self.selector = selector
26
27
_numbering = EXIT_NUMBERING()
28
si
29
30
/// The number of `exit`, from 1. Exits that go to the same place
31
/// share a number.
32
number(exit: Values.Exit) -> int => _numbering.number(exit)
33
si
34
si