mirror of
https://github.com/KhronosGroup/SPIRV-Tools
synced 2024-11-22 19:50:05 +00:00
Generalize spvOperandTableNameLookup to take string length.
This is preparation for parsing mask expressions.
This commit is contained in:
parent
e3a19c0d63
commit
388c40d9c6
@ -1456,12 +1456,12 @@ spv_result_t spvOperandTableGet(spv_operand_table *pOperandTable) {
|
||||
|
||||
spv_result_t spvOperandTableNameLookup(const spv_operand_table table,
|
||||
const spv_operand_type_t type,
|
||||
const char *name,
|
||||
spv_operand_desc *pEntry) {
|
||||
const char* name,
|
||||
const size_t nameLength,
|
||||
spv_operand_desc* pEntry) {
|
||||
if (!table) return SPV_ERROR_INVALID_TABLE;
|
||||
if (!name || !pEntry) return SPV_ERROR_INVALID_POINTER;
|
||||
|
||||
const uint64_t nameLength = strlen(name);
|
||||
for (uint64_t typeIndex = 0; typeIndex < table->count; ++typeIndex) {
|
||||
if (type == table->types[typeIndex].type) {
|
||||
for (uint64_t operandIndex = 0;
|
||||
@ -1469,7 +1469,7 @@ spv_result_t spvOperandTableNameLookup(const spv_operand_table table,
|
||||
if (nameLength ==
|
||||
strlen(table->types[typeIndex].entries[operandIndex].name) &&
|
||||
!strncmp(table->types[typeIndex].entries[operandIndex].name, name,
|
||||
strlen(name))) {
|
||||
nameLength)) {
|
||||
*pEntry = &table->types[typeIndex].entries[operandIndex];
|
||||
return SPV_SUCCESS;
|
||||
}
|
||||
|
@ -45,12 +45,14 @@ using spv_operand_pattern_t = std::deque<spv_operand_type_t>;
|
||||
/// @param[in] table to lookup
|
||||
/// @param[in] type the operand group's type
|
||||
/// @param[in] name of the operand to find
|
||||
/// @param[in] nameLength number of bytes of name to compare
|
||||
/// @param[out] pEntry returned operand table entry
|
||||
///
|
||||
/// @return result code
|
||||
spv_result_t spvOperandTableNameLookup(const spv_operand_table table,
|
||||
const spv_operand_type_t type,
|
||||
const char *name,
|
||||
const size_t nameLength,
|
||||
spv_operand_desc *pEntry);
|
||||
|
||||
/// @brief Find the operand with value in the table
|
||||
|
@ -539,7 +539,8 @@ spv_result_t spvTextEncodeOperand(
|
||||
// NOTE: All non literal operands are handled here using the operand
|
||||
// table.
|
||||
spv_operand_desc entry;
|
||||
if (spvOperandTableNameLookup(operandTable, type, textValue, &entry)) {
|
||||
if (spvOperandTableNameLookup(operandTable, type, textValue,
|
||||
strlen(textValue), &entry)) {
|
||||
DIAGNOSTIC << "Invalid " << spvOperandTypeStr(type) << " '" << textValue
|
||||
<< "'.";
|
||||
return SPV_ERROR_INVALID_TEXT;
|
||||
|
Loading…
Reference in New Issue
Block a user