| 166 | } // anonymous namespace |
| 167 | |
| 168 | spv_result_t BinaryToDot(const spv_const_context context, const uint32_t* words, |
| 169 | size_t num_words, std::iostream* out, |
| 170 | spv_diagnostic* diagnostic) { |
| 171 | // Invalid arguments return error codes, but don't necessarily generate |
| 172 | // diagnostics. These are programmer errors, not user errors. |
| 173 | if (!diagnostic) return SPV_ERROR_INVALID_DIAGNOSTIC; |
| 174 | const spvtools::AssemblyGrammar grammar(context); |
| 175 | |
| 176 | spvtools::FriendlyNameMapper friendly_mapper(context, words, num_words); |
| 177 | DotConverter converter(friendly_mapper.GetNameMapper(), out); |
| 178 | converter.Begin(); |
| 179 | if (auto error = spvBinaryParse(context, &converter, words, num_words, |
| 180 | nullptr, HandleInstruction, diagnostic)) { |
| 181 | return error; |
| 182 | } |
| 183 | converter.End(); |
| 184 | |
| 185 | return SPV_SUCCESS; |
| 186 | } |
no test coverage detected