assertTrackable
Asserts that a ZIR instruction is tracked across incremental updates, and
thus may be given an InternPool.TrackedInst.
Function parameters
Parameters
The data stored at byte offset 0 when ZIR is stored in a file.
Types
- Header
- The data stored at byte offset 0 when ZIR is stored in a file.
- Inst
- These are untyped instructions generated from an Abstract Syntax Tree.
- DeclContents
- `DeclContents` contains all "interesting" instructions found within a declaration by `findTrackable`.
Returns the requested data, as well as the new index which is at the start of the
Functions
- extraData
- Returns the requested data, as well as the new index which is at the start of the
- nullTerminatedString
- Given an index into `string_bytes` returns the null-terminated string found there.
- findTrackable
- Find all tracked ZIR instructions, recursively, within a `declaration` instruction.
- findTrackableRoot
- Like `findTrackable`, but only considers the `main_struct_inst` instruction.
- assertTrackable
- Asserts that a ZIR instruction is tracked across incremental updates, and
When the ZIR update tracking logic must be modified to consider new instructions,
Values
- inst_tracking_version
- When the ZIR update tracking logic must be modified to consider new instructions,
Source
Implementation
pub fn assertTrackable(zir: Zir, inst_idx: Zir.Inst.Index) void {
comptime assert(Zir.inst_tracking_version == 0);
const inst = zir.instructions.get(@intFromEnum(inst_idx));
switch (inst.tag) {
.struct_init,
.struct_init_ref,
.struct_init_anon,
=> {}, // tracked in order, as the owner instructions of anonymous struct types
.func, .func_inferred => {
// These are tracked provided they are actual function declarations, not just bodies.
const extra = zir.extraData(Inst.Func, inst.data.pl_node.payload_index);
assert(extra.data.body_len != 0);
},
.func_fancy => {
// These are tracked provided they are actual function declarations, not just bodies.
const extra = zir.extraData(Inst.FuncFancy, inst.data.pl_node.payload_index);
assert(extra.data.body_len != 0);
},
.declaration => {}, // tracked by correlating names in the namespace of the parent container
.extended => switch (inst.data.extended.opcode) {
.struct_decl,
.union_decl,
.enum_decl,
.opaque_decl,
.reify,
=> {}, // tracked in order, as the owner instructions of explicit container types
else => unreachable, // assertion failure; not trackable
},
else => unreachable, // assertion failure; not trackable
}
}