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

plobsing at svn.parrot.org plobsing at svn.parrot.org
Fri Apr 9 23:25:25 UTC 2010


Author: plobsing
Date: Fri Apr  9 23:25:24 2010
New Revision: 45488
URL: https://trac.parrot.org/parrot/changeset/45488

Log:
handle creating storage on thaw of odd typed hashes

Modified:
   trunk/src/pmc/hash.pmc

Modified: trunk/src/pmc/hash.pmc
==============================================================================
--- trunk/src/pmc/hash.pmc	Fri Apr  9 21:58:21 2010	(r45487)
+++ trunk/src/pmc/hash.pmc	Fri Apr  9 23:25:24 2010	(r45488)
@@ -1136,8 +1136,30 @@
             const INTVAL v_type = VTABLE_shift_integer(INTERP, info);
             Hash        *hash;
 
-            if (k_type == Hash_key_type_int && v_type == enum_hash_int) {
-                SELF.set_pointer(parrot_new_intval_hash(INTERP));
+            if (k_type != Hash_key_type_STRING || v_type != enum_hash_pmc) {
+                hash_comp_fn cmp_fn;
+                hash_hash_key_fn key_fn;
+
+                switch (k_type) {
+                  case Hash_key_type_int:
+                    key_fn = key_hash_int;
+                    cmp_fn = int_compare;
+                    break;
+                  case Hash_key_type_STRING:
+                    key_fn = key_hash_STRING;
+                    cmp_fn = STRING_compare;
+                    break;
+                  case Hash_key_type_PMC:
+                    key_fn = key_hash_PMC;
+                    cmp_fn = PMC_compare;
+                    break;
+                  default:
+                    Parrot_ex_throw_from_c_args(interp, NULL, 1,
+                            "unimplemented key type");
+                    break;
+                }
+
+                SELF.set_pointer(parrot_create_hash(INTERP, v_type, k_type, cmp_fn, key_fn));
             }
 
             hash = (Hash *)SELF.get_pointer();


More information about the parrot-commits mailing list