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/ › llvm/ › Builder.zig › arrayConstAssumeCapacity
arrayConstAssumeCapacity
Builder.arrayConstAssumeCapacity
fn arrayConstAssumeCapacity (self : *Builder , ty : Type , vals : []const Constant ) Constant
File
Code
fn arrayConstAssumeCapacity (self : *Builder , ty : Type , vals : []const Constant ) Constant {
const type_item = self .type_items .items [@backingInt (ty )];
const type_extra : struct { len : u64 , child : Type } = switch (type_item .tag ) {
inline .small_array , .array => |kind | extra : {
const extra = self .typeExtraData (switch (kind ) {
.small_array => Type .Vector ,
.array => Type .Array ,
else => unreachable ,
}, type_item .data );
break :extra .{ .len = extra .length (), .child = extra .child };
},
else => unreachable ,
};
assert (type_extra .len == vals .len );
for (vals ) |val | assert (type_extra .child == val .typeOf (self ));
for (vals ) |val | {
if (!val .isZeroInit (self )) break ;
} else return self .zeroInitConstAssumeCapacity (ty );
const result = self .getOrPutConstantAggregateAssumeCapacity (.array , ty , vals );
return result .constant ;
}