[svn:parrot] r45002 - branches/pcc_megrecells/src/pmc

bacek at svn.parrot.org bacek at svn.parrot.org
Thu Mar 18 09:48:54 UTC 2010


Author: bacek
Date: Thu Mar 18 09:48:54 2010
New Revision: 45002
URL: https://trac.parrot.org/parrot/changeset/45002

Log:
Add NOCELL type to distinguish not-filled cells

Modified:
   branches/pcc_megrecells/src/pmc/callcontext.pmc

Modified: branches/pcc_megrecells/src/pmc/callcontext.pmc
==============================================================================
--- branches/pcc_megrecells/src/pmc/callcontext.pmc	Thu Mar 18 09:48:29 2010	(r45001)
+++ branches/pcc_megrecells/src/pmc/callcontext.pmc	Thu Mar 18 09:48:54 2010	(r45002)
@@ -31,10 +31,11 @@
 } Pcc_cell;
 
 /* mask off lower two bits (1 + 2 = 3) for pointer tags */
-#define INTCELL    0
-#define FLOATCELL  1
-#define STRINGCELL 2
-#define PMCCELL    3
+#define NOCELL     0
+#define INTCELL    1
+#define FLOATCELL  2
+#define STRINGCELL 3
+#define PMCCELL    4
 
 #define ALLOC_CELL(i) \
     (Pcc_cell *)Parrot_gc_allocate_fixed_size_storage((i), sizeof (Pcc_cell))
@@ -832,7 +833,7 @@
     VTABLE INTVAL get_integer_keyed_int(INTVAL key) {
         Pcc_cell *cell = get_cell_at(INTERP, SELF, key);
 
-        if (!cell)
+        if (cell->type == NOCELL)
             return 0;
 
         return autobox_intval(INTERP, cell);
@@ -841,7 +842,7 @@
     VTABLE FLOATVAL get_number_keyed_int(INTVAL key) {
         Pcc_cell *cell = get_cell_at(INTERP, SELF, key);
 
-        if (!cell)
+        if (cell->type == NOCELL)
             return 0.0;
 
         return autobox_floatval(INTERP, cell);
@@ -850,7 +851,7 @@
     VTABLE STRING * get_string_keyed_int(INTVAL key) {
         Pcc_cell *cell = get_cell_at(INTERP, SELF, key);
 
-        if (!cell)
+        if (cell->type == NOCELL)
             return NULL;
 
         return autobox_string(INTERP, cell);
@@ -859,7 +860,7 @@
     VTABLE PMC * get_pmc_keyed_int(INTVAL key) {
         Pcc_cell *cell = get_cell_at(INTERP, SELF, key);
 
-        if (!cell)
+        if (cell->type == NOCELL)
             return PMCNULL;
 
         return autobox_pmc(INTERP, cell);
@@ -868,73 +869,29 @@
     VTABLE void set_integer_keyed_int(INTVAL key, INTVAL value) {
         Pcc_cell *cell = get_cell_at(INTERP, SELF, key);
 
-        if (!cell) {
-            INTVAL num_positionals;
-
-            GET_ATTR_num_positionals(INTERP, SELF, num_positionals);
-
-            if (key == num_positionals)
-                VTABLE_push_integer(INTERP, SELF, value);
-
-            /* XXX: else throw exception? */
-            return;
-        }
-
-        CELL_INT(cell) = value;
+        cell->u.i   = value;
+        cell->type  = INTCELL;
     }
 
     VTABLE void set_number_keyed_int(INTVAL key, FLOATVAL value) {
         Pcc_cell *cell = get_cell_at(INTERP, SELF, key);
 
-        if (!cell) {
-            INTVAL num_positionals;
-
-            GET_ATTR_num_positionals(INTERP, SELF, num_positionals);
-
-            if (key == num_positionals)
-                VTABLE_push_float(INTERP, SELF, value);
-
-            /* XXX: else throw exception? */
-            return;
-        }
-
-        CELL_FLOAT(cell) = value;
+        cell->u.n   = value;
+        cell->type  = FLOATCELL;
     }
 
     VTABLE void set_string_keyed_int(INTVAL key, STRING *value) {
         Pcc_cell *cell = get_cell_at(INTERP, SELF, key);
 
-        if (!cell) {
-            INTVAL num_positionals;
-
-            GET_ATTR_num_positionals(INTERP, SELF, num_positionals);
-
-            if (key == num_positionals)
-                VTABLE_push_string(INTERP, SELF, value);
-
-            /* XXX: else throw exception? */
-            return;
-        }
-
-        CELL_STRING(cell) = value;
+        cell->u.s   = value;
+        cell->type  = STRINGCELL;
     }
 
     VTABLE void set_pmc_keyed_int(INTVAL key, PMC *value) {
         Pcc_cell *cell = get_cell_at(INTERP, SELF, key);
 
-        if (!cell) {
-            INTVAL num_positionals;
-
-            GET_ATTR_num_positionals(INTERP, SELF, num_positionals);
-
-            if (key == num_positionals)
-                VTABLE_push_pmc(INTERP, SELF, value);
-
-            /* XXX: else throw exception? */
-            return;
-        }
-
-        CELL_PMC(cell) = value;
+        cell->u.s   = value;
+        cell->type  = STRINGCELL;
     }
 
     VTABLE void set_integer_keyed_str(STRING *key, INTVAL value) {


More information about the parrot-commits mailing list