Zig 0.17.0-dev (Split by item)

Shortcut keys
?
Show these tips
S
Focus search field
Esc
Clear focus & close tips
U
Jump to source code
↑
Move up in search results
↓
Move down in search results
↵
Go to active search result
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. Private Function

floatRoundOp

Private Function
std.zig.AstGen.floatRoundOp
fn floatRoundOp(
    gz: *GenZir,
    scope: *Scope,
    ri: ResultInfo,
    node: Ast.Node.Index,
    operand_node: Ast.Node.Index,
    float_tag: Zir.Inst.Tag,
) InnerError!Zir.Inst.Ref

Params

Errors

OutOfMemory
AnalysisFail

File

zig/AstGen.zig:9784
9784
9785
9786
9787
9788
9789
9790
9791
9792
9793
9794
9795
9796
9797
9798
9799
9800
9801
9802
9803
9804
9805
9806
9807
9808
9809
9810
9811
9812
9813
9814
9815
9816
9817
9818
9819
fn floatRoundOp(
    gz: *GenZir,
    scope: *Scope,
    ri: ResultInfo,
    node: Ast.Node.Index,
    operand_node: Ast.Node.Index,
    float_tag: Zir.Inst.Tag,
) InnerError!Zir.Inst.Ref {
    if (try ri.rl.resultType(gz, node)) |dest_type| {
        const cursor = maybeAdvanceSourceCursorToMainToken(gz, node);

        const operand_ty_inst = try gz.addExtendedPayload(.round_op_ty, Zir.Inst.UnNode{
            .node = gz.nodeIndexToRelative(node),
            .operand = dest_type,
        });

        const operand = try expr(gz, scope, .{ .rl = .{ .coerced_ty = operand_ty_inst } }, operand_node);

        try emitDbgStmt(gz, cursor);
        const round_op: Zir.Inst.RoundOp = switch (float_tag) {
            .round => .round,
            .floor => .floor,
            .ceil => .ceil,
            .trunc => .trunc,
            else => unreachable,
        };
        const result = try gz.addExtendedPayloadSmall(.round_op, @backingInt(round_op), Zir.Inst.BinNode{
            .node = gz.nodeIndexToRelative(node),
            .lhs = dest_type,
            .rhs = operand,
        });
        return rvalue(gz, ri, result, node);
    } else {
        return floatUnOp(gz, scope, ri, node, operand_node, float_tag);
    }
}