feature. See also
. The project being documented here (as the example) is the Zig library itself.
AstGen.boolBinOp
fn boolBinOp(
gz: *GenZir,
scope: *Scope,
ri: ResultInfo,
node: Ast.Node.Index,
zir_tag: Zir.Inst.Tag,
) InnerError!Zir.Inst.Ref
File
Code
fn boolBinOp(
gz: *GenZir,
scope: *Scope,
ri: ResultInfo,
node: Ast.Node.Index,
zir_tag: Zir.Inst.Tag,
) InnerError!Zir.Inst.Ref {
const astgen = gz.astgen;
const tree = astgen.tree;
const lhs_node, const rhs_node = tree.nodeData(node).node_and_node;
const lhs = try expr(gz, scope, coerced_bool_ri, lhs_node);
const bool_br = (try gz.addPlNodePayloadIndex(zir_tag, node, undefined)).toIndex().?;
var rhs_scope = gz.makeSubBlock(scope);
defer rhs_scope.unstack();
const rhs = try fullBodyExpr(&rhs_scope, &rhs_scope.base, coerced_bool_ri, rhs_node, .allow_branch_hint);
if (!gz.refIsNoReturn(rhs)) {
_ = try rhs_scope.addBreakWithSrcNode(.break_inline, bool_br, rhs, rhs_node);
}
try rhs_scope.setBoolBrBody(bool_br, lhs);
const block_ref = bool_br.toRef();
return rvalue(gz, ri, block_ref, node);
}