feature. See also
. The project being documented here (as the example) is the Zig library itself.
Builder.zeroInitConstAssumeCapacity
fn zeroInitConstAssumeCapacity(self: *Builder, ty: Type) Constant
File
Code
fn zeroInitConstAssumeCapacity(self: *Builder, ty: Type) Constant {
switch (ty) {
inline .half,
.bfloat,
.float,
.double,
.fp128,
.x86_fp80,
=> |tag| return @field(Builder, @tagName(tag) ++ "ConstAssumeCapacity")(self, 0.0),
.ppc_fp128 => return self.ppc_fp128ConstAssumeCapacity(.{ 0.0, 0.0 }),
.token => return .none,
.i1 => return .false,
else => switch (self.type_items.items[@backingInt(ty)].tag) {
.simple,
.function,
.vararg_function,
=> unreachable,
.integer => {
var limbs: [std.math.big.int.calcLimbLen(0)]std.math.big.Limb = undefined;
const bigint = std.math.big.int.Mutable.init(&limbs, 0);
return self.bigIntConstAssumeCapacity(ty, bigint.toConst()) catch unreachable;
},
.pointer => return self.nullConstAssumeCapacity(ty),
.target,
.vector,
.scalable_vector,
.small_array,
.array,
.structure,
.packed_structure,
.named_structure,
=> {},
},
}
const result = self.getOrPutConstantNoExtraAssumeCapacity(
.{ .tag = .zeroinitializer, .data = @backingInt(ty) },
);
return result.constant;
}