Zig 0.17.0-dev (Split by item)
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 library itself.
Zig › std/ › zig/ › AstGen.zig › genDefers
genDefers
AstGen.genDefers
fn genDefers (
gz : *GenZir ,
outer_scope : *Scope ,
inner_scope : *Scope ,
which_ones : enum
File
Code
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 ,
}
}
}