mirror of
https://github.com/ziglang/zig.git
synced 2026-02-14 13:30:45 +00:00
Builder: implement opaque structs in bitcode
This commit is contained in:
parent
43daed64fe
commit
6abb432598
@ -13015,18 +13015,23 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co
|
||||
.string = extra.id.slice(self).?,
|
||||
});
|
||||
|
||||
const real_struct = self.type_items.items[@intFromEnum(extra.body)];
|
||||
const is_packed: bool = switch (real_struct.tag) {
|
||||
.structure => false,
|
||||
.packed_structure => true,
|
||||
else => unreachable,
|
||||
};
|
||||
switch (extra.body) {
|
||||
.none => try type_block.writeAbbrev(ir.Type.Opaque{}),
|
||||
else => {
|
||||
const real_struct = self.type_items.items[@intFromEnum(extra.body)];
|
||||
const is_packed: bool = switch (real_struct.tag) {
|
||||
.structure => false,
|
||||
.packed_structure => true,
|
||||
else => unreachable,
|
||||
};
|
||||
|
||||
var real_extra = self.typeExtraDataTrail(Type.Structure, real_struct.data);
|
||||
try type_block.writeAbbrev(ir.Type.StructNamed{
|
||||
.is_packed = is_packed,
|
||||
.types = real_extra.trail.next(real_extra.data.fields_len, Type, self),
|
||||
});
|
||||
var real_extra = self.typeExtraDataTrail(Type.Structure, real_struct.data);
|
||||
try type_block.writeAbbrev(ir.Type.StructNamed{
|
||||
.is_packed = is_packed,
|
||||
.types = real_extra.trail.next(real_extra.data.fields_len, Type, self),
|
||||
});
|
||||
},
|
||||
}
|
||||
},
|
||||
.array,
|
||||
.small_array,
|
||||
|
||||
@ -188,6 +188,7 @@ pub const Type = struct {
|
||||
pub const abbrevs = [_]type{
|
||||
NumEntry,
|
||||
Simple,
|
||||
Opaque,
|
||||
Integer,
|
||||
StructAnon,
|
||||
StructNamed,
|
||||
@ -214,6 +215,13 @@ pub const Type = struct {
|
||||
code: u5,
|
||||
};
|
||||
|
||||
pub const Opaque = struct {
|
||||
pub const ops = [_]AbbrevOp{
|
||||
.{ .literal = 6 },
|
||||
.{ .literal = 0 },
|
||||
};
|
||||
};
|
||||
|
||||
pub const Integer = struct {
|
||||
pub const ops = [_]AbbrevOp{
|
||||
.{ .literal = 7 },
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user