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 › llvm › Builder › structConstAssumeCapacity Private Function structConstAssumeCapacity Doc Source Private Function std.zig.llvm.Builder.structConstAssumeCapacity
fn structConstAssumeCapacity (self : *Builder , ty : Type , vals : []const Constant ) Constant Params File zig/llvm/Builder.zig: 12530
12530
12531
12532
12533
12534
12535
12536
12537
12538
12539
12540
12541
12542
12543
12544
12545
12546
12547
12548
12549
12550
12551
12552
12553
12554
12555
12556
12557
12558 fn structConstAssumeCapacity (self : *Builder , ty : Type , vals : []const Constant ) Constant {
const type_item = self .type_items .items [@backingInt (ty )];
var extra = self .typeExtraDataTrail (Type .Structure , switch (type_item .tag ) {
.structure , .packed_structure => type_item .data ,
.named_structure => data : {
const body_ty = self .typeExtraData (Type .NamedStructure , type_item .data ).body ;
const body_item = self .type_items .items [@backingInt (body_ty )];
switch (body_item .tag ) {
.structure , .packed_structure => break :data body_item .data ,
else => unreachable ,
}
},
else => unreachable ,
});
const fields = extra .trail .next (extra .data .fields_len , Type , self );
for (fields , vals ) |field , val | assert (field == val .typeOf (self ));
for (vals ) |val | {
if (!val .isZeroInit (self )) break ;
} else return self .zeroInitConstAssumeCapacity (ty );
const tag : Constant .Tag = switch (ty .unnamedTag (self )) {
.structure => .structure ,
.packed_structure => .packed_structure ,
else => unreachable ,
};
const result = self .getOrPutConstantAggregateAssumeCapacity (tag , ty , vals );
return result .constant ;
}