Materialize method descriptors when instantiating method objects.

Previously, when comparing method descriptors, one had to piecewise
compare the leaves of a method structure for equality.

With this change a flat method descriptor is computed and associated
to an object.  This will simplify comparisons for descriptor equality
used during verification and reflective method retrieval.

Change-Id: I91e5ac76fb3816a36716b34fe43d05cd7364897b
diff --git a/src/object.cc b/src/object.cc
index 96c5116..98b6e43 100644
--- a/src/object.cc
+++ b/src/object.cc
@@ -157,33 +157,50 @@
   return ShortyCharToSize(shorty_[0]);
 }
 
-Method* Class::FindDirectMethod(const String* name) const {
-  Method* result = NULL;
-  for (size_t i = 0; i < NumDirectMethods(); i++) {
+Method* Class::FindDeclaredDirectMethod(const StringPiece& name,
+                                        const StringPiece& descriptor) {
+  for (size_t i = 0; i < NumDirectMethods(); ++i) {
     Method* method = GetDirectMethod(i);
-    if (String::Equals(method->GetName(), name)) {
-      result = method;
-      break;
+    if (String::EqualsUtf8(method->GetName(), name.data()) &&
+        String::EqualsUtf8(method->GetDescriptor(), descriptor.data())) {
+      return method;
     }
   }
-  return result;
+  return NULL;
 }
 
-Method* Class::FindVirtualMethod(const String* name) const {
-  Method* result = NULL;
-  for (size_t i = 0; i < NumVirtualMethods(); i++) {
+Method* Class::FindDirectMethod(const StringPiece& name,
+                                const StringPiece& descriptor) {
+  for (Class* klass = this; klass != NULL; klass = klass->GetSuperClass()) {
+    Method* method = klass->FindDeclaredDirectMethod(name, descriptor);
+    if (method != NULL) {
+      return method;
+    }
+  }
+  return NULL;
+}
+
+Method* Class::FindDeclaredVirtualMethod(const StringPiece& name,
+                                         const StringPiece& descriptor) {
+  for (size_t i = 0; i < NumVirtualMethods(); ++i) {
     Method* method = GetVirtualMethod(i);
-    if (String::Equals(method->GetName(), name)) {
-      result = method;
-      break;
+    if (String::EqualsUtf8(method->GetName(), name.data()) &&
+        String::EqualsUtf8(method->GetDescriptor(), descriptor.data())) {
+      return method;
     }
   }
-  return result;
+  return NULL;
 }
 
-Method* Class::FindDirectMethodLocally(const StringPiece& name,
-                                       const StringPiece& descriptor) const {
-  return NULL;  // TODO
+Method* Class::FindVirtualMethod(const StringPiece& name,
+                                 const StringPiece& descriptor) {
+  for (Class* klass = this; klass != NULL; klass = klass->GetSuperClass()) {
+    Method* method = klass->FindDeclaredVirtualMethod(name, descriptor);
+    if (method != NULL) {
+      return method;
+    }
+  }
+  return NULL;
 }
 
 // TODO: get global references for these