struct SwitchBlockErrUnion [src]
Trailing:
multi_cases_len: u32 // if has_multi_cases
err_capture_inst: u32 // if any_uses_err_capture
non_err_body {
info: ProngInfo,
inst: Index // for every info.body_len
}
else_body { // if has_else
info: ProngInfo,
inst: Index // for every info.body_len
}
scalar_cases: { // for every scalar_cases_len
item: Ref,
info: ProngInfo,
inst: Index // for every info.body_len
}
multi_cases: { // for every multi_cases_len
items_len: u32,
ranges_len: u32,
info: ProngInfo,
item: Ref // for every items_len
ranges: { // for every ranges_len
item_first: Ref,
item_last: Ref,
}
inst: Index // for every info.body_len
}
When analyzing a case body, the switch instruction itself refers to the
captured error, or to the success value in non_err_body. Whether this
is captured by reference or by value depends on whether the byref bit
is set for the corresponding body. err_capture_inst refers to the error
capture outside of the switch, i.e. err in
x catch |err| switch (err) { ... }.
Fields
operand: Ref
bits: Bits
main_src_node_offset: Ast.Node.Offset
Members
- Bits (struct)
- MultiProng (struct)
Source
pub const SwitchBlockErrUnion = struct {
operand: Ref,
bits: Bits,
main_src_node_offset: Ast.Node.Offset,
pub const Bits = packed struct(u32) {
/// If true, one or more prongs have multiple items.
has_multi_cases: bool,
/// If true, there is an else prong. This is mutually exclusive with `has_under`.
has_else: bool,
any_uses_err_capture: bool,
payload_is_ref: bool,
scalar_cases_len: ScalarCasesLen,
pub const ScalarCasesLen = u28;
};
pub const MultiProng = struct {
items: []const Ref,
body: []const Index,
};
}