* src/vm/method.c, src/vm/method.h (method_count_implementations):
authoredwin <none@none>
Wed, 3 Jan 2007 22:20:25 +0000 (22:20 +0000)
committeredwin <none@none>
Wed, 3 Jan 2007 22:20:25 +0000 (22:20 +0000)
New function.

src/vm/method.c
src/vm/method.h

index 53ccb6dd141db0d28c285e6b4b735f3fb3321b63..c6c5df137a447b79b6997eae8aa34e4554d1b320 100644 (file)
@@ -32,7 +32,7 @@
             Edwin Steiner
             Christian Thalinger
 
-   $Id: method.c 5992 2006-11-15 22:46:10Z edwin $
+   $Id: method.c 6273 2007-01-03 22:20:25Z edwin $
 
 */
 
@@ -155,6 +155,55 @@ methodinfo *method_vftbl_lookup(vftbl_t *vftbl, methodinfo* m)
 }
 
 
+/* method_count_implementations ************************************************
+
+   Count the implementations of a method in a class cone (a class and all its
+   subclasses.)
+
+   IN:
+       m................the method to count
+          c................class at which to start the counting (this class and
+                           all its subclasses will be searched)
+
+   OUT:
+       *found...........if found != NULL, *found receives the method
+                           implementation that was found. This value is only
+                                               meaningful if the return value is 1.
+
+   RETURN VALUE:
+       the number of implementations found
+
+*******************************************************************************/
+
+s4 method_count_implementations(methodinfo *m, classinfo *c, methodinfo **found)
+{
+       s4          count;
+       methodinfo *mp;
+       methodinfo *mend;
+       classinfo  *child;
+
+       count = 0;
+
+       mp = c->methods;
+       mend = mp + c->methodscount;
+
+       for (; mp < mend; ++mp) {
+               if (method_canoverwrite(mp, m)) {
+                       if (found)
+                               *found = mp;
+                       count++;
+                       break;
+               }
+       }
+
+       for (child = c->sub; child != NULL; child = child->nextsub) {
+               count += method_count_implementations(m, child, found);
+       }
+
+       return count;
+}
+
+
 /* method_add_to_worklist ******************************************************
 
    Add the method to the given worklist. If the method already occurs in
index 59f50658944076e73f92b59902175e837ad6762c..4dd819bb7e7b6dd35b0aa12d7cfa92a4e8ce8f15 100644 (file)
@@ -28,7 +28,7 @@
             Christian Thalinger
             Edwin Steiner
 
-   $Id: method.h 6216 2006-12-18 18:21:37Z twisti $
+   $Id: method.h 6273 2007-01-03 22:20:25Z edwin $
 */
 
 
@@ -157,6 +157,8 @@ methodinfo *method_vftbl_lookup(vftbl_t *vftbl, methodinfo* m);
 void method_add_assumption_monomorphic(methodinfo *m, methodinfo *caller);
 void method_break_assumption_monomorphic(methodinfo *m, method_worklist **wl);
 
+s4   method_count_implementations(methodinfo *m, classinfo *c, methodinfo **found);
+
 #if !defined(NDEBUG)
 void method_printflags(methodinfo *m);
 void method_print(methodinfo *m);