Author: jonathan
Date: Sun Apr  1 16:37:56 2007
New Revision: 17938

Modified:
   trunk/src/pmc/object.pmc

Log:
[PDD15]: Implement get_class and can v-table methods in the Object PMC.

Modified: trunk/src/pmc/object.pmc
==============================================================================
--- trunk/src/pmc/object.pmc    (original)
+++ trunk/src/pmc/object.pmc    Sun Apr  1 16:37:56 2007
@@ -155,6 +155,38 @@
         return method;
     }
 
+/*
+
+=item C<PMC* get_class()>
+
+Get the class PMC representing the class that this object is an instance of.
+
+=cut
+
+*/
+    PMC* get_class()
+    {
+        Parrot_Object *obj = PARROT_OBJECT(SELF);
+        return obj->class;
+    }
+
+/*
+
+=item C<INTVAL can(STRING *method_name)>
+
+Returns 0 if the class does not have a method with the given name and a
+non-zero value if it does.
+
+=cut
+
+*/
+    INTVAL can(STRING *method_name)
+    {
+        /* Just use find_method and see it if finds anything. */
+        PMC *method = VTABLE_find_method(interp, SELF, method_name);
+        return PMC_IS_NULL(method);
+    }
+
 }
 
 /*

Reply via email to