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 standard library.
std › zig › AstGen › deferStmt Private Function deferStmt Doc Source 3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098 fn deferStmt (
gz : *GenZir ,
scope : *Scope ,
node : Ast .Node .Index ,
block_arena : Allocator ,
scope_tag : Scope .Tag ,
) InnerError !*Scope {
var defer_gen = gz .makeSubBlock (scope );
defer_gen .cur_defer_node = node .toOptional ();
defer_gen .any_defer_node = node .toOptional ();
defer defer_gen .unstack ();
const tree = gz .astgen .tree ;
const expr_node = tree .nodeData (node ).node ;
_ = try unusedResultExpr (&defer_gen , &defer_gen .base , expr_node );
try checkUsed (gz , scope , &defer_gen .base );
_ = try defer_gen .addBreak (.break_inline , @fromBackingInt (@intCast (0 )), .void_value );
const body = defer_gen .instructionsSlice ();
const body_len = gz .astgen .countBodyLenAfterFixupsExtraRefs (body , &.{});
const index : u32 = @intCast (gz .astgen .extra .items .len );
try gz .astgen .extra .ensureUnusedCapacity (gz .astgen .gpa , body_len );
gz .astgen .appendBodyWithFixupsExtraRefsArrayList (&gz .astgen .extra , body , &.{});
const defer_scope = try block_arena .create (Scope .Defer );
defer_scope .* = .{
.base = .{ .tag = scope_tag },
.parent = scope ,
.index = index ,
.len = body_len ,
};
return &defer_scope .base ;
}