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.

emitDbgStmtForceCurrentIndex

In some cases, Sema expects us to generate a dbg_stmt at the instruction index directly preceding the next instruction (e.g. if a call is %10, it expects a dbg_stmt at %9). TODO: this logic may allow redundant dbg_stmt instructions; fix up Sema so we don't need it!

AstGen.emitDbgStmtForceCurrentIndex
fn emitDbgStmtForceCurrentIndex(gz: *GenZir, lc: LineColumn) !void

File

lib/std/zig/AstGen.zig:13249

Code

fn emitDbgStmtForceCurrentIndex(gz: *GenZir, lc: LineColumn) !void {
    const astgen = gz.astgen;
    if (gz.instructions.items.len > gz.instructions_top and
        @backingInt(gz.instructions.items[gz.instructions.items.len - 1]) == astgen.instructions.len - 1)
    {
        const last = astgen.instructions.len - 1;
        if (astgen.instructions.items(.tag)[last] == .dbg_stmt) {
            astgen.instructions.items(.data)[last].dbg_stmt = .{
                .line = lc[0],
                .column = lc[1],
            };
            return;
        }
    }

    _ = try gz.add(.{ .tag = .dbg_stmt, .data = .{
        .dbg_stmt = .{
            .line = lc[0],
            .column = lc[1],
        },
    } });
}