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.

isFnBodyGutted

Check if it is already gutted (i.e. its body replaced with @trap()).

Walk.isFnBodyGutted
fn isFnBodyGutted(ast: *const Ast, body_node: Ast.Node.Index) bool

File

Code

fn isFnBodyGutted(ast: *const Ast, body_node: Ast.Node.Index) bool {
    // skip over discards
    var statements_buf: [2]Ast.Node.Index = undefined;
    const statements = switch (ast.nodeTag(body_node)) {
        .block_two,
        .block_two_semicolon,
        .block,
        .block_semicolon,
        => ast.blockStatements(&statements_buf, body_node).?,

        else => return false,
    };
    var i: usize = 0;
    while (i < statements.len) : (i += 1) {
        switch (categorizeStmt(ast, statements[i])) {
            .discard_identifier => continue,
            .trap_call => return i + 1 == statements.len,
            else => return false,
        }
    }
    return false;
}