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/ › BitcodeReader.zig › readFixed
readFixed
BitcodeReader.readFixed
fn readFixed (bc : *BitcodeReader , comptime T : type , bits : u7 ) !T
File
Code
fn readFixed (bc : *BitcodeReader , comptime T : type , bits : u7 ) !T {
var result : T = 0 ;
var shift : std .math .Log2IntCeil (T ) = 0 ;
var remaining = bits ;
while (remaining > 0 ) {
if (bc .bit_offset == 0 ) bc .bit_buffer = try bc .read32Bits ();
const chunk_len = @min (@as (u6 , 32 ) - bc .bit_offset , remaining );
const chunk_mask = @as (u32 , std .math .maxInt (u32 )) >> @intCast (32 - chunk_len );
result |= @as (T , @intCast (bc .bit_buffer >> bc .bit_offset & chunk_mask )) << @intCast (shift );
shift += @intCast (chunk_len );
remaining -= chunk_len ;
bc .bit_offset = @truncate (bc .bit_offset + chunk_len );
}
return result ;
}