| 326 | } |
| 327 | |
| 328 | spv_result_t AssemblyContext::binaryEncodeString(const char* value, |
| 329 | spv_instruction_t* pInst) { |
| 330 | const size_t length = strlen(value); |
| 331 | const size_t wordCount = (length / 4) + 1; |
| 332 | const size_t oldWordCount = pInst->words.size(); |
| 333 | const size_t newWordCount = oldWordCount + wordCount; |
| 334 | |
| 335 | // TODO(dneto): We can just defer this check until later. |
| 336 | if (newWordCount > SPV_LIMIT_INSTRUCTION_WORD_COUNT_MAX) { |
| 337 | return diagnostic() << "Instruction too long: more than " |
| 338 | << SPV_LIMIT_INSTRUCTION_WORD_COUNT_MAX << " words."; |
| 339 | } |
| 340 | |
| 341 | pInst->words.reserve(newWordCount); |
| 342 | spvtools::utils::AppendToVector(value, &pInst->words); |
| 343 | |
| 344 | return SPV_SUCCESS; |
| 345 | } |
| 346 | |
| 347 | spv_result_t AssemblyContext::recordTypeDefinition( |
| 348 | const spv_instruction_t* pInst) { |