Zig 0.17.0-dev (Split by item)

Shortcut keys
?
Show these tips
S
Focus search field
Esc
Clear focus & close tips
U
Jump to source code
↑
Move up in search results
↓
Move down in search results
↵
Go to active search result
This is an example of documentation generated by ZigDoc, an alternative to Zig's built-in Auto Doc feature. See also examples in other modes/formats. The project being documented here (as the example) is the Zig standard library. Public Struct

UnionDecl

Public Struct
std.zig.Zir.Inst.UnionDecl
pub const UnionDecl = struct

Trailing:

  1. captures_len: u32 // if has_captures_len
  2. decls_len: u32, // if has_decls_len
  3. fields_len: u32, // if has_fields_len
  4. arg_type_body_len: u32, // if kind.hasArgType()
  5. capture: Capture // for every captures_len
  6. capture_name: NullTerminatedString // for every captures_len
  7. decl: Index, // for every decls_len; points to a declaration instruction
  8. field_name: NullTerminatedString // for every fields_len
  9. field_type_body_len: u32 // for every fields_len 9 . field_align_body_len: u32 // for every fields_len if any_field_aligns
  10. field_value_body_len: u32 // for every fields_len if any_field_values
  11. arg_type_body_inst: Inst.Index // for each arg_type_body_len
  12. body_inst: Inst.Index // type body, then align body, then value body, for each field

Fields

fields_hash_0: u32

These fields should be concatenated and reinterpreted as a std.zig.SrcHash. This hash contains the source of all fields, and any specified attributes (extern etc).

fields_hash_1: u32
fields_hash_2: u32
fields_hash_3: u32
src_line: u32
src_column: u32
src_node: Ast.Node.Index

This node provides a new absolute baseline node for all instructions within this struct.

Structs

Types

File

zig/Zir.zig:3702
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
    pub const UnionDecl = struct {
        // These fields should be concatenated and reinterpreted as a `std.zig.SrcHash`.
        // This hash contains the source of all fields, and any specified attributes (`extern` etc).
        fields_hash_0: u32,
        fields_hash_1: u32,
        fields_hash_2: u32,
        fields_hash_3: u32,
        src_line: u32,
        src_column: u32,
        /// This node provides a new absolute baseline node for all instructions within this struct.
        src_node: Ast.Node.Index,

        pub const Small = packed struct(u16) {
            has_captures_len: bool,
            has_decls_len: bool,
            has_fields_len: bool,
            name_strategy: NameStrategy,
            kind: Kind,
            any_field_aligns: bool,
            any_field_values: bool,
            _: u6 = 0,
        };

        pub const Kind = enum(u3) {
            /// `union`
            auto,
            /// `union(T)`
            tagged_explicit,
            /// `union(enum)`
            tagged_enum,
            /// `union(enum(T))`
            tagged_enum_explicit,
            /// `extern union`
            @"extern",
            /// `packed union`
            @"packed",
            /// `packed union(T)`
            packed_explicit,

            pub fn hasArgType(k: Kind) bool {
                return switch (k) {
                    .auto, .tagged_enum, .@"extern", .@"packed" => false,
                    .tagged_explicit, .tagged_enum_explicit, .packed_explicit => true,
                };
            }

            pub fn layout(k: Kind) std.lang.Type.ContainerLayout {
                return switch (k) {
                    .auto, .tagged_explicit, .tagged_enum, .tagged_enum_explicit => .auto,
                    .@"extern" => .@"extern",
                    .@"packed", .packed_explicit => .@"packed",
                };
            }
        };
    }