| ... | @@ -181,6 +181,27 @@ pub fn flushModule(self: *SpirV, comp: *Compilation, prog_node: *std.Progress.No | ... | @@ -181,6 +181,27 @@ pub fn flushModule(self: *SpirV, comp: *Compilation, prog_node: *std.Progress.No |
| 181 | try writeCapabilities(&self.spv, target); | 181 | try writeCapabilities(&self.spv, target); |
| 182 | try writeMemoryModel(&self.spv, target); | 182 | try writeMemoryModel(&self.spv, target); |
| 183 | | 183 | |
| | 184 | // We need to export the list of error names somewhere so that we can pretty-print them in the |
| | 185 | // executor. This is not really an important thing though, so we can just dump it in any old |
| | 186 | // nonsemantic instruction. For now, just put it in OpSourceExtension with a special name. |
| | 187 | |
| | 188 | var error_info = std.ArrayList(u8).init(self.spv.arena); |
| | 189 | try error_info.appendSlice("zig_errors"); |
| | 190 | const module = self.base.options.module.?; |
| | 191 | for (module.error_name_list.items) |name| { |
| | 192 | // Errors can contain pretty much any character - to encode them in a string we must escape |
| | 193 | // them somehow. Easiest here is to use some established scheme, one which also preseves the |
| | 194 | // name if it contains no strange characters is nice for debugging. URI encoding fits the bill. |
| | 195 | // We're using : as separator, which is a reserved character. |
| | 196 | |
| | 197 | const escaped_name = try std.Uri.escapeString(self.base.allocator, name); |
| | 198 | defer self.base.allocator.free(escaped_name); |
| | 199 | try error_info.writer().print(":{s}", .{escaped_name}); |
| | 200 | } |
| | 201 | try self.spv.sections.debug_strings.emit(self.spv.gpa, .OpSourceExtension, .{ |
| | 202 | .extension = error_info.items, |
| | 203 | }); |
| | 204 | |
| 184 | try self.spv.flush(self.base.file.?); | 205 | try self.spv.flush(self.base.file.?); |
| 185 | } | 206 | } |
| 186 | | 207 | |