Added first pass of verifier and supporting changes.

The verifier still needs to make a second pass through the code where it
checks the code flow. A TODO marks where it will be added.

Change-Id: I0abea5bad563776186df342d8132fb1ca8869652
diff --git a/src/dex_instruction_visitor.h b/src/dex_instruction_visitor.h
index 73b4b3e..6a6bc3e 100644
--- a/src/dex_instruction_visitor.h
+++ b/src/dex_instruction_visitor.h
@@ -11,17 +11,17 @@
 template<typename T>
 class DexInstructionVisitor {
  public:
-  void Visit(uint16_t* code, size_t size) {
+  void Visit(const uint16_t* code, size_t size) {
     T* derived = static_cast<T*>(this);
-    byte* ptr = reinterpret_cast<byte*>(code);
-    byte* end = ptr + size;
+    const byte* ptr = reinterpret_cast<const byte*>(code);
+    const byte* end = ptr + size;
     while (ptr != end) {
-      Instruction* inst = Instruction::At(ptr);
+      const Instruction* inst = Instruction::At(ptr);
       switch (inst->Opcode()) {
-#define INSTRUCTION_CASE(o, cname, p, f, r, i, a)  \
-        case Instruction::cname: {                 \
-          derived->Do_ ## cname(inst);             \
-          break;                                   \
+#define INSTRUCTION_CASE(o, cname, p, f, r, i, a, v)  \
+        case Instruction::cname: {                    \
+          derived->Do_ ## cname(inst);                \
+          break;                                      \
         }
 #include "dex_instruction_list.h"
         DEX_INSTRUCTION_LIST(INSTRUCTION_CASE)
@@ -30,17 +30,17 @@
         default:
           CHECK(true);
       }
-      ptr += inst->Size();
+      ptr += inst->Size() * sizeof(uint16_t);
       CHECK_LE(ptr, end);
     }
   }
 
  private:
   // Specific handlers for each instruction.
-#define INSTRUCTION_VISITOR(o, cname, p, f, r, i, a)    \
-  void Do_ ## cname(Instruction* inst) {                \
-    T* derived = static_cast<T*>(this);                 \
-    derived->Do_Default(inst);                          \
+#define INSTRUCTION_VISITOR(o, cname, p, f, r, i, a, v)    \
+  void Do_ ## cname(const Instruction* inst) {             \
+    T* derived = static_cast<T*>(this);                    \
+    derived->Do_Default(inst);                             \
   }
 #include "dex_instruction_list.h"
   DEX_INSTRUCTION_LIST(INSTRUCTION_VISITOR)
@@ -48,11 +48,12 @@
 #undef INSTRUCTION_VISITOR
 
   // The default instruction handler.
-  void Do_Default(Instruction* inst) {
+  void Do_Default(const Instruction* inst) {
     return;
   }
 };
 
+
 }  // namespace art
 
 #endif  // ART_SRC_DEX_INSTRUCTION_VISITOR_H_