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 Function

findTrackableFields

Public Function
std.zig.Zir.findTrackableFields
pub fn findTrackableFields(
    zir: *const Zir,
    gpa: Allocator,
    contents: *DeclContents,
    type_decl_inst: Zir.Inst.Index,
) Allocator.Error!void

findTrackable does not recurse into field expressions in a type. Instead, this function will scan specifically field expressions in a given type declaration for trackable ZIR instructions.

Params

File

zig/Zir.zig:4084
4084
4085
4086
4087
4088
4089
4090
4091
4092
4093
4094
4095
4096
4097
4098
4099
4100
4101
4102
4103
4104
4105
4106
4107
4108
4109
4110
4111
4112
4113
4114
4115
4116
4117
4118
4119
4120
4121
4122
4123
4124
4125
pub fn findTrackableFields(
    zir: *const Zir,
    gpa: Allocator,
    contents: *DeclContents,
    type_decl_inst: Zir.Inst.Index,
) Allocator.Error!void {
    contents.clear();

    var found_defers: std.AutoHashMapUnmanaged(u32, void) = .empty;
    defer found_defers.deinit(gpa);

    assert(zir.instructions.items(.tag)[@backingInt(type_decl_inst)] == .extended);
    switch (zir.instructions.items(.data)[@backingInt(type_decl_inst)].extended.opcode) {
        .struct_decl => {
            const struct_decl = zir.getStructDecl(type_decl_inst);
            var it = struct_decl.iterateFields();
            while (it.next()) |field| {
                try zir.findTrackableBody(gpa, contents, &found_defers, field.type_body);
                if (field.align_body) |b| try zir.findTrackableBody(gpa, contents, &found_defers, b);
                if (field.default_body) |b| try zir.findTrackableBody(gpa, contents, &found_defers, b);
            }
        },
        .union_decl => {
            const union_decl = zir.getUnionDecl(type_decl_inst);
            var it = union_decl.iterateFields();
            while (it.next()) |field| {
                if (field.type_body) |b| try zir.findTrackableBody(gpa, contents, &found_defers, b);
                if (field.align_body) |b| try zir.findTrackableBody(gpa, contents, &found_defers, b);
                if (field.value_body) |b| try zir.findTrackableBody(gpa, contents, &found_defers, b);
            }
        },
        .enum_decl => {
            const enum_decl = zir.getEnumDecl(type_decl_inst);
            var it = enum_decl.iterateFields();
            while (it.next()) |field| {
                if (field.value_body) |b| try zir.findTrackableBody(gpa, contents, &found_defers, b);
            }
        },
        .opaque_decl => {},
        else => unreachable,
    }
}