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 › BitcodeReader › parseBlockInfoBlock Private Function parseBlockInfoBlock Doc Source Private Function std.zig.llvm.BitcodeReader.parseBlockInfoBlock
fn parseBlockInfoBlock (bc : *BitcodeReader ) !void Params File zig/llvm/BitcodeReader.zig: 331
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375 fn parseBlockInfoBlock (bc : *BitcodeReader ) !void {
var block_id : ?u32 = null ;
while (true ) {
const record = (try bc .nextRecord ()) orelse return error .EndOfStream ;
switch (record .id ) {
Abbrev .Builtin .end_block .toRecordId () => break ,
Abbrev .Builtin .define_abbrev .toRecordId () => {
const gop = try bc .block_info .getOrPut (bc .allocator , block_id orelse
return error .UnspecifiedBlockId );
if (!gop .found_existing ) gop .value_ptr .* = Block .Info .default ;
try gop .value_ptr .abbrevs .addOwnedAbbrev (
bc .allocator ,
try record .toOwnedAbbrev (bc .allocator ),
);
},
Block .Info .set_bid_id => block_id = std .math .cast (u32 , record .operands [0 ]) orelse
return error .Overflow ,
Block .Info .block_name_id => if (bc .keep_names ) {
const gop = try bc .block_info .getOrPut (bc .allocator , block_id orelse
return error .UnspecifiedBlockId );
if (!gop .found_existing ) gop .value_ptr .* = Block .Info .default ;
const name = try bc .allocator .alloc (u8 , record .operands .len );
errdefer bc .allocator .free (name );
for (name , record .operands ) |*byte , operand |
byte .* = std .math .cast (u8 , operand ) orelse return error .InvalidName ;
gop .value_ptr .block_name = name ;
},
Block .Info .set_record_name_id => if (bc .keep_names ) {
const gop = try bc .block_info .getOrPut (bc .allocator , block_id orelse
return error .UnspecifiedBlockId );
if (!gop .found_existing ) gop .value_ptr .* = Block .Info .default ;
const name = try bc .allocator .alloc (u8 , record .operands .len - 1 );
errdefer bc .allocator .free (name );
for (name , record .operands [1 ..]) |*byte , operand |
byte .* = std .math .cast (u8 , operand ) orelse return error .InvalidName ;
try gop .value_ptr .record_names .put (
bc .allocator ,
std .math .cast (u32 , record .operands [0 ]) orelse return error .Overflow ,
name ,
);
},
else => return error .UnsupportedBlockInfoRecord ,
}
}
}