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

renderBuiltinCall

Private Function
std.zig.Ast.Render.renderBuiltinCall
fn renderBuiltinCall(
    r: *Render,
    builtin_token: Ast.TokenIndex,
    params: []const Ast.Node.Index,
    space: Space,
) Error!void

Params

Errors

OutOfMemory

Ran out of memory allocating call stack frames to complete rendering.

WriteFailed

Transitive failure from

File

zig/Ast/Render.zig:1646
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
fn renderBuiltinCall(
    r: *Render,
    builtin_token: Ast.TokenIndex,
    params: []const Ast.Node.Index,
    space: Space,
) Error!void {
    const tree = r.tree;
    const ais = r.ais;

    // remove before 0.18.0 is released
    const builtin_token_slice = tree.tokenSlice(builtin_token); // @name
    const lexeme: []const u8, const have_int_cast: bool = lexeme: {
        if (mem.eql(u8, builtin_token_slice, "@intFromEnum"))
            break :lexeme .{ "@backingInt", false };
        if (mem.eql(u8, builtin_token_slice, "@enumFromInt"))
            break :lexeme .{ "@fromBackingInt(@intCast", true };
        break :lexeme .{ builtin_token_slice, false };
    };
    try ais.writeAll(lexeme);
    try renderSpace(r, builtin_token, builtin_token_slice.len, .none);

    if (r.fixups.rebase_imported_paths) |prefix| {
        const slice = tree.tokenSlice(builtin_token);
        if (params.len != 0 and mem.eql(u8, slice, "@import")) f: {
            const param = params[0];
            const str_lit_token = tree.nodeMainToken(param);
            assert(tree.tokenTag(str_lit_token) == .string_literal);
            const token_bytes = tree.tokenSlice(str_lit_token);
            const imported_string = std.zig.string_literal.parseAlloc(r.gpa, token_bytes) catch |err| switch (err) {
                error.OutOfMemory => |e| return e,
                error.InvalidLiteral => break :f,
            };
            defer r.gpa.free(imported_string);
            const new_string = try std.fs.path.resolvePosix(r.gpa, &.{ prefix, imported_string });
            defer r.gpa.free(new_string);

            try renderToken(r, builtin_token + 1, .none); // (
            try ais.print("\"{f}\"", .{std.zig.fmtString(new_string)});
            return renderToken(r, str_lit_token + 1, space); // )
        }
    }

    try renderParamList(r, builtin_token + 1, params, .skip); // space is rendered below
    if (have_int_cast) try ais.writeAll(")");
    const rparen: Ast.TokenIndex = rparen: {
        if (params.len == 0) break :rparen builtin_token + 1 + 1;
        const after_last_param_tok = tree.lastToken(params[params.len - 1]) + 1;
        break :rparen after_last_param_tok + @intFromBool(tree.tokenTag(after_last_param_tok) == .comma);
    };
    return renderSpace(r, rparen, tokenSliceForRender(tree, rparen).len, space);
}