| 63 | } |
| 64 | |
| 65 | spv_result_t extractOpString(const spv_position_t& loc, |
| 66 | const spv_parsed_instruction_t& instruction, |
| 67 | std::string* output) { |
| 68 | assert(output != nullptr); |
| 69 | assert(instruction.opcode == static_cast<unsigned>(spv::Op::OpString)); |
| 70 | if (instruction.num_operands != 2) { |
| 71 | spvtools::Error(spvtools::utils::CLIMessageConsumer, "", loc, |
| 72 | "Missing operands for OpString."); |
| 73 | return SPV_ERROR_INVALID_BINARY; |
| 74 | } |
| 75 | |
| 76 | const auto& operand = instruction.operands[1]; |
| 77 | const char* stringBegin = |
| 78 | reinterpret_cast<const char*>(instruction.words + operand.offset); |
| 79 | const char* stringEnd = reinterpret_cast<const char*>( |
| 80 | instruction.words + operand.offset + operand.num_words); |
| 81 | return ExtractStringLiteral(loc, stringBegin, stringEnd, output); |
| 82 | } |
| 83 | |
| 84 | spv_result_t extractOpSourceContinued( |
| 85 | const spv_position_t& loc, const spv_parsed_instruction_t& instruction, |
no test coverage detected