MCPcopy Create free account
hub / github.com/KhronosGroup/SPIRV-Tools / encodeImmediate

Function encodeImmediate

source/text.cpp:163–174  ·  view source on GitHub ↗

Parses an immediate integer from text, guarding against overflow. If successful, adds the parsed value to pInst, advances the context past it, and returns SPV_SUCCESS. Otherwise, leaves pInst alone, emits diagnostics, and returns SPV_ERROR_INVALID_TEXT.

Source from the content-addressed store, hash-verified

161/// and returns SPV_SUCCESS. Otherwise, leaves pInst alone, emits diagnostics,
162/// and returns SPV_ERROR_INVALID_TEXT.
163spv_result_t encodeImmediate(spvtools::AssemblyContext* context,
164 const char* text, spv_instruction_t* pInst) {
165 assert(*text == '!');
166 uint32_t parse_result;
167 if (!spvtools::utils::ParseNumber(text + 1, &parse_result)) {
168 return context->diagnostic(SPV_ERROR_INVALID_TEXT)
169 << "Invalid immediate integer: !" << text + 1;
170 }
171 context->binaryEncodeU32(parse_result, pInst);
172 context->seekForward(static_cast<uint32_t>(strlen(text)));
173 return SPV_SUCCESS;
174}
175
176} // anonymous namespace
177

Callers 2

spvTextEncodeOperandFunction · 0.85

Calls 4

ParseNumberFunction · 0.85
binaryEncodeU32Method · 0.80
seekForwardMethod · 0.80
diagnosticMethod · 0.45

Tested by

no test coverage detected