mirror of
https://github.com/ziglang/zig.git
synced 2025-12-24 23:23:07 +00:00
LLVM Builder: Add strtab helper to String
This commit is contained in:
parent
9ccd7158b9
commit
2801bf6400
@ -130,6 +130,11 @@ pub const String = enum(u32) {
|
||||
};
|
||||
};
|
||||
|
||||
pub const StrtabString = struct {
|
||||
offset: usize,
|
||||
size: usize,
|
||||
};
|
||||
|
||||
pub const Type = enum(u32) {
|
||||
void,
|
||||
half,
|
||||
@ -2159,6 +2164,18 @@ pub const Global = struct {
|
||||
return builder.globals.keys()[@intFromEnum(self.unwrap(builder))];
|
||||
}
|
||||
|
||||
pub fn strtab(self: Index, builder: *const Builder) StrtabString {
|
||||
const name_index = self.name(builder).toIndex() orelse return .{
|
||||
.offset = 0,
|
||||
.size = 0,
|
||||
};
|
||||
|
||||
return .{
|
||||
.offset = builder.string_indices.items[name_index],
|
||||
.size = builder.string_indices.items[name_index + 1] - builder.string_indices.items[name_index] - 1,
|
||||
};
|
||||
}
|
||||
|
||||
pub fn typeOf(self: Index, builder: *const Builder) Type {
|
||||
return self.ptrConst(builder).type;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user