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 › AstGen › assignShiftSat Private Function assignShiftSat Doc Source Private Function std.zig.AstGen.assignShiftSat
fn assignShiftSat (gz : *GenZir , scope : *Scope , infix_node : Ast .Node .Index ) InnerError !void Params Errors File zig/AstGen.zig: 3723
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742 fn assignShiftSat (gz : *GenZir , scope : *Scope , infix_node : Ast .Node .Index ) InnerError !void {
try emitDbgNode (gz , infix_node );
const astgen = gz .astgen ;
const tree = astgen .tree ;
const lhs_node , const rhs_node = tree .nodeData (infix_node ).node_and_node ;
const lhs_ptr = try lvalExpr (gz , scope , lhs_node );
const lhs = try gz .addUnNode (.load , lhs_ptr , infix_node );
// Saturating shift-left allows any integer type for both the LHS and RHS.
const rhs = try expr (gz , scope , .{ .rl = .none }, rhs_node );
const result = try gz .addPlNode (.shl_sat , infix_node , Zir .Inst .Bin {
.lhs = lhs ,
.rhs = rhs ,
});
_ = try gz .addPlNode (.store_node , infix_node , Zir .Inst .Bin {
.lhs = lhs_ptr ,
.rhs = result ,
});
}