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 › doubleConstAssumeCapacity Private Function doubleConstAssumeCapacity Doc Source Private Function std.zig.llvm.Builder.doubleConstAssumeCapacity
fn doubleConstAssumeCapacity (self : *Builder , val : f64 ) Constant Params File zig/llvm/Builder.zig: 12382
12382
12383
12384
12385
12386
12387
12388
12389
12390
12391
12392
12393
12394
12395
12396
12397
12398
12399
12400
12401
12402
12403
12404
12405
12406
12407
12408
12409
12410
12411 fn doubleConstAssumeCapacity (self : *Builder , val : f64 ) Constant {
const Adapter = struct {
builder : *const Builder ,
pub fn hash (_ : @This (), key : f64 ) u32 {
return @truncate (std .hash .Wyhash .hash (
comptime std .hash .int (@backingInt (Constant .Tag .double )),
std .mem .asBytes (&key ),
));
}
pub fn eql (ctx : @This (), lhs_key : f64 , _ : void , rhs_index : usize ) bool {
if (ctx .builder .constant_items .items (.tag )[rhs_index ] != .double ) return false ;
const rhs_data = ctx .builder .constant_items .items (.data )[rhs_index ];
const rhs_extra = ctx .builder .constantExtraData (Constant .Double , rhs_data );
return @as (u64 , @bitCast (lhs_key )) == @as (u64 , rhs_extra .hi ) << 32 | rhs_extra .lo ;
}
};
const gop = self .constant_map .getOrPutAssumeCapacityAdapted (val , Adapter { .builder = self });
if (!gop .found_existing ) {
gop .key_ptr .* = {};
gop .value_ptr .* = {};
self .constant_items .appendAssumeCapacity (.{
.tag = .double ,
.data = self .addConstantExtraAssumeCapacity (Constant .Double {
.lo = @truncate (@as (u64 , @bitCast (val ))),
.hi = @intCast (@as (u64 , @bitCast (val )) >> 32 ),
}),
});
}
return @fromBackingInt (@intCast (gop .index ));
}