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 › structInitExprAnon Private Function structInitExprAnon Doc Source Private Function std.zig.AstGen.structInitExprAnon
fn structInitExprAnon (
gz : *GenZir ,
scope : *Scope ,
node : Ast .Node .Index ,
struct_init : Ast .full .StructInit ,
) InnerError !Zir .Inst .Ref Params Errors File zig/AstGen.zig: 1876
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905 fn structInitExprAnon (
gz : *GenZir ,
scope : *Scope ,
node : Ast .Node .Index ,
struct_init : Ast .full .StructInit ,
) InnerError !Zir .Inst .Ref {
const astgen = gz .astgen ;
const tree = astgen .tree ;
const payload_index = try addExtra (astgen , Zir .Inst .StructInitAnon {
.abs_node = node ,
.src_line = astgen .source_line ,
.src_column = astgen .source_column ,
.fields_len = @intCast (struct_init .ast .fields .len ),
});
const field_size = @typeInfo (Zir .Inst .StructInitAnon .Item ).@"struct" .field_names .len ;
var extra_index : usize = try reserveExtra (astgen , struct_init .ast .fields .len * field_size );
for (struct_init .ast .fields ) |field_init | {
const name_token = tree .firstToken (field_init ) - 2 ;
const str_index = try astgen .identAsString (name_token );
setExtra (astgen , extra_index , Zir .Inst .StructInitAnon .Item {
.field_name = str_index ,
.init = try expr (gz , scope , .{ .rl = .none }, field_init ),
});
extra_index += field_size ;
}
return gz .addPlNodePayloadIndex (.struct_init_anon , node , payload_index );
}
A struct initialization expression using a
struct_init_anoninstruction.