fn fetchRemoveRefEntries(astgen: *AstGen, param_insts: []const Zir.Inst.Index) ![]Zir.Inst.Index 13612
13613
13614
13615
13616
13617
13618
13619
13620fn fetchRemoveRefEntries(astgen: *AstGen, param_insts: []const Zir.Inst.Index) ![]Zir.Inst.Index {
var refs: std.ArrayList(Zir.Inst.Index) = .empty;
for (param_insts) |param_inst| {
if (astgen.ref_table.fetchRemove(param_inst)) |kv| {
try refs.append(astgen.arena, kv.value);
}
}
return refs.items;
}
Given a list of instructions, returns a list of all instructions which are a
refof one of the originals, fromastgen.ref_table, non-recursively. The entries are removed fromastgen.ref_table, and the returned slice can then be treated as its own body, to appendrefinstructions to a body other than the one they would normally exist in.This is used when lowering functions. Very rarely, the callconv expression, align expression, etc may reference function parameters via
¶m; in this case, we need to lower to arefinstruction in the callconv/align/etc body, rather than in the declaration body. However, we don't append these bodies toextrauntil we've evaluated all of the bodies into a bigGenZirstack. Therefore, we use this function to pull out these per-bodyrefinstructions which must be emitted.