[svn:parrot] r37650 - in trunk/src: . call dynpmc pmc
cotto at svn.parrot.org
cotto at svn.parrot.org
Mon Mar 23 20:05:45 UTC 2009
Author: cotto
Date: Mon Mar 23 20:05:44 2009
New Revision: 37650
URL: https://trac.parrot.org/parrot/changeset/37650
Log:
[hash] use get/set_pointer instead of PMC_struct_val on Hash-like PMCs
Modified:
trunk/src/call/pcc.c
trunk/src/dynpmc/dynlexpad.pmc
trunk/src/hash.c
trunk/src/pmc/hash.pmc
trunk/src/pmc_freeze.c
Modified: trunk/src/call/pcc.c
==============================================================================
--- trunk/src/call/pcc.c Mon Mar 23 20:01:56 2009 (r37649)
+++ trunk/src/call/pcc.c Mon Mar 23 20:05:44 2009 (r37650)
@@ -901,7 +901,8 @@
if (!PMC_IS_NULL(st->key)) {
st->src.slurp_i++;
st->name = (STRING *)parrot_hash_get_idx(interp,
- (Hash *)PMC_struct_val(st->src.slurp), st->key);
+ (Hash *)VTABLE_get_pointer(interp, st->src.slurp),
+ st->key);
PARROT_ASSERT(st->name);
UVal_pmc(st->val) = VTABLE_get_pmc_keyed_str(interp,
st->src.slurp, st->name);
Modified: trunk/src/dynpmc/dynlexpad.pmc
==============================================================================
--- trunk/src/dynpmc/dynlexpad.pmc Mon Mar 23 20:01:56 2009 (r37649)
+++ trunk/src/dynpmc/dynlexpad.pmc Mon Mar 23 20:05:44 2009 (r37650)
@@ -37,13 +37,17 @@
*/
void init_pmc(PMC* lexinfo) {
+ Hash *hash;
if (VTABLE_elements(interp, lexinfo)) {
PMC_pmc_val(SELF) =
pmc_new_init(interp, enum_class_LexPad, lexinfo);
}
else
PMC_pmc_val(SELF) = NULL;
- parrot_new_pmc_hash(interp, SELF);
+
+ hash = parrot_new_hash(INTERP);
+ PMC_struct_val(SELF) = hash;
+ hash->container = SELF;
PObj_custom_mark_destroy_SETALL(SELF);
}
Modified: trunk/src/hash.c
==============================================================================
--- trunk/src/hash.c Mon Mar 23 20:01:56 2009 (r37649)
+++ trunk/src/hash.c Mon Mar 23 20:05:44 2009 (r37650)
@@ -834,7 +834,7 @@
=item C<void parrot_new_pmc_hash>
-Creates a new Parrot STRING hash in PMC_struct_val(container).
+Creates a new Parrot STRING hash in C<container>.
=cut
@@ -845,13 +845,8 @@
parrot_new_pmc_hash(PARROT_INTERP, ARGOUT(PMC *container))
{
ASSERT_ARGS(parrot_new_pmc_hash)
- Hash * const hash = parrot_create_hash(interp,
- enum_type_PMC,
- Hash_key_type_STRING,
- STRING_compare,
- (hash_hash_key_fn)key_hash_STRING);
- PMC_struct_val(container) = hash;
- hash->container = container;
+ Hash * const hash = parrot_new_hash(interp);
+ VTABLE_set_pointer(interp, container, hash);
}
Modified: trunk/src/pmc/hash.pmc
==============================================================================
--- trunk/src/pmc/hash.pmc Mon Mar 23 20:01:56 2009 (r37649)
+++ trunk/src/pmc/hash.pmc Mon Mar 23 20:05:44 2009 (r37650)
@@ -182,7 +182,9 @@
PMC_struct_val(SELF) = new_hash;
new_hash->container = SELF;
- parrot_hash_destroy(INTERP, old_hash);
+ if (old_hash != NULL) {
+ parrot_hash_destroy(INTERP, old_hash);
+ }
}
/*
Modified: trunk/src/pmc_freeze.c
==============================================================================
--- trunk/src/pmc_freeze.c Mon Mar 23 20:01:56 2009 (r37649)
+++ trunk/src/pmc_freeze.c Mon Mar 23 20:05:44 2009 (r37650)
@@ -1560,7 +1560,8 @@
{
ASSERT_ARGS(todo_list_seen)
HashBucket * const b =
- parrot_hash_get_bucket(interp, (Hash *)PMC_struct_val(info->seen), pmc);
+ parrot_hash_get_bucket(interp,
+ (Hash *)VTABLE_get_pointer(interp, info->seen), pmc);
if (b) {
*id = (UINTVAL) b->value;
@@ -1569,7 +1570,8 @@
info->id += 4; /* next id to freeze */
*id = info->id;
- parrot_hash_put(interp, (Hash *)PMC_struct_val(info->seen), pmc, (void*)*id);
+ parrot_hash_put(interp,
+ (Hash *)VTABLE_get_pointer(interp, info->seen), pmc, (void*)*id);
/* remember containers */
if (pmc->pmc_ext)
list_unshift(interp, (List *)PMC_data(info->todo), pmc, enum_type_PMC);
More information about the parrot-commits
mailing list