ART: Refactored VisualizerPrinter visitor pattern

This patch refactors the visitor pattern in HGraphVisualizerPrinter
to output instruction-specific details.

Change-Id: Icfed9cd844b973025337a6bb584e1bc88f1ddd58
diff --git a/compiler/optimizing/graph_visualizer.cc b/compiler/optimizing/graph_visualizer.cc
index b14b0a7..9ed1e45 100644
--- a/compiler/optimizing/graph_visualizer.cc
+++ b/compiler/optimizing/graph_visualizer.cc
@@ -142,8 +142,7 @@
     }
   }
 
-  void VisitParallelMove(HParallelMove* instruction) {
-    output_ << instruction->DebugName();
+  void VisitParallelMove(HParallelMove* instruction) OVERRIDE {
     output_ << " (";
     for (size_t i = 0, e = instruction->NumMoves(); i < e; ++i) {
       MoveOperands* move = instruction->MoveOperandsAt(i);
@@ -158,8 +157,25 @@
     output_ << " (liveness: " << instruction->GetLifetimePosition() << ")";
   }
 
-  void VisitInstruction(HInstruction* instruction) {
+  void VisitIntConstant(HIntConstant *instruction) OVERRIDE {
+    output_ << " " << instruction->GetValue();
+  }
+
+  void VisitLongConstant(HLongConstant *instruction) OVERRIDE {
+    output_ << " " << instruction->GetValue();
+  }
+
+  void VisitFloatConstant(HFloatConstant *instruction) OVERRIDE {
+    output_ << " " << instruction->GetValue();
+  }
+
+  void VisitDoubleConstant(HDoubleConstant *instruction) OVERRIDE {
+    output_ << " " << instruction->GetValue();
+  }
+
+  void PrintInstruction(HInstruction* instruction) {
     output_ << instruction->DebugName();
+    instruction->Accept(this);
     if (instruction->InputCount() > 0) {
       output_ << " [ ";
       for (HInputIterator inputs(instruction); !inputs.Done(); inputs.Advance()) {
@@ -167,15 +183,6 @@
       }
       output_ << "]";
     }
-    if (instruction->IsIntConstant()) {
-      output_ << " " << instruction->AsIntConstant()->GetValue();
-    } else if (instruction->IsLongConstant()) {
-      output_ << " " << instruction->AsLongConstant()->GetValue();
-    } else if (instruction->IsFloatConstant()) {
-      output_ << " " << instruction->AsFloatConstant()->GetValue();
-    } else if (instruction->IsDoubleConstant()) {
-      output_ << " " << instruction->AsDoubleConstant()->GetValue();
-    }
     if (pass_name_ == kLivenessPassName && instruction->GetLifetimePosition() != kNoLifetime) {
       output_ << " (liveness: " << instruction->GetLifetimePosition();
       if (instruction->HasLiveInterval()) {
@@ -210,7 +217,7 @@
       int bci = 0;
       output_ << bci << " " << instruction->NumberOfUses()
               << " " << GetTypeId(instruction->GetType()) << instruction->GetId() << " ";
-      instruction->Accept(this);
+      PrintInstruction(instruction);
       output_ << kEndInstructionMarker << std::endl;
     }
   }
@@ -222,7 +229,7 @@
     EndTag("cfg");
   }
 
-  void VisitBasicBlock(HBasicBlock* block) {
+  void VisitBasicBlock(HBasicBlock* block) OVERRIDE {
     StartTag("block");
     PrintProperty("name", "B", block->GetBlockId());
     if (block->GetLifetimeStart() != kNoLifetime) {