structstd.zig.Zir.Inst.SwitchBlock.Bits[src]

Types

TypeScalarCasesLen[src]

Source Code

Source code
pub const ScalarCasesLen = u26

Fields

has_multi_cases: bool

If true, one or more prongs have multiple items.

has_else: bool

If true, there is an else prong. This is mutually exclusive with has_under.

has_under: bool

If true, there is an underscore prong. This is mutually exclusive with has_else.

any_has_tag_capture: bool

If true, at least one prong has an inline tag capture.

any_non_inline_capture: bool

If true, at least one prong has a capture which may not be comptime-known via inline.

has_continue: bool
scalar_cases_len: ScalarCasesLen

Functions

FunctionspecialProng[src]

pub fn specialProng(bits: Bits) SpecialProng

Parameters

bits: Bits

Source Code

Source code
pub fn specialProng(bits: Bits) SpecialProng {
    const has_else: u2 = @intFromBool(bits.has_else);
    const has_under: u2 = @intFromBool(bits.has_under);
    return switch ((has_else << 1) | has_under) {
        0b00 => .none,
        0b01 => .under,
        0b10 => .@"else",
        0b11 => unreachable,
    };
}

Source Code

Source code
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,
    /// If true, there is an underscore prong. This is mutually exclusive with `has_else`.
    has_under: bool,
    /// If true, at least one prong has an inline tag capture.
    any_has_tag_capture: bool,
    /// If true, at least one prong has a capture which may not
    /// be comptime-known via `inline`.
    any_non_inline_capture: bool,
    has_continue: bool,
    scalar_cases_len: ScalarCasesLen,

    pub const ScalarCasesLen = u26;

    pub fn specialProng(bits: Bits) SpecialProng {
        const has_else: u2 = @intFromBool(bits.has_else);
        const has_under: u2 = @intFromBool(bits.has_under);
        return switch ((has_else << 1) | has_under) {
            0b00 => .none,
            0b01 => .under,
            0b10 => .@"else",
            0b11 => unreachable,
        };
    }
}