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 library itself.

transSwitchProngStmt

Collects all statements seen by this case into a block. Avoids creating a block if the first statement is a break or return.

Translator.transSwitchProngStmt
fn transSwitchProngStmt(
    t: *Translator,
    scope: *Scope,
    stmt: Node.Index,
    body: []const Node.Index,
) TransError!ZigNode

File

lib/compiler/translate-c/Translator.zig:2059

Code

fn transSwitchProngStmt(
    t: *Translator,
    scope: *Scope,
    stmt: Node.Index,
    body: []const Node.Index,
) TransError!ZigNode {
    switch (stmt.get(t.tree)) {
        .case_stmt, .default_stmt => unreachable,
        else => {
            var block_scope = try Scope.Block.init(t, scope, false);
            defer block_scope.deinit();

            // we do not need to translate `stmt` since it is the first stmt of `body`
            try t.transSwitchProngStmtInline(&block_scope, body);
            return try block_scope.complete();
        },
    }
}