| ... | ... | @@ -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 | 138 | pub const Type = enum(u32) { |
| 134 | 139 | void, |
| 135 | 140 | half, |
| ... | ... | @@ -2159,6 +2164,18 @@ pub const Global = struct { |
| 2159 | 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 | 2179 | pub fn typeOf(self: Index, builder: *const Builder) Type { |
| 2163 | 2180 | return self.ptrConst(builder).type; |
| 2164 | 2181 | } |