| 974 | } |
| 975 | |
| 976 | spv_result_t spvTextToBinaryWithOptions(const spv_const_context context, |
| 977 | const char* input_text, |
| 978 | const size_t input_text_size, |
| 979 | const uint32_t options, |
| 980 | spv_binary* pBinary, |
| 981 | spv_diagnostic* pDiagnostic) { |
| 982 | spv_context_t hijack_context = *context; |
| 983 | if (pDiagnostic) { |
| 984 | *pDiagnostic = nullptr; |
| 985 | spvtools::UseDiagnosticAsMessageConsumer(&hijack_context, pDiagnostic); |
| 986 | } |
| 987 | |
| 988 | spv_text_t text = {input_text, input_text_size}; |
| 989 | spvtools::AssemblyGrammar grammar(&hijack_context); |
| 990 | |
| 991 | spv_result_t result = spvTextToBinaryInternal( |
| 992 | grammar, hijack_context.consumer, &text, options, pBinary); |
| 993 | if (pDiagnostic && *pDiagnostic) (*pDiagnostic)->isTextSource = true; |
| 994 | |
| 995 | return result; |
| 996 | } |
| 997 | |
| 998 | void spvTextDestroy(spv_text text) { |
| 999 | if (text) { |