pub const Subprogram = struct {
pub const Options = struct {
di_flags: DIFlags,
sp_flags: DISPFlags,
};
pub const DISPFlags = packed struct(u32) {
Virtuality: enum(u2) { Zero, Virtual, PureVirtual } = .Zero,
LocalToUnit: bool = false,
Definition: bool = false,
Optimized: bool = false,
Pure: bool = false,
Elemental: bool = false,
Recursive: bool = false,
MainSubprogram: bool = false,
Deleted: bool = false,
ReservedBit10: u1 = 0,
ObjCDirect: bool = false,
Unused: u20 = 0,
pub fn format(self: DISPFlags, w: *Writer) Writer.Error!void {
var need_pipe = false;
const info = @typeInfo(DISPFlags).@"struct";
inline for (info.field_names, info.field_types) |field_name, field_type| {
switch (@typeInfo(field_type)) {
.bool => if (@field(self, field_name)) {
if (need_pipe) try w.writeAll(" | ") else need_pipe = true;
try w.print("DISPFlag{s}", .{field_name});
},
.@"enum" => if (@field(self, field_name) != .Zero) {
if (need_pipe) try w.writeAll(" | ") else need_pipe = true;
try w.print("DISPFlag{s}", .{@tagName(@field(self, field_name))});
},
.int => assert(@field(self, field_name) == 0),
else => @compileError("bad field type: " ++ field_name ++ ": " ++
@typeName(field_type)),
}
}
if (!need_pipe) try w.writeByte('0');
}
};
file: Metadata.Optional,
name: Metadata.String.Optional,
linkage_name: Metadata.String.Optional,
line: u32,
scope_line: u32,
ty: Metadata.Optional,
di_flags: DIFlags,
compile_unit: Metadata.Optional,
}