Given a list of instructions, returns a list of all instructions which are a ref of one of the originals,
from astgen.ref_table, non-recursively. The entries are removed from astgen.ref_table, and the returned
slice can then be treated as its own body, to append ref instructions 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 a ref instruction in the callconv/align/etc
body, rather than in the declaration body. However, we don't append these bodies to extra until we've evaluated
all of the bodies into a big GenZir stack. Therefore, we use this function to pull out these per-body ref
instructions which must be emitted.
fn fetchRemoveRefEntries(astgen: *AstGen, param_insts: []const Zir.Inst.Index) ![]Zir.Inst.Index
fn 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;
}