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 Struct

LocalPtr

Private Struct
std.zig.AstGen.Scope.LocalPtr
const LocalPtr = struct

This could be a const or var local. It has a pointer instead of a value. This structure lives as long as the AST generation of the Block node that contains the variable.

Fields

base: Scope = Scope{ .tag = base_tag }
parent: *Scope

Parents can be: LocalVal, LocalPtr, GenZir, Defer, Namespace.

gen_zir: *GenZir
ptr: Zir.Inst.Ref
token_src: Ast.TokenIndex

Source location of the corresponding variable declaration.

used: Ast.OptionalTokenIndex = .none

Track the first identifier where it is referenced. .none means never referenced.

discarded: Ast.OptionalTokenIndex = .none

Track the identifier where it is discarded, like this _ = foo;. .none means never discarded.

used_as_lvalue: bool = false

Whether this value is used as an lvalue after initialization. If not, we know it can be const, so will emit a compile error if it is var.

name: Zir.NullTerminatedString

String table index.

id_cat: IdCat
maybe_comptime: bool

true means we find out during Sema whether the value is comptime. false means it is already known at AstGen the value is runtime-known.

Values

File

zig/AstGen.zig:11170
11170
11171
11172
11173
11174
11175
11176
11177
11178
11179
11180
11181
11182
11183
11184
11185
11186
11187
11188
11189
11190
11191
11192
11193
11194
    const LocalPtr = struct {
        const base_tag: Tag = .local_ptr;
        base: Scope = Scope{ .tag = base_tag },
        /// Parents can be: `LocalVal`, `LocalPtr`, `GenZir`, `Defer`, `Namespace`.
        parent: *Scope,
        gen_zir: *GenZir,
        ptr: Zir.Inst.Ref,
        /// Source location of the corresponding variable declaration.
        token_src: Ast.TokenIndex,
        /// Track the first identifier where it is referenced.
        /// .none means never referenced.
        used: Ast.OptionalTokenIndex = .none,
        /// Track the identifier where it is discarded, like this `_ = foo;`.
        /// .none means never discarded.
        discarded: Ast.OptionalTokenIndex = .none,
        /// Whether this value is used as an lvalue after initialization.
        /// If not, we know it can be `const`, so will emit a compile error if it is `var`.
        used_as_lvalue: bool = false,
        /// String table index.
        name: Zir.NullTerminatedString,
        id_cat: IdCat,
        /// true means we find out during Sema whether the value is comptime.
        /// false means it is already known at AstGen the value is runtime-known.
        maybe_comptime: bool,
    }