[svn:parrot] r39751 - branches/tt761_keys_revamp/src/pmc
bacek at svn.parrot.org
bacek at svn.parrot.org
Wed Jun 24 10:23:27 UTC 2009
Author: bacek
Date: Wed Jun 24 10:23:25 2009
New Revision: 39751
URL: https://trac.parrot.org/parrot/changeset/39751
Log:
[pmc] Hash.get_string_keyed* migrated to new style
Modified:
branches/tt761_keys_revamp/src/pmc/hash.pmc
branches/tt761_keys_revamp/src/pmc/orderedhash.pmc
Modified: branches/tt761_keys_revamp/src/pmc/hash.pmc
==============================================================================
--- branches/tt761_keys_revamp/src/pmc/hash.pmc Tue Jun 23 22:27:19 2009 (r39750)
+++ branches/tt761_keys_revamp/src/pmc/hash.pmc Wed Jun 24 10:23:25 2009 (r39751)
@@ -837,31 +837,43 @@
*/
- VTABLE STRING *get_string_keyed(PMC *key) {
- PMC *valpmc;
- void *keystr;
- HashBucket *b;
- PMC *nextkey;
- Hash * const hash = (Hash *)SELF.get_pointer();
+ /* Called from HashIterator */
+ MULTI STRING *get_string_keyed(HashIteratorKey key) {
+ void *value = (PMC*)PARROT_HASHITERATORKEY(key)->bucket->value;
+ return hash_value_to_string(INTERP, (Hash*)SELF.get_pointer(), value);
+ }
- /* called from iterator */
- if (VTABLE_type(INTERP, key) == enum_class_HashIteratorKey) {
- PMC *val = (PMC*)PARROT_HASHITERATORKEY(key)->bucket->value;
- return VTABLE_get_string(INTERP, val);
- }
+ /* Simple PMC */
+ MULTI STRING *get_string_keyed(DEFAULT key) {
+ const Hash * const hash = (Hash*)SELF.get_pointer();
+ HashBucket * const b = parrot_hash_get_bucket(INTERP, hash,
+ hash_key_from_pmc(INTERP, hash, key));
- keystr = hash_key_from_pmc(INTERP, hash, key);
- b = parrot_hash_get_bucket(INTERP, hash, keystr);
+ if (!b)
+ return Parrot_str_new_noinit(INTERP, enum_stringrep_one, 0);
+
+ return hash_value_to_string(INTERP, hash, b->value);
+ }
+
+ /* Compound Key */
+ MULTI STRING *get_string_keyed(Key key) {
+ const Hash * const hash = (Hash *)SELF.get_pointer();
+ HashBucket *b = parrot_hash_get_bucket(INTERP, hash,
+ hash_key_from_pmc(INTERP, hash, key));
+ PMC *valpmc;
+ PMC *nextkey;
if (!b)
return Parrot_str_new_noinit(INTERP, enum_stringrep_one, 0);
- nextkey = key_next(INTERP, key);
- valpmc = (PMC *)b->value;
+ nextkey = VTABLE_shift_pmc(INTERP, key);
+ valpmc = hash_value_to_pmc(INTERP, hash, b->value);
+ /* Stop recursion. This is last step */
if (!nextkey)
return VTABLE_get_string(INTERP, valpmc);
+ /* Recusively call to enclosed aggregate */
return VTABLE_get_string_keyed(INTERP, valpmc, nextkey);
}
Modified: branches/tt761_keys_revamp/src/pmc/orderedhash.pmc
==============================================================================
--- branches/tt761_keys_revamp/src/pmc/orderedhash.pmc Tue Jun 23 22:27:19 2009 (r39750)
+++ branches/tt761_keys_revamp/src/pmc/orderedhash.pmc Wed Jun 24 10:23:25 2009 (r39751)
@@ -167,7 +167,7 @@
return VTABLE_get_string_keyed(INTERP, item, next);
}
- return SUPER(key);
+ return INTERP->vtables[enum_class_Hash]->get_string_keyed(INTERP, SELF, key);
}
/*
More information about the parrot-commits
mailing list