[svn:parrot] r37659 - trunk/src/pmc
cotto at svn.parrot.org
cotto at svn.parrot.org
Tue Mar 24 01:36:16 UTC 2009
Author: cotto
Date: Tue Mar 24 01:36:15 2009
New Revision: 37659
URL: https://trac.parrot.org/parrot/changeset/37659
Log:
[PMC] switch Hash-like PMCs to ATTRs
Modified:
trunk/src/pmc/addrregistry.pmc
trunk/src/pmc/default.pmc
trunk/src/pmc/hash.pmc
trunk/src/pmc/lexinfo.pmc
trunk/src/pmc/lexpad.pmc
trunk/src/pmc/namespace.pmc
trunk/src/pmc/orderedhash.pmc
trunk/src/pmc/unmanagedstruct.pmc
Modified: trunk/src/pmc/addrregistry.pmc
==============================================================================
--- trunk/src/pmc/addrregistry.pmc Tue Mar 24 01:02:08 2009 (r37658)
+++ trunk/src/pmc/addrregistry.pmc Tue Mar 24 01:36:15 2009 (r37659)
@@ -49,8 +49,9 @@
int_compare,
key_hash_int);
- /* prevent set_pointer from trying to delete an invalid hash */
- PMC_struct_val(SELF) = NULL;
+ Parrot_AddrRegistry_attributes *attrs =
+ mem_allocate_zeroed_typed(Parrot_AddrRegistry_attributes);
+ PMC_data(SELF) = attrs;
SELF.set_pointer(registry);
PObj_custom_mark_destroy_SETALL(SELF);
Modified: trunk/src/pmc/default.pmc
==============================================================================
--- trunk/src/pmc/default.pmc Tue Mar 24 01:02:08 2009 (r37658)
+++ trunk/src/pmc/default.pmc Tue Mar 24 01:36:15 2009 (r37659)
@@ -210,7 +210,7 @@
if (!self->pmc_ext)
add_pmc_ext(interp, self);
- PMC_metadata(self) = prop = pmc_new_noinit(interp, enum_class_Hash);
+ PMC_metadata(self) = prop = pmc_new(interp, enum_class_Hash);
GC_WRITE_BARRIER(interp, self, NULL, prop);
VTABLE_init(interp, prop);
propagate_std_props(interp, self, prop);
Modified: trunk/src/pmc/hash.pmc
==============================================================================
--- trunk/src/pmc/hash.pmc Tue Mar 24 01:02:08 2009 (r37658)
+++ trunk/src/pmc/hash.pmc Tue Mar 24 01:36:15 2009 (r37659)
@@ -97,13 +97,14 @@
EXCEPTION_UNEXPECTED_NULL, "Hash: Cannot use NULL STRING key");
else
return keystr;
- }
+
}
/* Albeit the Hash PMC doesn't use PMC_data, it needs the next_for_GC pointer
* We would get recursive marking of a deeply nested HoHoH...
*/
pmclass Hash need_ext provides hash {
+ ATTR Hash *hash;
/*
@@ -120,16 +121,18 @@
*/
VTABLE void init() {
- PMC_struct_val(SELF) = NULL;
+ Parrot_Hash_attributes *attr =
+ mem_allocate_zeroed_typed(Parrot_Hash_attributes);
+ PMC_data(SELF) = attr;
+ SELF.set_pointer(parrot_new_hash(INTERP));
PObj_custom_mark_destroy_SETALL(SELF);
- parrot_new_pmc_hash(INTERP, SELF);
}
VTABLE void destroy() {
if (SELF.get_pointer()) {
parrot_hash_destroy(INTERP, (Hash *)SELF.get_pointer());
- PMC_struct_val(SELF) = NULL;
}
+ mem_sys_free(PMC_data(SELF));
}
/*
@@ -163,7 +166,6 @@
parrot_hash_clone(INTERP, (Hash *)SELF.get_pointer(),
(Hash *)VTABLE_get_pointer(INTERP, dest));
- ((Hash *)PMC_struct_val(dest))->container = dest;
return dest;
}
@@ -181,7 +183,7 @@
Hash *old_hash = (Hash *)SELF.get_pointer();
Hash *new_hash = (Hash *)ptr;
- PMC_struct_val(SELF) = new_hash;
+ PARROT_HASH(SELF)->hash = new_hash;
new_hash->container = SELF;
if (old_hash != NULL) {
parrot_hash_destroy(INTERP, old_hash);
@@ -198,7 +200,7 @@
*/
VTABLE void *get_pointer() {
- return PMC_struct_val(SELF);
+ return PARROT_HASH(SELF)->hash;
}
/*
Modified: trunk/src/pmc/lexinfo.pmc
==============================================================================
--- trunk/src/pmc/lexinfo.pmc Tue Mar 24 01:02:08 2009 (r37658)
+++ trunk/src/pmc/lexinfo.pmc Tue Mar 24 01:36:15 2009 (r37659)
@@ -72,8 +72,9 @@
(hash_comp_fn)Parrot_str_not_equal, /* STRING compare */
(hash_hash_key_fn)Parrot_str_to_hashval); /* hash */
- /* prevent set_pointer from trying to delete an invalid hash */
- PMC_struct_val(SELF) = NULL;
+ Parrot_LexInfo_attributes *attrs =
+ mem_allocate_zeroed_typed(Parrot_LexInfo_attributes);
+ PMC_data(SELF) = attrs;
SELF.set_pointer(hash);
PObj_active_destroy_SET(SELF);
}
Modified: trunk/src/pmc/lexpad.pmc
==============================================================================
--- trunk/src/pmc/lexpad.pmc Tue Mar 24 01:02:08 2009 (r37658)
+++ trunk/src/pmc/lexpad.pmc Tue Mar 24 01:36:15 2009 (r37659)
@@ -97,14 +97,15 @@
VTABLE INTVAL elements() {
PMC *info;
GET_ATTR_lexinfo(INTERP, SELF, info);
- return parrot_hash_size(INTERP, (Hash *)PMC_struct_val(info));
+ return parrot_hash_size(INTERP,
+ (Hash *)VTABLE_get_pointer(INTERP, info));
}
VTABLE INTVAL exists_keyed_str(STRING *name) {
PMC *info;
GET_ATTR_lexinfo(INTERP, SELF, info);
return parrot_hash_get_bucket(INTERP,
- (Hash *)PMC_struct_val(info), name) != 0;
+ (Hash *)VTABLE_get_pointer(INTERP, info), name) != 0;
}
VTABLE INTVAL exists_keyed(PMC *name) {
@@ -121,7 +122,7 @@
GET_ATTR_lexinfo(INTERP, SELF, info);
GET_ATTR_ctx(INTERP, SELF, ctx);
- hash = (Hash *)PMC_struct_val(info);
+ hash = (Hash *)VTABLE_get_pointer(INTERP, info);
b = parrot_hash_get_bucket(INTERP, hash, name);
if (!b)
@@ -146,7 +147,7 @@
GET_ATTR_lexinfo(INTERP, SELF, info);
GET_ATTR_ctx(INTERP, SELF, ctx);
- hash = (Hash *)PMC_struct_val(info);
+ hash = (Hash *)VTABLE_get_pointer(INTERP, info);
b = parrot_hash_get_bucket(INTERP, hash, name);
if (!b)
Modified: trunk/src/pmc/namespace.pmc
==============================================================================
--- trunk/src/pmc/namespace.pmc Tue Mar 24 01:02:08 2009 (r37658)
+++ trunk/src/pmc/namespace.pmc Tue Mar 24 01:36:15 2009 (r37659)
@@ -132,20 +132,22 @@
=item C<void init()>
-Initialize a C<NameSpace> PMC by calling C<Hash.init> and clearing
-other fields.
+Initialize a C<NameSpace> PMC.
=cut
*/
VTABLE void init() {
- SUPER(); /* _struct_val := Hash */
- PMC_pmc_val(SELF) = NULL; /* parent */
- PMC_data(SELF) =
+ SUPER();
+ PMC_pmc_val(SELF) = NULL; /* parent */
+ PMC_data(SELF) =
mem_allocate_zeroed_typed(Parrot_NameSpace_attributes);
PARROT_NAMESPACE(SELF)->vtable = PMCNULL;
PARROT_NAMESPACE(SELF)->_class = PMCNULL;
+ PARROT_NAMESPACE(SELF)->_class = PMCNULL;
+ SELF.set_pointer(parrot_new_hash(INTERP));
+ PObj_custom_mark_destroy_SETALL(SELF);
}
/*
@@ -183,7 +185,6 @@
*/
VTABLE void destroy() {
mem_sys_free(PARROT_NAMESPACE(SELF));
- SUPER();
}
/*
Modified: trunk/src/pmc/orderedhash.pmc
==============================================================================
--- trunk/src/pmc/orderedhash.pmc Tue Mar 24 01:02:08 2009 (r37658)
+++ trunk/src/pmc/orderedhash.pmc Tue Mar 24 01:36:15 2009 (r37659)
@@ -429,7 +429,7 @@
}
VTABLE INTVAL exists_keyed_str(STRING *key) {
- const Hash * const h = (Hash *)SELF.get_pointer();
+ const Hash * const h = (Hash *)SELF.get_pointer();
const HashBucket * const b = parrot_hash_get_bucket(INTERP, h, key);
return (b && b->key);
Modified: trunk/src/pmc/unmanagedstruct.pmc
==============================================================================
--- trunk/src/pmc/unmanagedstruct.pmc Tue Mar 24 01:02:08 2009 (r37658)
+++ trunk/src/pmc/unmanagedstruct.pmc Tue Mar 24 01:36:15 2009 (r37659)
@@ -91,7 +91,7 @@
PMC * const types = PMC_pmc_val(pmc);
if (types->vtable->base_type == enum_class_OrderedHash) {
- Hash * const hash = (Hash *)PMC_struct_val(types);
+ Hash * const hash = (Hash *)VTABLE_get_pointer(interp, types);
HashBucket * const b = parrot_hash_get_bucket(interp, hash,
VTABLE_get_string(interp, key));
More information about the parrot-commits
mailing list