[svn:parrot] r43910 - branches/op_pmcs/src/pmc

whiteknight at svn.parrot.org whiteknight at svn.parrot.org
Thu Feb 11 16:30:41 UTC 2010


Author: whiteknight
Date: Thu Feb 11 16:30:40 2010
New Revision: 43910
URL: https://trac.parrot.org/parrot/changeset/43910

Log:
[pmc2c--] Fix Opcode and OpLib PMCs so they build and pass a few ad hoc tests I threw together.

Modified:
   branches/op_pmcs/src/pmc/opcode.pmc
   branches/op_pmcs/src/pmc/oplib.pmc

Modified: branches/op_pmcs/src/pmc/opcode.pmc
==============================================================================
--- branches/op_pmcs/src/pmc/opcode.pmc	Thu Feb 11 16:18:00 2010	(r43909)
+++ branches/op_pmcs/src/pmc/opcode.pmc	Thu Feb 11 16:30:40 2010	(r43910)
@@ -1,6 +1,6 @@
 #include "parrot/parrot.h"
 
-pmclass Opcode {
+pmclass Opcode auto_attrs {
     ATTR op_info_t *info;
     ATTR INTVAL op_number;
     ATTR STRING *full_name_cache;
@@ -17,13 +17,13 @@
 
     VTABLE void set_pointer(void *i) {
         Parrot_Opcode_attributes * const attrs = PARROT_OPCODE(SELF);
-        attrs->info = i;
+        attrs->info = (op_info_t *)i;
     }
 
     VTABLE void set_string_native(STRING *name) {
         const char * const cstr = Parrot_str_to_cstring(INTERP, name);
         const INTVAL num = interp->op_lib->op_code(cstr, 1);
-        Parrot_str_free_cstring(INTERP, cstr);
+        Parrot_str_free_cstring(cstr);
         if (num == -1)
             Parrot_ex_throw_from_c_args(INTERP, NULL, EXCEPTION_OUT_OF_BOUNDS,
                 "Opcode: Opcode %S not found", name);
@@ -43,13 +43,13 @@
         if (value >= opcount || value < 0)
             Parrot_ex_throw_from_c_args(INTERP, NULL, EXCEPTION_OUT_OF_BOUNDS,
                 "Opcode: Opcode index %d out of bounds", value);
-        attrs->info = &(inter->op_info_table[value]);
+        attrs->info = &(interp->op_info_table[value]);
         attrs->op_number = value;
     }
 
-    VTABLE STRING *get_string() {
+    VTABLE STRING* get_string() {
         Parrot_Opcode_attributes * const attrs = PARROT_OPCODE(SELF);
-        if (attrs->full_name == NULL) {
+        if (attrs->full_name_cache == NULL) {
             const char * const name = attrs->info->full_name;
             const INTVAL len = strlen(name);
             STRING * const newstr = Parrot_str_new(INTERP, name, len);

Modified: branches/op_pmcs/src/pmc/oplib.pmc
==============================================================================
--- branches/op_pmcs/src/pmc/oplib.pmc	Thu Feb 11 16:18:00 2010	(r43909)
+++ branches/op_pmcs/src/pmc/oplib.pmc	Thu Feb 11 16:30:40 2010	(r43910)
@@ -16,25 +16,23 @@
 
     /* Look up an opnumber given the name of the op. First we look for the
        specific name, then the more general short name. */
-    VTABLE INTVAL get_integer_keyed_string(STRING *name) {
+    VTABLE INTVAL get_integer_keyed_str(STRING *name) {
         const char * const cstr = Parrot_str_to_cstring(INTERP, name);
         INTVAL num = interp->op_lib->op_code(cstr, 1);
         if (num == -1)
             num = interp->op_lib->op_code(cstr, 0);
-        Parrot_str_free_cstring(INTERP, cstr);
+        Parrot_str_free_cstring(cstr);
         return num;
     }
 
-    VTABLE PMC *get_pmc_keyed_string(STRING *name) {
-        PMC * const family = pmc_new(INTERP, enum_class_OpFamily);
-        VTABLE_set_string_native(INTERP, name);
-        if (!VTABLE_elements(INTERP, family))
-            return PMCNULL;
-        return family;
+    VTABLE PMC* get_pmc_keyed_str(STRING *name) {
+        PMC * const op = pmc_new(INTERP, enum_class_Opcode);
+        VTABLE_set_string_native(INTERP, op, name);
+        return op;
     }
 
-    VTABLE PMC *get_pmc_keyed_int(INTVAL value) {
-        PMC * const op = pmc_new(INTERP, enum_class_Opcode)
+    VTABLE PMC* get_pmc_keyed_int(INTVAL value) {
+        PMC * const op = pmc_new(INTERP, enum_class_Opcode);
         VTABLE_set_integer_native(INTERP, op, value);
         return op;
     }


More information about the parrot-commits mailing list