feature. See also
. The project being documented here (as the example) is the Zig library itself.
AstGen.shiftOp
fn shiftOp(
gz: *GenZir,
scope: *Scope,
ri: ResultInfo,
node: Ast.Node.Index,
lhs_node: Ast.Node.Index,
rhs_node: Ast.Node.Index,
tag: Zir.Inst.Tag,
) InnerError!Zir.Inst.Ref
File
Code
fn shiftOp(
gz: *GenZir,
scope: *Scope,
ri: ResultInfo,
node: Ast.Node.Index,
lhs_node: Ast.Node.Index,
rhs_node: Ast.Node.Index,
tag: Zir.Inst.Tag,
) InnerError!Zir.Inst.Ref {
const lhs = try expr(gz, scope, .{ .rl = .none }, lhs_node);
const cursor = switch (gz.astgen.tree.nodeTag(node)) {
.shl, .shr => maybeAdvanceSourceCursorToMainToken(gz, node),
else => undefined,
};
const log2_int_type = try gz.addUnNode(.typeof_log2_int_type, lhs, lhs_node);
const rhs = try expr(gz, scope, .{ .rl = .{ .ty = log2_int_type }, .ctx = .shift_op }, rhs_node);
switch (gz.astgen.tree.nodeTag(node)) {
.shl, .shr => try emitDbgStmt(gz, cursor),
else => undefined,
}
const result = try gz.addPlNode(tag, node, Zir.Inst.Bin{
.lhs = lhs,
.rhs = rhs,
});
return rvalue(gz, ri, result, node);
}