typeCapturesLen
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 typeCapturesLen(zir: Zir, type_decl: Inst.Index) u32 {
const inst = zir.instructions.get(@intFromEnum(type_decl));
assert(inst.tag == .extended);
switch (inst.data.extended.opcode) {
.struct_decl => {
const small: Inst.StructDecl.Small = @bitCast(inst.data.extended.small);
if (!small.has_captures_len) return 0;
const extra = zir.extraData(Inst.StructDecl, inst.data.extended.operand);
return zir.extra[extra.end];
},
.union_decl => {
const small: Inst.UnionDecl.Small = @bitCast(inst.data.extended.small);
if (!small.has_captures_len) return 0;
const extra = zir.extraData(Inst.UnionDecl, inst.data.extended.operand);
return zir.extra[extra.end + @intFromBool(small.has_tag_type)];
},
.enum_decl => {
const small: Inst.EnumDecl.Small = @bitCast(inst.data.extended.small);
if (!small.has_captures_len) return 0;
const extra = zir.extraData(Inst.EnumDecl, inst.data.extended.operand);
return zir.extra[extra.end + @intFromBool(small.has_tag_type)];
},
.opaque_decl => {
const small: Inst.OpaqueDecl.Small = @bitCast(inst.data.extended.small);
if (!small.has_captures_len) return 0;
const extra = zir.extraData(Inst.OpaqueDecl, inst.data.extended.operand);
return zir.extra[extra.end];
},
else => unreachable,
}
}