Refactor the use of Method by the compiler.

Remove the dependence on the Method object in dex2oat, allowing lazier
resolution.
Introduce new find and iterators in DexFile to simplify common
operations and avoid misuse of class data items.

Change-Id: I39fb8252190f543d89d8b233076355cec310fe08
diff --git a/src/utils.cc b/src/utils.cc
index c37343c..c528f1c 100644
--- a/src/utils.cc
+++ b/src/utils.cc
@@ -153,6 +153,19 @@
   return result;
 }
 
+std::string PrettyMethod(uint32_t method_idx, const DexFile& dex_file, bool with_signature) {
+  const DexFile::MethodId& method_id = dex_file.GetMethodId(method_idx);
+  std::string result(PrettyDescriptor(dex_file.GetMethodDeclaringClassDescriptor(method_id)));
+  result += '.';
+  result += dex_file.GetMethodName(method_id);
+  if (with_signature) {
+    // TODO: iterate over the signature's elements and pass them all to
+    // PrettyDescriptor? We'd need to pull out the return type specially, too.
+    result += dex_file.GetMethodSignature(method_id);
+  }
+  return result;
+}
+
 std::string PrettyTypeOf(const Object* obj) {
   if (obj == NULL) {
     return "null";