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 › Zir › getParamBody Public Function getParamBody Doc Source Public Function std.zig.Zir.getParamBody
pub fn getParamBody (zir : Zir , fn_inst : Inst .Index ) []const Zir .Inst .Index Params File zig/Zir.zig: 4669
4669
4670
4671
4672
4673
4674
4675
4676
4677
4678
4679
4680
4681
4682
4683
4684
4685
4686
4687
4688
4689
4690
4691
4692
4693
4694
4695
4696 pub fn getParamBody (zir : Zir , fn_inst : Inst .Index ) []const Zir .Inst .Index {
const tags = zir .instructions .items (.tag );
const datas = zir .instructions .items (.data );
const inst_data = datas [@backingInt (fn_inst )].pl_node ;
const param_block_index = switch (tags [@backingInt (fn_inst )]) {
.func , .func_inferred => blk : {
const extra = zir .extraData (Inst .Func , inst_data .payload_index );
break :blk extra .data .param_block ;
},
.func_fancy => blk : {
const extra = zir .extraData (Inst .FuncFancy , inst_data .payload_index );
break :blk extra .data .param_block ;
},
else => unreachable ,
};
switch (tags [@backingInt (param_block_index )]) {
.block , .block_comptime , .block_inline => {
const param_block = zir .extraData (Inst .Block , datas [@backingInt (param_block_index )].pl_node .payload_index );
return zir .bodySlice (param_block .end , param_block .data .body_len );
},
.declaration => {
return zir .getDeclaration (param_block_index ).value_body .?;
},
else => unreachable ,
}
}