[svn:parrot] r44506 - trunk/src/pmc

NotFound at svn.parrot.org NotFound at svn.parrot.org
Fri Feb 26 22:10:11 UTC 2010


Author: NotFound
Date: Fri Feb 26 22:10:09 2010
New Revision: 44506
URL: https://trac.parrot.org/parrot/changeset/44506

Log:
method oplib.ops_by_shortname

Modified:
   trunk/src/pmc/oplib.pmc

Modified: trunk/src/pmc/oplib.pmc
==============================================================================
--- trunk/src/pmc/oplib.pmc	Fri Feb 26 20:59:15 2010	(r44505)
+++ trunk/src/pmc/oplib.pmc	Fri Feb 26 22:10:09 2010	(r44506)
@@ -96,6 +96,24 @@
     VTABLE INTVAL get_integer() {
         return INTERP->op_lib->op_count;
     }
+
+    METHOD ops_by_shortname(STRING *shortname)
+    {
+        char *sname = Parrot_str_to_cstring(INTERP, shortname);
+        const op_lib_t * const op_lib = INTERP->op_lib;
+        const op_info_t * const table = op_lib->op_info_table;
+        PMC *result = PMCNULL;
+        UINTVAL i;
+        for (i = 0; i < op_lib->op_count; ++i) {
+            if (strcmp(table[i].name, sname) == 0) {
+                if (PMC_IS_NULL(result))
+                    result = Parrot_pmc_new(INTERP, enum_class_ResizablePMCArray);
+                VTABLE_push_pmc(INTERP, result, SELF.get_pmc_keyed_int(i));
+            }
+        }
+        Parrot_str_free_cstring(sname);
+        RETURN(PMC *result);
+    }
 }
 
 /*


More information about the parrot-commits mailing list