extraData
Returns the requested data, as well as the new index which is at the start of the trailers for the object.
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 extraData(code: Zir, comptime T: type, index: usize) ExtraData(T) {
const fields = @typeInfo(T).@"struct".fields;
var i: usize = index;
var result: T = undefined;
inline for (fields) |field| {
@field(result, field.name) = switch (field.type) {
u32 => code.extra[i],
Inst.Ref,
Inst.Index,
Inst.Declaration.Name,
std.zig.SimpleComptimeReason,
NullTerminatedString,
// Ast.TokenIndex is missing because it is a u32.
Ast.OptionalTokenIndex,
Ast.Node.Index,
Ast.Node.OptionalIndex,
=> @enumFromInt(code.extra[i]),
Ast.TokenOffset,
Ast.OptionalTokenOffset,
Ast.Node.Offset,
Ast.Node.OptionalOffset,
=> @enumFromInt(@as(i32, @bitCast(code.extra[i]))),
Inst.Call.Flags,
Inst.BuiltinCall.Flags,
Inst.SwitchBlock.Bits,
Inst.SwitchBlockErrUnion.Bits,
Inst.FuncFancy.Bits,
Inst.Declaration.Flags,
Inst.Param.Type,
Inst.Func.RetTy,
=> @bitCast(code.extra[i]),
else => @compileError("bad field type"),
};
i += 1;
}
return .{
.data = result,
.end = i,
};
}