feature. See also
. The project being documented here (as the example) is the Zig library itself.
AstGen.setExtra
fn setExtra(astgen: *AstGen, index: usize, extra: anytype) void
File
Code
fn setExtra(astgen: *AstGen, index: usize, extra: anytype) void {
const info = @typeInfo(@TypeOf(extra)).@"struct";
var i = index;
inline for (info.field_names, info.field_types) |field_name, field_type| {
astgen.extra.items[i] = switch (field_type) {
u32 => @field(extra, field_name),
Zir.Inst.Ref,
Zir.Inst.Index,
Zir.Inst.Declaration.Name,
std.zig.SimpleComptimeReason,
Zir.NullTerminatedString,
Ast.OptionalTokenIndex,
Ast.Node.Index,
Ast.Node.OptionalIndex,
=> @backingInt(@field(extra, field_name)),
Ast.TokenOffset,
Ast.OptionalTokenOffset,
Ast.Node.Offset,
Ast.Node.OptionalOffset,
=> @bitCast(@backingInt(@field(extra, field_name))),
i32,
Zir.Inst.Call.Flags,
Zir.Inst.BuiltinCall.Flags,
Zir.Inst.SwitchBlock.Bits,
Zir.Inst.FuncFancy.Bits,
Zir.Inst.Param.Type,
Zir.Inst.Func.RetTy,
=> @bitCast(@field(extra, field_name)),
else => @compileError("bad field type"),
};
i += 1;
}
}