Simplify code for handling literals in disassembler.
authorLei Zhang <antiagainst@google.com>
Mon, 14 Sep 2015 16:26:15 +0000 (12:26 -0400)
committerDavid Neto <dneto@google.com>
Mon, 26 Oct 2015 16:55:33 +0000 (12:55 -0400)
source/binary.cpp

index e89ff9f..707cc87 100644 (file)
@@ -234,16 +234,6 @@ spv_result_t spvBinaryDecodeOperand(
       index++;
       position->index++;
     } break;
-    case SPV_OPERAND_TYPE_LITERAL:
-    case SPV_OPERAND_TYPE_OPTIONAL_LITERAL:
-    case SPV_OPERAND_TYPE_LITERAL_IN_OPTIONAL_TUPLE: {
-      // TODO: Need to support multiple word literals
-      stream.get() << (color ? clr::red() : "");
-      stream.get() << spvFixWord(words[index], endian);
-      stream.get() << (color ? clr::reset() : "");
-      index++;
-      position->index++;
-    } break;
     case SPV_OPERAND_TYPE_LITERAL_NUMBER: {
       // NOTE: Special case for extended instruction use
       if (OpExtInst == opcode) {
@@ -257,11 +247,18 @@ spv_result_t spvBinaryDecodeOperand(
         stream.get() << (color ? clr::red() : "");
         stream.get() << extInst->name;
         stream.get() << (color ? clr::reset() : "");
-      } else {
-        stream.get() << (color ? clr::red() : "");
-        stream.get() << spvFixWord(words[index], endian);
-        stream.get() << (color ? clr::reset() : "");
+        index++;
+        position->index++;
+        break;
       }
+    }  // Fall through for the general case.
+    case SPV_OPERAND_TYPE_LITERAL:
+    case SPV_OPERAND_TYPE_OPTIONAL_LITERAL:
+    case SPV_OPERAND_TYPE_LITERAL_IN_OPTIONAL_TUPLE: {
+      // TODO: Need to support multiple word literals
+      stream.get() << (color ? clr::red() : "");
+      stream.get() << spvFixWord(words[index], endian);
+      stream.get() << (color ? clr::reset() : "");
       index++;
       position->index++;
     } break;