feature. See also
. The project being documented here (as the example) is the Zig library itself.
Builder.constantExtraDataTrail
fn constantExtraDataTrail(
self: *const Builder,
comptime T: type,
index: Constant.Item.ExtraIndex,
) struct
File
Code
fn constantExtraDataTrail(
self: *const Builder,
comptime T: type,
index: Constant.Item.ExtraIndex,
) struct { data: T, trail: ConstantExtraDataTrail } {
var result: T = undefined;
const info = @typeInfo(T).@"struct";
inline for (
info.field_names,
info.field_types,
self.constant_extra.items[index..][0..info.field_names.len],
) |field_name, field_type, value|
@field(result, field_name) = switch (field_type) {
u32 => value,
String, Type, Constant, Function.Index, Function.Block.Index => @fromBackingInt(@intCast(value)),
Constant.GetElementPtr.Info => @bitCast(value),
else => @compileError("bad field type: " ++ @typeName(field_type)),
};
return .{
.data = result,
.trail = .{ .index = index + @as(Constant.Item.ExtraIndex, @intCast(info.field_names.len)) },
};
}