Function assertTrackable [src]
Asserts that a ZIR instruction is tracked across incremental updates, and
thus may be given an InternPool.TrackedInst.
Prototype
pub fn assertTrackable(zir: Zir, inst_idx: Zir.Inst.Index) void
Parameters
zir: Zir
inst_idx: Zir.Inst.Index
Source
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
}
}