From e3f70b9a857fc587979d2bbc9422ea465fe8122c Mon Sep 17 00:00:00 2001 From: David Neto Date: Thu, 27 Aug 2015 13:50:05 -0400 Subject: [PATCH] Combine parsing of ID and RESULT_ID operand types --- source/text.cpp | 25 +++++-------------------- 1 file changed, 5 insertions(+), 20 deletions(-) diff --git a/source/text.cpp b/source/text.cpp index 0c202e8..534e4b1 100644 --- a/source/text.cpp +++ b/source/text.cpp @@ -353,35 +353,20 @@ spv_result_t spvTextEncodeOperand( } switch (type) { - case SPV_OPERAND_TYPE_ID: { - if ('%' == textValue[0]) { - textValue++; - } - // TODO: Force all ID's to be prefixed with '%'. - uint32_t id = 0; - if (spvTextIsNamedId(textValue)) { - id = spvNamedIdAssignOrGet(namedIdTable, textValue, pBound); - } else { - spvCheck(spvTextToUInt32(textValue, &id), - DIAGNOSTIC << "Invalid ID '" << textValue << "'."; - return SPV_ERROR_INVALID_TEXT); - } - pInst->words[pInst->wordCount++] = id; - if (*pBound <= id) { - *pBound = id + 1; - } - } break; + case SPV_OPERAND_TYPE_ID: case SPV_OPERAND_TYPE_RESULT_ID: { if ('%' == textValue[0]) { textValue++; } - // TODO: Force all Result ID's to be prefixed with '%'. + // TODO: Force all ID's to be prefixed with '%'. uint32_t id = 0; if (spvTextIsNamedId(textValue)) { id = spvNamedIdAssignOrGet(namedIdTable, textValue, pBound); } else { spvCheck(spvTextToUInt32(textValue, &id), - DIAGNOSTIC << "Invalid result ID '" << textValue << "'."; + DIAGNOSTIC << "Invalid " + << ((type == SPV_OPERAND_TYPE_RESULT_ID) ? "result " : "") + << "ID '" << textValue << "'."; return SPV_ERROR_INVALID_TEXT); } pInst->words[pInst->wordCount++] = id; -- 2.7.4