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. Private Function

genDefers

Private Function
std.zig.AstGen.genDefers
fn genDefers(
    gz: *GenZir,
    outer_scope: *Scope,
    inner_scope: *Scope,
    which_ones: enum

Params

  • gz: *GenZir
  • outer_scope: *Scope
  • inner_scope: *Scope
  • which_ones: enum { normal_only, normal_and_error }

Errors

OutOfMemory
AnalysisFail

File

zig/AstGen.zig:2992
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
fn genDefers(
    gz: *GenZir,
    outer_scope: *Scope,
    inner_scope: *Scope,
    which_ones: enum { normal_only, normal_and_error },
) InnerError!void {
    var scope = inner_scope;
    while (scope != outer_scope) {
        switch (scope.unwrap()) {
            .gen_zir => |gen_zir| scope = gen_zir.parent,
            .local_val => |local_val| scope = local_val.parent,
            .local_ptr => |local_ptr| scope = local_ptr.parent,
            .defer_normal => |defer_scope| {
                scope = defer_scope.parent;
                try gz.addDefer(defer_scope.index, defer_scope.len);
            },
            .defer_error => |defer_scope| {
                scope = defer_scope.parent;
                switch (which_ones) {
                    .normal_only => continue,
                    .normal_and_error => {
                        try gz.addDefer(defer_scope.index, defer_scope.len);
                    },
                }
            },
            .namespace => unreachable,
            .top => unreachable,
        }
    }
}