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 $
*/
}
+/* 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
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 $
*/
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);