| ... | @@ -130,6 +130,11 @@ pub const String = enum(u32) { | ... | @@ -130,6 +130,11 @@ pub const String = enum(u32) { |
| 130 | }; | 130 | }; |
| 131 | }; | 131 | }; |
| 132 | | 132 | |
| | 133 | pub const StrtabString = struct { |
| | 134 | offset: usize, |
| | 135 | size: usize, |
| | 136 | }; |
| | 137 | |
| 133 | pub const Type = enum(u32) { | 138 | pub const Type = enum(u32) { |
| 134 | void, | 139 | void, |
| 135 | half, | 140 | half, |
| ... | @@ -2159,6 +2164,18 @@ pub const Global = struct { | ... | @@ -2159,6 +2164,18 @@ pub const Global = struct { |
| 2159 | return builder.globals.keys()[@intFromEnum(self.unwrap(builder))]; | 2164 | return builder.globals.keys()[@intFromEnum(self.unwrap(builder))]; |
| 2160 | } | 2165 | } |
| 2161 | | 2166 | |
| | 2167 | pub fn strtab(self: Index, builder: *const Builder) StrtabString { |
| | 2168 | const name_index = self.name(builder).toIndex() orelse return .{ |
| | 2169 | .offset = 0, |
| | 2170 | .size = 0, |
| | 2171 | }; |
| | 2172 | |
| | 2173 | return .{ |
| | 2174 | .offset = builder.string_indices.items[name_index], |
| | 2175 | .size = builder.string_indices.items[name_index + 1] - builder.string_indices.items[name_index] - 1, |
| | 2176 | }; |
| | 2177 | } |
| | 2178 | |
| 2162 | pub fn typeOf(self: Index, builder: *const Builder) Type { | 2179 | pub fn typeOf(self: Index, builder: *const Builder) Type { |
| 2163 | return self.ptrConst(builder).type; | 2180 | return self.ptrConst(builder).type; |
| 2164 | } | 2181 | } |