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

nameStratExpr

Private Function
std.zig.AstGen.nameStratExpr
fn nameStratExpr(
    gz: *GenZir,
    scope: *Scope,
    ri: ResultInfo,
    node: Ast.Node.Index,
    name_strat: Zir.Inst.NameStrategy,
) InnerError!?Zir.Inst.Ref

When a name strategy other than .anon is available, for instance when analyzing the init expr of a variable declaration, try this function before expr/comptimeExpr/etc, so that the name strategy can be applied if necessary. If null is returned, then node does not consume a name strategy, and a normal evaluation function like expr should be used instead. Otherwise, node does consume a name strategy; the expression has been evaluated like expr, but using the given name strategy.

Params

Errors

OutOfMemory
AnalysisFail

File

zig/AstGen.zig:1164
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
fn nameStratExpr(
    gz: *GenZir,
    scope: *Scope,
    ri: ResultInfo,
    node: Ast.Node.Index,
    name_strat: Zir.Inst.NameStrategy,
) InnerError!?Zir.Inst.Ref {
    const astgen = gz.astgen;
    const tree = astgen.tree;
    switch (tree.nodeTag(node)) {
        .container_decl,
        .container_decl_trailing,
        .container_decl_two,
        .container_decl_two_trailing,
        .container_decl_arg,
        .container_decl_arg_trailing,
        .tagged_union,
        .tagged_union_trailing,
        .tagged_union_two,
        .tagged_union_two_trailing,
        .tagged_union_enum_tag,
        .tagged_union_enum_tag_trailing,
        => {
            var buf: [2]Ast.Node.Index = undefined;
            return try containerDecl(gz, scope, ri, node, tree.fullContainerDecl(&buf, node).?, name_strat);
        },
        .builtin_call_two,
        .builtin_call_two_comma,
        .builtin_call,
        .builtin_call_comma,
        => {
            const builtin_token = tree.nodeMainToken(node);
            const builtin_name = tree.tokenSlice(builtin_token);
            const info = BuiltinFn.list.get(builtin_name) orelse return null;
            switch (info.tag) {
                .Enum, .Struct, .Union => {
                    var buf: [2]Ast.Node.Index = undefined;
                    const params = tree.builtinCallParams(&buf, node).?;
                    return try builtinCall(gz, scope, ri, node, params, false, name_strat);
                },
                else => return null,
            }
        },
        else => return null,
    }
}