[svn:parrot] r39752 - branches/tt761_keys_revamp/src/pmc

bacek at svn.parrot.org bacek at svn.parrot.org
Wed Jun 24 10:23:47 UTC 2009


Author: bacek
Date: Wed Jun 24 10:23:47 2009
New Revision: 39752
URL: https://trac.parrot.org/parrot/changeset/39752

Log:
[pmc] Small fixes in Hash - don't blindly cast value to PMC*

Modified:
   branches/tt761_keys_revamp/src/pmc/hash.pmc

Modified: branches/tt761_keys_revamp/src/pmc/hash.pmc
==============================================================================
--- branches/tt761_keys_revamp/src/pmc/hash.pmc	Wed Jun 24 10:23:25 2009	(r39751)
+++ branches/tt761_keys_revamp/src/pmc/hash.pmc	Wed Jun 24 10:23:47 2009	(r39752)
@@ -714,6 +714,7 @@
 
 */
 
+    /* I can't migrate this function right now. Some problem with JITting */
     VTABLE FLOATVAL get_number_keyed(PMC *key) {
         PMC               *nextkey;
         PMC               *valpmc;
@@ -916,18 +917,25 @@
 */
 
     VTABLE PMC *get_pmc_keyed_str(STRING *key) {
-        HashBucket * const b =
-            parrot_hash_get_bucket(INTERP, (Hash *)SELF.get_pointer(), key);
+        const Hash * const hash = (Hash *)SELF.get_pointer();
+        HashBucket * const b    = parrot_hash_get_bucket(INTERP, hash,
+                hash_key_from_string(INTERP, hash, key));
 
         if (!b)
             return PMCNULL;
 
-        return (PMC *)b->value;
+        return hash_value_to_pmc(INTERP, hash, b->value);
     }
 
     VTABLE PMC *get_pmc_keyed_int(INTVAL key) {
-        STRING * const s = Parrot_str_from_int(INTERP, key);
-        return SELF.get_pmc_keyed_str(s);
+        const Hash * const hash = (Hash *)SELF.get_pointer();
+        HashBucket * const b    = parrot_hash_get_bucket(INTERP, hash,
+                hash_key_from_int(INTERP, hash, key));
+
+        if (!b)
+            return PMCNULL;
+
+        return hash_value_to_pmc(INTERP, hash, b->value);
     }
 
     VTABLE PMC *get_pmc_keyed(PMC *key) {
@@ -1316,14 +1324,15 @@
 */
 
     VTABLE INTVAL defined_keyed_str(STRING *key) {
-        HashBucket * const b =
-            parrot_hash_get_bucket(INTERP, (Hash *)SELF.get_pointer(), key);
+        const Hash * const hash = (Hash *)SELF.get_pointer();
+        HashBucket * const b = parrot_hash_get_bucket(INTERP, hash,
+                hash_key_from_string(INTERP, hash, key));
 
         /* no such key */
         if (!b)
             return 0;
 
-        return VTABLE_defined(INTERP, (PMC*)b->value);
+        return VTABLE_defined(INTERP, hash_value_to_pmc(INTERP, hash, b->value));
     }
 
 /*


More information about the parrot-commits mailing list