Author: chromatic
Date: Tue May 1 23:53:54 2007
New Revision: 18394
Modified:
trunk/include/parrot/pmc_freeze.h
trunk/src/pmc/array.pmc
trunk/src/pmc/bigint.pmc
trunk/src/pmc/enumerate.pmc
trunk/src/pmc/fixedstringarray.pmc
trunk/src/pmc/hash.pmc
trunk/src/pmc/intlist.pmc
trunk/src/pmc/iterator.pmc
trunk/src/pmc/lexpad.pmc
trunk/src/pmc/orderedhash.pmc
trunk/src/pmc/parrotinterpreter.pmc
trunk/src/pmc/parrotthread.pmc
trunk/src/pmc/resizablestringarray.pmc
Log:
[PMC] More casting cleanups for C++ correctness.
There are some type-punning occurrences I can't fix easily, but they'd be good
to change to enable more optimizations.
Modified: trunk/include/parrot/pmc_freeze.h
==============================================================================
--- trunk/include/parrot/pmc_freeze.h (original)
+++ trunk/include/parrot/pmc_freeze.h Tue May 1 23:53:54 2007
@@ -68,7 +68,7 @@
INTVAL what;
STRING* image;
PMC* mark_ptr;
- PMC** thaw_ptr; /* where to thaw aa new PMC */
+ PMC** thaw_ptr; /* where to thaw a new PMC */
PMC* container; /* when thawing aggregate items */
INTVAL last_type;
PMC* seen; /* seen hash */
Modified: trunk/src/pmc/array.pmc
==============================================================================
--- trunk/src/pmc/array.pmc (original)
+++ trunk/src/pmc/array.pmc Tue May 1 23:53:54 2007
@@ -1250,7 +1250,7 @@
for (i = 0; i < max; ++i) {
PMC *value;
- value = list_get(INTERP, PMC_data_typed(ret, List *),
+ value = (PMC *)list_get(INTERP, PMC_data_typed(ret, List *),
i, enum_type_PMC);
if (!PMC_IS_NULL(value)) {
Modified: trunk/src/pmc/bigint.pmc
==============================================================================
--- trunk/src/pmc/bigint.pmc (original)
+++ trunk/src/pmc/bigint.pmc Tue May 1 23:53:54 2007
@@ -73,7 +73,7 @@
static void
bigint_set_self(Interp *interp, PMC *self, BIGNUM *value) {
- mpz_set(BN(self), value);
+ mpz_set(BN(self), (mpz_srcptr)value);
}
static long
Modified: trunk/src/pmc/enumerate.pmc
==============================================================================
--- trunk/src/pmc/enumerate.pmc (original)
+++ trunk/src/pmc/enumerate.pmc Tue May 1 23:53:54 2007
@@ -40,30 +40,37 @@
*/
INTVAL get_bool() {
- PMC *key = PMC_struct_val(SELF);
- PMC *iter = PMC_pmc_val(SELF);
- INTVAL ok = PMC_int_val(key) >= 0 && VTABLE_get_bool(INTERP, iter);
+ PMC *key = (PMC *)PMC_struct_val(SELF);
+ PMC *iter = (PMC *)PMC_pmc_val(SELF);
+ INTVAL ok = PMC_int_val(key) >= 0 && VTABLE_get_bool(INTERP, iter);
+
if (!ok)
PMC_int_val(key) = -1;
+
return ok;
}
PMC* shift_pmc() {
- PMC *key = PMC_struct_val(SELF);
- PMC *iter = PMC_pmc_val(SELF);
PMC *item, *tupl, *val;
- INTVAL i = PMC_int_val(key);
+ PMC *key = (PMC *)PMC_struct_val(SELF);
+ PMC *iter = (PMC *)PMC_pmc_val(SELF);
+ INTVAL i = PMC_int_val(key);
if (i == -1)
real_exception(INTERP, NULL, E_StopIteration, "StopIteration");
+
item = VTABLE_shift_pmc(INTERP, iter);
tupl = pmc_new(INTERP, enum_class_FixedPMCArray);
+
++PMC_int_val(key);
VTABLE_set_integer_native(INTERP, tupl, 2);
- val = pmc_new(INTERP, enum_class_Integer);
+
+ val = pmc_new(INTERP, enum_class_Integer);
PMC_int_val(val) = i;
+
VTABLE_set_pmc_keyed_int(INTERP, tupl, 0, val);
VTABLE_set_pmc_keyed_int(INTERP, tupl, 1, item);
+
return tupl;
}
Modified: trunk/src/pmc/fixedstringarray.pmc
==============================================================================
--- trunk/src/pmc/fixedstringarray.pmc (original)
+++ trunk/src/pmc/fixedstringarray.pmc Tue May 1 23:53:54 2007
@@ -513,11 +513,14 @@
INTVAL i, n;
STRING **data;
SUPER(info);
+
if (info->extra_flags == EXTRA_IS_NULL) {
DYNSELF.init();
- n = io->vtable->shift_integer(INTERP, io);
+
+ n = io->vtable->shift_integer(INTERP, io);
DYNSELF.set_integer_native(n);
- data = PMC_data(SELF);
+ data = PMC_data_typed(SELF, STRING **);
+
for (i = 0; i < n; ++i)
data[i] = io->vtable->shift_string(INTERP, io);
}
Modified: trunk/src/pmc/hash.pmc
==============================================================================
--- trunk/src/pmc/hash.pmc (original)
+++ trunk/src/pmc/hash.pmc Tue May 1 23:53:54 2007
@@ -141,7 +141,7 @@
void mark() {
if (PMC_struct_val(SELF))
- parrot_mark_hash(INTERP, PMC_struct_val(SELF));
+ parrot_mark_hash(INTERP, (Hash *)PMC_struct_val(SELF));
}
/*
@@ -173,19 +173,22 @@
*/
- INTVAL type_keyed(PMC* key) {
- PMC* valpmc;
- PMC* nextkey;
- STRING* const keystr = make_hash_key(INTERP, key);
- HashBucket* const b =
+ INTVAL type_keyed(PMC *key) {
+ PMC *valpmc;
+ PMC *nextkey;
+ STRING * const keystr = make_hash_key(INTERP, key);
+ HashBucket * const b =
parrot_hash_get_bucket(INTERP, (Hash*)PMC_struct_val(SELF),
keystr);
- if (b == NULL) {
+
+ if (b == NULL)
return 0;
- }
+
nextkey = key_next(INTERP, key);
- valpmc = b->value;
+ valpmc = (PMC *)b->value;
+
if (!nextkey)
return VTABLE_type(INTERP, valpmc);
+
return VTABLE_type_keyed(INTERP, valpmc, nextkey);
}
@@ -219,7 +222,7 @@
*/
INTVAL get_integer() {
- return parrot_hash_size(INTERP, PMC_struct_val(SELF));
+ return parrot_hash_size(INTERP, (Hash *)PMC_struct_val(SELF));
}
/*
@@ -255,12 +258,12 @@
*/
- INTVAL get_integer_keyed(PMC* key) {
- PMC* valpmc;
- STRING* keystr;
- Hash * const hash = PMC_struct_val(SELF);
+ INTVAL get_integer_keyed(PMC *key) {
+ PMC *valpmc;
+ STRING *keystr;
HashBucket *b;
- PMC* nextkey;
+ PMC *nextkey;
+ Hash * const hash = (Hash *)PMC_struct_val(SELF);
switch (PObj_get_FLAGS(key) & KEY_type_FLAGS) {
case KEY_hash_iterator_FLAGS:
@@ -271,20 +274,24 @@
return (INTVAL)parrot_hash_get_idx(INTERP, hash, key);
}
else {
- STRING *s = parrot_hash_get_idx(INTERP, hash, key);
+ STRING *s = (STRING*)parrot_hash_get_idx(INTERP, hash,
key);
return string_to_int(INTERP, s);
}
default:
keystr = make_hash_key(INTERP, key);
}
- b = parrot_hash_get_bucket(INTERP, hash, keystr);
- if (b == NULL) {
+
+ b = parrot_hash_get_bucket(INTERP, hash, keystr);
+
+ if (b == NULL)
return 0;
- }
+
nextkey = key_next(INTERP, key);
- valpmc = b->value;
+ valpmc = (PMC *)b->value;
+
if (!nextkey)
return VTABLE_get_integer(INTERP, valpmc);
+
return VTABLE_get_integer_keyed(INTERP, valpmc, nextkey);
}
@@ -321,19 +328,22 @@
*/
- FLOATVAL get_number_keyed(PMC* key) {
- PMC* valpmc;
- STRING* const keystr = make_hash_key(INTERP, key);
- HashBucket * const b =
- parrot_hash_get_bucket(INTERP, (Hash*)PMC_struct_val(SELF),
keystr);
- PMC* nextkey;
- if (b == NULL) {
+ FLOATVAL get_number_keyed(PMC *key) {
+ PMC *nextkey;
+ PMC *valpmc;
+ STRING * const keystr = make_hash_key(INTERP, key);
+ HashBucket * const b = parrot_hash_get_bucket(INTERP,
+ (Hash*)PMC_struct_val(SELF),
keystr);
+
+ if (b == NULL)
return 0.0;
- }
+
nextkey = key_next(INTERP, key);
- valpmc = b->value;
+ valpmc = (PMC *)b->value;
+
if (!nextkey)
return VTABLE_get_number(INTERP, valpmc);
+
return VTABLE_get_number_keyed(INTERP, valpmc, nextkey);
}
@@ -439,11 +449,11 @@
*/
STRING* get_string_keyed(PMC* key) {
- PMC* valpmc;
- STRING* keystr;
- HashBucket *b;
- Hash * const hash = PMC_struct_val(SELF);
- PMC* nextkey;
+ PMC *valpmc;
+ STRING *keystr;
+ HashBucket *b;
+ PMC *nextkey;
+ Hash * const hash = (Hash *)PMC_struct_val(SELF);
switch (PObj_get_FLAGS(key) & KEY_type_FLAGS) {
case KEY_hash_iterator_FLAGS:
@@ -452,23 +462,28 @@
INTVAL i = (INTVAL)parrot_hash_get_idx(INTERP, hash, key);
return string_from_int(INTERP, i);
}
- return parrot_hash_get_idx(INTERP, hash, key);
+ return (STRING *)parrot_hash_get_idx(INTERP, hash, key);
default:
keystr = make_hash_key(INTERP, key);
}
+
b = parrot_hash_get_bucket(INTERP, hash, keystr);
+
if (b == NULL) {
/*
* TODO current behaviour of $S0 = hsh['no_such_key'] in
* PGE and possibly more code needs an empty STRING
* (--leo)
*/
- return string_make_empty(INTERP,enum_stringrep_one,0);
+ return string_make_empty(INTERP, enum_stringrep_one, 0);
}
+
nextkey = key_next(INTERP, key);
- valpmc = b->value;
+ valpmc = (PMC *)b->value;
+
if (!nextkey)
return VTABLE_get_string(INTERP, valpmc);
+
return VTABLE_get_string_keyed(INTERP, valpmc, nextkey);
}
@@ -483,7 +498,7 @@
*/
INTVAL get_bool() {
- return parrot_hash_size(INTERP, PMC_struct_val(SELF)) != 0;
+ return parrot_hash_size(INTERP, (Hash *)PMC_struct_val(SELF)) != 0;
}
/*
@@ -497,7 +512,7 @@
*/
INTVAL elements() {
- return parrot_hash_size(INTERP, PMC_struct_val(SELF));
+ return parrot_hash_size(INTERP, (Hash *)PMC_struct_val(SELF));
}
/*
@@ -510,13 +525,14 @@
*/
- PMC* get_pmc_keyed_str(STRING* key) {
+ PMC* get_pmc_keyed_str(STRING *key) {
HashBucket * const b =
parrot_hash_get_bucket(INTERP, (Hash*) PMC_struct_val(SELF), key);
- if (b == NULL) {
+
+ if (b == NULL)
return PMCNULL;
- }
- return b->value;
+
+ return (PMC *)b->value;
}
PMC* get_pmc_keyed_int(INTVAL key) {
@@ -539,28 +555,30 @@
*/
PMC* get_iter() {
- PMC * const iter = pmc_new_init(INTERP, enum_class_Iterator, SELF);
- PMC * const key = pmc_new(INTERP, enum_class_Key);
+ PMC * const iter = pmc_new_init(INTERP, enum_class_Iterator, SELF);
+ PMC * const key = pmc_new(INTERP, enum_class_Key);
PMC_struct_val(iter) = key;
PObj_get_FLAGS(key) |= KEY_hash_iterator_FLAGS;
- PMC_data(key) = (void *)INITBucketIndex;
+ PMC_data(key) = (void *)INITBucketIndex;
+
/* -1 for an empty hash, 0 for a non-empty hash. */
- PMC_int_val(key) =
- parrot_hash_size(INTERP, PMC_struct_val(SELF)) ? 0 : -1;
+ PMC_int_val(key) =
+ parrot_hash_size(INTERP, (Hash *)PMC_struct_val(SELF)) ? 0 : -1;
+
return iter;
}
- PMC* slice(PMC* key) {
+ PMC* slice(PMC *key) {
return NULL;
}
- PMC* get_pmc_keyed(PMC* key) {
- Hash * const hash = PMC_struct_val(SELF);
- STRING* keystr;
+ PMC* get_pmc_keyed(PMC *key) {
+ Hash * const hash = (Hash *)PMC_struct_val(SELF);
+ STRING *keystr;
HashBucket *b;
- PMC* nextkey;
- PMC* result;
+ PMC *nextkey;
+ PMC *result;
switch (PObj_get_FLAGS(key) & KEY_type_FLAGS) {
case KEY_hash_iterator_FLAGS:
@@ -574,7 +592,8 @@
PMC_int_val(result) = i;
}
else {
- STRING * const s = parrot_hash_get_idx(INTERP, hash, key);
+ STRING *s;
+ s = (STRING *)parrot_hash_get_idx(INTERP, hash, key);
result = pmc_new(INTERP, enum_class_String);
VTABLE_set_string_native(INTERP, result, s);
}
@@ -582,13 +601,17 @@
default:
keystr = make_hash_key(INTERP, key);
}
+
b = parrot_hash_get_bucket(INTERP, hash, keystr);
- if (b == NULL) {
+
+ if (b == NULL)
return PMCNULL;
- }
+
nextkey = key_next(INTERP, key);
+
if (!nextkey)
- return b->value;
+ return (PMC *)b->value;
+
return VTABLE_get_pmc_keyed(INTERP, (PMC*)b->value, nextkey);
}
@@ -615,19 +638,22 @@
*/
- void set_integer_keyed(PMC* key, INTVAL value) {
- STRING* keystr;
- PMC* nextkey;
- PMC* box;
+ void set_integer_keyed(PMC *key, INTVAL value) {
+ STRING *keystr;
+ PMC *nextkey;
+ PMC *box;
- if (!key) return;
- keystr = make_hash_key(INTERP, key);
+ if (!key)
+ return;
+
+ keystr = make_hash_key(INTERP, key);
nextkey = key_next(INTERP, key);
+
if (nextkey == NULL) {
PMC* val = get_integer_pmc(INTERP, SELF->vtable->base_type);
VTABLE_set_integer_native(INTERP, val, value);
- parrot_hash_put(INTERP, PMC_struct_val(SELF), keystr, val);
+ parrot_hash_put(INTERP, (Hash *)PMC_struct_val(SELF), keystr, val);
return;
}
box = SELF.get_pmc_keyed_str(keystr);
@@ -646,11 +672,12 @@
*/
- void set_integer_keyed_str(STRING* key, INTVAL value) {
- PMC* const val = get_integer_pmc(INTERP, SELF->vtable->base_type);
+ void set_integer_keyed_str(STRING *key, INTVAL value) {
+ PMC * const val = get_integer_pmc(INTERP, SELF->vtable->base_type);
PMC_int_val(val) = value;
- parrot_hash_put(INTERP, PMC_struct_val(SELF), key, val);
+
+ parrot_hash_put(INTERP, (Hash *)PMC_struct_val(SELF), key, val);
}
/*
@@ -661,25 +688,30 @@
*/
- void set_number_keyed(PMC* key, FLOATVAL value) {
- STRING* keystr;
- PMC* nextkey;
- PMC* box;
+ void set_number_keyed(PMC *key, FLOATVAL value) {
+ STRING *keystr;
+ PMC *nextkey;
+ PMC *box;
- if (!key) return;
- keystr = make_hash_key(INTERP, key);
+ if (!key)
+ return;
+
+ keystr = make_hash_key(INTERP, key);
nextkey = key_next(INTERP, key);
+
if (nextkey == NULL) {
PMC* val = get_number_pmc(INTERP, SELF->vtable->base_type);
PMC_num_val(val) = value;
- parrot_hash_put(INTERP, PMC_struct_val(SELF), keystr, val);
+ parrot_hash_put(INTERP, (Hash *)PMC_struct_val(SELF), keystr, val);
return;
}
+
box = SELF.get_pmc_keyed_str(keystr);
- if (box == NULL) {
- /* autovivify an Hash */
+
+ /* autovivify an Hash */
+ if (box == NULL)
box = pmc_new(INTERP, DYNSELF.type());
- }
+
VTABLE_set_number_keyed(INTERP, box, nextkey, value);
}
@@ -693,11 +725,12 @@
*/
- void set_number_keyed_str(STRING* key, FLOATVAL value) {
- PMC* const val = get_number_pmc(INTERP, SELF->vtable->base_type);
+ void set_number_keyed_str(STRING *key, FLOATVAL value) {
+ PMC * const val = get_number_pmc(INTERP, SELF->vtable->base_type);
PMC_num_val(val) = value;
- parrot_hash_put(INTERP, PMC_struct_val(SELF), key, val);
+
+ parrot_hash_put(INTERP, (Hash *)PMC_struct_val(SELF), key, val);
}
/*
@@ -708,25 +741,30 @@
*/
- void set_string_keyed(PMC* key, STRING* value) {
- STRING* keystr;
- PMC* nextkey;
- PMC* box;
+ void set_string_keyed(PMC *key, STRING *value) {
+ STRING *keystr;
+ PMC *nextkey;
+ PMC *box;
- if (!key) return;
- keystr = make_hash_key(INTERP, key);
+ if (!key)
+ return;
+
+ keystr = make_hash_key(INTERP, key);
nextkey = key_next(INTERP, key);
+
if (nextkey == NULL) {
PMC* const val = get_string_pmc(INTERP, SELF->vtable->base_type);
VTABLE_set_string_native(INTERP, val, value);
- parrot_hash_put(INTERP, PMC_struct_val(SELF), keystr, val);
+ parrot_hash_put(INTERP, (Hash *)PMC_struct_val(SELF), keystr, val);
return;
}
+
box = SELF.get_pmc_keyed_str(keystr);
- if (box == NULL) {
- /* autovivify an Hash */
+
+ /* autovivify an Hash */
+ if (box == NULL)
box = pmc_new(INTERP, DYNSELF.type());
- }
+
VTABLE_set_string_keyed(INTERP, box, nextkey, value);
}
@@ -738,11 +776,11 @@
*/
- void set_string_keyed_str(STRING* key, STRING* value) {
+ void set_string_keyed_str(STRING *key, STRING *value) {
PMC* const val = get_string_pmc(INTERP, SELF->vtable->base_type);
VTABLE_set_string_native(INTERP, val, value);
- parrot_hash_put(INTERP, PMC_struct_val(SELF), key, val);
+ parrot_hash_put(INTERP, (Hash *)PMC_struct_val(SELF), key, val);
}
/*
@@ -753,23 +791,28 @@
*/
- void set_pmc_keyed(PMC* key, PMC* value) {
- STRING* keystr;
- PMC* nextkey;
- PMC* box;
+ void set_pmc_keyed(PMC *key, PMC *value) {
+ STRING *keystr;
+ PMC *nextkey;
+ PMC *box;
+
+ if (!key)
+ return;
- if (!key) return;
- keystr = make_hash_key(INTERP, key);
+ keystr = make_hash_key(INTERP, key);
nextkey = key_next(INTERP, key);
+
if (nextkey == NULL) {
- parrot_hash_put(INTERP, PMC_struct_val(SELF), keystr, value);
+ parrot_hash_put(INTERP, (Hash*)PMC_struct_val(SELF), keystr,
value);
return;
}
+
box = SELF.get_pmc_keyed_str(keystr);
- if (box == NULL) {
- /* autovivify an Hash */
+
+ /* autovivify an Hash */
+ if (box == NULL)
box = pmc_new(INTERP, DYNSELF.type());
- }
+
VTABLE_set_pmc_keyed(INTERP, box, nextkey, value);
}
@@ -783,8 +826,8 @@
*/
- void set_pmc_keyed_str(STRING* key, PMC* value) {
- parrot_hash_put(INTERP, PMC_struct_val(SELF), key, value);
+ void set_pmc_keyed_str(STRING *key, PMC *value) {
+ parrot_hash_put(INTERP, (Hash *)PMC_struct_val(SELF), key, value);
}
/*
@@ -1033,11 +1076,14 @@
}
else
SELF.init();
- hash = PMC_struct_val(SELF);
+
+ hash = (Hash *)PMC_struct_val(SELF);
+
assert((INTVAL)hash->key_type == k_type);
- assert(hash->entry_type == v_type);
+ assert(hash->entry_type == v_type);
+
hash->container = SELF;
- hash->entries = elems;
+ hash->entries = elems;
}
}
}
Modified: trunk/src/pmc/intlist.pmc
==============================================================================
--- trunk/src/pmc/intlist.pmc (original)
+++ trunk/src/pmc/intlist.pmc Tue May 1 23:53:54 2007
@@ -192,7 +192,8 @@
*/
void unshift_integer(INTVAL value) {
- intlist_unshift(INTERP, (IntList**) &PMC_struct_val(SELF), value);
+ IntList **list = (IntList **)PMC_struct_val(SELF);
+ intlist_unshift(INTERP, list, value);
}
/*
@@ -206,7 +207,8 @@
*/
INTVAL shift_integer() {
- return intlist_shift(INTERP, (IntList**) &PMC_struct_val(SELF));
+ IntList **list = (IntList **)PMC_struct_val(SELF);
+ return intlist_shift(INTERP, list);
}
void splice(PMC* value, INTVAL offset, INTVAL count) {
Modified: trunk/src/pmc/iterator.pmc
==============================================================================
--- trunk/src/pmc/iterator.pmc (original)
+++ trunk/src/pmc/iterator.pmc Tue May 1 23:53:54 2007
@@ -96,7 +96,7 @@
*/
PMC* clone() {
- PMC * const key = PMC_struct_val(SELF);
+ PMC * const key = (PMC *)PMC_struct_val(SELF);
PMC *res = pmc_new_init(INTERP, SELF->vtable->base_type,
PMC_pmc_val(SELF));
PMC_struct_val(res) = VTABLE_clone(interp, key);
return res;
@@ -128,7 +128,7 @@
*/
STRING* get_string() {
- PMC * const key = PMC_struct_val(SELF);
+ PMC * const key = (PMC *)PMC_struct_val(SELF);
return string_from_int(INTERP, key_integer(INTERP, key));
}
@@ -155,8 +155,8 @@
*/
INTVAL get_integer_keyed_int(INTVAL idx) {
- PMC * const key = PMC_struct_val(SELF);
- PMC * const agg = PMC_pmc_val(SELF);
+ PMC * const key = (PMC *)PMC_struct_val(SELF);
+ PMC * const agg = (PMC *)PMC_pmc_val(SELF);
return VTABLE_get_integer_keyed_int(INTERP, agg, PMC_int_val(key)
+idx);
}
@@ -183,8 +183,8 @@
*/
FLOATVAL get_number_keyed_int(INTVAL idx) {
- PMC * const key = PMC_struct_val(SELF);
- PMC * const agg = PMC_pmc_val(SELF);
+ PMC * const key = (PMC *)PMC_struct_val(SELF);
+ PMC * const agg = (PMC *)PMC_pmc_val(SELF);
return VTABLE_get_number_keyed_int(INTERP, agg, PMC_int_val(key) +
idx);
}
@@ -213,8 +213,8 @@
*/
STRING* get_string_keyed_int(INTVAL idx) {
- PMC * const key = PMC_struct_val(SELF);
- PMC * const agg = PMC_pmc_val(SELF);
+ PMC * const key = (PMC *)PMC_struct_val(SELF);
+ PMC * const agg = (PMC *)PMC_pmc_val(SELF);
return VTABLE_get_string_keyed_int(INTERP, agg, PMC_int_val(key) +
idx);
}
@@ -229,7 +229,7 @@
*/
INTVAL get_bool() {
- PMC * const key = PMC_struct_val(SELF);
+ PMC * const key = (PMC *)PMC_struct_val(SELF);
return key && PMC_int_val(key) != -1;
}
@@ -272,8 +272,8 @@
*/
PMC* get_pmc_keyed_int(INTVAL idx) {
- PMC * const key = PMC_struct_val(SELF);
- PMC * const agg = PMC_pmc_val(SELF);
+ PMC * const key = (PMC *)PMC_struct_val(SELF);
+ PMC * const agg = (PMC *)PMC_pmc_val(SELF);
return VTABLE_get_pmc_keyed_int(INTERP, agg, PMC_int_val(key) + idx);
}
@@ -307,7 +307,7 @@
if (!PMC_struct_val(SELF))
key = key_new(INTERP);
else
- key = PMC_struct_val(SELF);
+ key = (PMC *)PMC_struct_val(SELF);
PMC_struct_val(SELF) =
VTABLE_nextkey_keyed(INTERP, key, agg, value);
@@ -323,11 +323,12 @@
*/
INTVAL pop_integer() {
- PMC * const key = PMC_struct_val(SELF);
- PMC * const agg = PMC_pmc_val(SELF);
- const INTVAL ret = VTABLE_get_integer_keyed(INTERP, agg, key);
+ PMC * const key = (PMC *)PMC_struct_val(SELF);
+ PMC * const agg = (PMC *)PMC_pmc_val(SELF);
+ const INTVAL ret = VTABLE_get_integer_keyed(INTERP, agg, key);
PMC_struct_val(SELF) =
VTABLE_nextkey_keyed(INTERP, key, agg, ITERATE_GET_PREV);
+
return ret;
}
@@ -340,11 +341,12 @@
*/
FLOATVAL pop_float() {
- PMC * const key = PMC_struct_val(SELF);
- PMC * const agg = PMC_pmc_val(SELF);
- const FLOATVAL ret = VTABLE_get_number_keyed(INTERP, agg, key);
+ PMC * const key = (PMC *)PMC_struct_val(SELF);
+ PMC * const agg = (PMC *)PMC_pmc_val(SELF);
+ const FLOATVAL ret = VTABLE_get_number_keyed(INTERP, agg, key);
PMC_struct_val(SELF) =
VTABLE_nextkey_keyed(INTERP, key, agg, ITERATE_GET_PREV);
+
return ret;
}
@@ -357,9 +359,9 @@
*/
STRING* pop_string() {
- PMC * const key = PMC_struct_val(SELF);
- PMC * const agg = PMC_pmc_val(SELF);
- STRING * const ret = VTABLE_get_string_keyed(INTERP, agg, key);
+ PMC * const key = (PMC *)PMC_struct_val(SELF);
+ PMC * const agg = (PMC *)PMC_pmc_val(SELF);
+ STRING * const ret = VTABLE_get_string_keyed(INTERP, agg, key);
PMC_struct_val(SELF) =
VTABLE_nextkey_keyed(INTERP, key, agg, ITERATE_GET_PREV);
return ret;
@@ -377,11 +379,12 @@
*/
PMC* pop_pmc() {
- PMC * const key = PMC_struct_val(SELF);
- PMC * const agg = PMC_pmc_val(SELF);
- PMC * const ret = VTABLE_get_pmc_keyed(INTERP, agg, key);
+ PMC * const key = (PMC *)PMC_struct_val(SELF);
+ PMC * const agg = (PMC *)PMC_pmc_val(SELF);
+ PMC * const ret = VTABLE_get_pmc_keyed(INTERP, agg, key);
PMC_struct_val(SELF) =
VTABLE_nextkey_keyed(INTERP, key, agg, ITERATE_GET_PREV);
+
return ret;
}
@@ -397,9 +400,9 @@
*/
INTVAL shift_integer() {
- PMC * const key = PMC_struct_val(SELF);
- PMC * const agg = PMC_pmc_val(SELF);
- const INTVAL ret = VTABLE_get_integer_keyed(INTERP, agg, key);
+ PMC * const key = (PMC *)PMC_struct_val(SELF);
+ PMC * const agg = (PMC *)PMC_pmc_val(SELF);
+ const INTVAL ret = VTABLE_get_integer_keyed(INTERP, agg, key);
PMC_struct_val(SELF) =
VTABLE_nextkey_keyed(INTERP, key, agg, ITERATE_GET_NEXT);
return ret;
@@ -426,32 +429,34 @@
PMC *iter, *arg = REG_PMC(5);
if (PObj_is_object_TEST(arg)) {
REG_PMC(5) = VTABLE_get_iter(INTERP, arg);
- return next;
+ return (opcode_t *)next;
}
REG_PMC(5) = iter = pmc_new_init(INTERP,
enum_class_Iterator, arg);
VTABLE_set_integer_native(INTERP, iter, 0);
- return next;
+ return (opcode_t *)next;
}
else if (REG_INT(3) == 2) /* TODO function+sentinel */
real_exception(INTERP, NULL, E_AssertionError,
"Iterator: invoke 2 args");
REG_INT(1) = REG_INT(2) = REG_INT(3) = REG_INT(4) = 0;
- key = PMC_struct_val(SELF);
- agg = PMC_pmc_val(SELF);
+ key = (PMC *)PMC_struct_val(SELF);
+ agg = (PMC *)PMC_pmc_val(SELF);
+
switch (agg->vtable->base_type) {
case enum_class_IntList:
- ires = DYNSELF.shift_integer();
+ ires = DYNSELF.shift_integer();
REG_INT(1) = 1;
REG_INT(5) = ires;
- return next;
+ return (opcode_t *)next;
default:
- res = DYNSELF.shift_pmc();
+ res = DYNSELF.shift_pmc();
REG_INT(3) = 1;
REG_PMC(5) = res;
- return next;
+ return (opcode_t *)next;
}
+
return NULL;
}
@@ -464,9 +469,9 @@
*/
FLOATVAL shift_float() {
- PMC * const key = PMC_struct_val(SELF);
- PMC * const agg = PMC_pmc_val(SELF);
- const FLOATVAL ret = VTABLE_get_number_keyed(INTERP, agg, key);
+ PMC * const key = (PMC *)PMC_struct_val(SELF);
+ PMC * const agg = (PMC *)PMC_pmc_val(SELF);
+ const FLOATVAL ret = VTABLE_get_number_keyed(INTERP, agg, key);
PMC_struct_val(SELF) =
VTABLE_nextkey_keyed(INTERP, key, agg, ITERATE_GET_NEXT);
return ret;
@@ -482,9 +487,9 @@
*/
STRING* shift_string() {
- PMC * const key = PMC_struct_val(SELF);
- PMC * const agg = PMC_pmc_val(SELF);
- STRING * const ret = VTABLE_get_string_keyed(INTERP, agg, key);
+ PMC * const key = (PMC *)PMC_struct_val(SELF);
+ PMC * const agg = (PMC *)PMC_pmc_val(SELF);
+ STRING * const ret = VTABLE_get_string_keyed(INTERP, agg, key);
PMC_struct_val(SELF) =
VTABLE_nextkey_keyed(INTERP, key, agg, ITERATE_GET_NEXT);
return ret;
@@ -502,16 +507,20 @@
*/
PMC* shift_pmc() {
- PMC * const key = PMC_struct_val(SELF);
- PMC * const agg = PMC_pmc_val(SELF);
- PMC *ret;
+ PMC * const key = (PMC *)PMC_struct_val(SELF);
+ PMC * const agg = (PMC *)PMC_pmc_val(SELF);
+ PMC *ret;
+
if (PMC_int_val(key) == -1) {
real_exception(INTERP, NULL, E_StopIteration, "StopIteration");
return NULL;
}
+
ret = VTABLE_get_pmc_keyed(INTERP, agg, key);
+
PMC_struct_val(SELF) =
VTABLE_nextkey_keyed(INTERP, key, agg, ITERATE_GET_NEXT);
+
return ret;
}
@@ -540,8 +549,8 @@
*/
INTVAL exists_keyed_int(INTVAL idx) {
- PMC * const key = PMC_struct_val(SELF);
- PMC * const agg = PMC_pmc_val(SELF);
+ PMC * const key = (PMC *)PMC_struct_val(SELF);
+ PMC * const agg = (PMC *)PMC_pmc_val(SELF);
return VTABLE_exists_keyed_int(INTERP, agg, PMC_int_val(key) + idx);
}
@@ -582,8 +591,8 @@
*/
INTVAL defined_keyed_int(INTVAL idx) {
- PMC * const key = PMC_struct_val(SELF);
- PMC * const agg = PMC_pmc_val(SELF);
+ PMC * const key = (PMC *)PMC_struct_val(SELF);
+ PMC * const agg = (PMC *)PMC_pmc_val(SELF);
return VTABLE_defined_keyed_int(INTERP, agg, PMC_int_val(key) + idx);
}
@@ -612,8 +621,8 @@
*/
INTVAL type_keyed_int(INTVAL idx) {
- PMC * const key = PMC_struct_val(SELF);
- PMC * const agg = PMC_pmc_val(SELF);
+ PMC * const key = (PMC *)PMC_struct_val(SELF);
+ PMC * const agg = (PMC *)PMC_pmc_val(SELF);
return VTABLE_type_keyed_int(INTERP, agg, PMC_int_val(key) + idx);
}
Modified: trunk/src/pmc/lexpad.pmc
==============================================================================
--- trunk/src/pmc/lexpad.pmc (original)
+++ trunk/src/pmc/lexpad.pmc Tue May 1 23:53:54 2007
@@ -105,7 +105,7 @@
PMC* get_pmc_keyed_str(STRING* name) {
PMC *info = PMC_pmc_val(SELF);
Hash *hash = (Hash *)PMC_struct_val(info);
- parrot_context_t *ctx = PMC_struct_val(SELF);
+ parrot_context_t *ctx = (parrot_context_t *)PMC_struct_val(SELF);
HashBucket *b = parrot_hash_get_bucket(INTERP, hash, name);
INTVAL regno;
@@ -125,7 +125,7 @@
void set_pmc_keyed_str(STRING *name, PMC *value) {
PMC *info = PMC_pmc_val(SELF);
Hash *hash = (Hash *)PMC_struct_val(info);
- parrot_context_t *ctx = PMC_struct_val(SELF);
+ parrot_context_t *ctx = (parrot_context_t *)PMC_struct_val(SELF);
HashBucket *b = parrot_hash_get_bucket(INTERP, hash, name);
INTVAL regno;
Modified: trunk/src/pmc/orderedhash.pmc
==============================================================================
--- trunk/src/pmc/orderedhash.pmc (original)
+++ trunk/src/pmc/orderedhash.pmc Tue May 1 23:53:54 2007
@@ -58,7 +58,7 @@
PMC* get_pmc_keyed_int(INTVAL idx) {
INTVAL n;
- Hash *h = PMC_struct_val(SELF);
+ Hash *h = (Hash *)PMC_struct_val(SELF);
HashBucket *b;
n = h->entries;
@@ -115,7 +115,7 @@
STRING* get_string_keyed_int(INTVAL idx) {
INTVAL n;
- Hash *h = PMC_struct_val(SELF);
+ Hash *h = (Hash *)PMC_struct_val(SELF);
HashBucket *b;
n = h->entries;
@@ -169,7 +169,7 @@
INTVAL get_integer_keyed_int(INTVAL idx) {
INTVAL n;
- Hash *h = PMC_struct_val(SELF);
+ Hash *h = (Hash *)PMC_struct_val(SELF);
HashBucket *b;
n = h->entries;
@@ -229,7 +229,7 @@
FLOATVAL get_number_keyed_int(INTVAL idx) {
INTVAL n;
- Hash *h = PMC_struct_val(SELF);
+ Hash *h = (Hash *)PMC_struct_val(SELF);
HashBucket *b;
n = h->entries;
@@ -293,7 +293,7 @@
void set_pmc_keyed_int(INTVAL idx, PMC *val) {
STRING *key, *fmt;
INTVAL n;
- Hash *h = PMC_struct_val(SELF);
+ Hash *h = (Hash *)PMC_struct_val(SELF);
HashBucket *b;
n = h->entries;
@@ -388,7 +388,7 @@
INTVAL exists_keyed_int(INTVAL idx) {
INTVAL n;
- Hash *h = PMC_struct_val(SELF);
+ Hash *h = (Hash *)PMC_struct_val(SELF);
HashBucket *b;
n = h->entries;
@@ -411,9 +411,9 @@
PMC *item, *next;
if (PObj_get_FLAGS(key) & KEY_integer_FLAG) {
- Hash *h = PMC_struct_val(SELF);
- INTVAL n, idx;
+ Hash *h = (Hash *)PMC_struct_val(SELF);
HashBucket *b;
+ INTVAL n, idx;
idx = key_integer(INTERP, key);
n = h->entries;
@@ -429,7 +429,7 @@
if (!b->key)
return 0;
- item = b->value;
+ item = (PMC *)b->value;
next = key_next(INTERP, key);
if (!next)
@@ -443,7 +443,7 @@
}
INTVAL exists_keyed_str(STRING* key) {
- Hash *h = PMC_struct_val(SELF);
+ Hash *h = (Hash *)PMC_struct_val(SELF);
HashBucket *b = parrot_hash_get_bucket(INTERP, h, key);
if (b && b->key)
@@ -472,7 +472,7 @@
Hash *h;
HashBucket *b;
- h = PMC_struct_val(SELF);
+ h = (Hash *)PMC_struct_val(SELF);
idx = key_integer(INTERP, key);
n = h->entries;
@@ -488,7 +488,7 @@
if (!b->key)
return 0;
- item = b->value;
+ item = (PMC *)b->value;
next = key_next(INTERP, key);
if (!next)
@@ -502,7 +502,7 @@
INTVAL defined_keyed_int(INTVAL idx) {
INTVAL n;
- Hash *h = PMC_struct_val(SELF);
+ Hash *h = (Hash *)PMC_struct_val(SELF);
HashBucket *b;
n = h->entries;
@@ -560,7 +560,7 @@
void delete_keyed_int(INTVAL idx) {
INTVAL n;
- Hash *h = PMC_struct_val(SELF);
+ Hash *h = (Hash *)PMC_struct_val(SELF);
HashBucket *b;
n = h->entries;
@@ -578,7 +578,7 @@
}
void delete_keyed_str(STRING *key) {
- Hash *h = PMC_struct_val(SELF);
+ Hash *h = (Hash *)PMC_struct_val(SELF);
HashBucket *b = parrot_hash_get_bucket(INTERP, h, key);
if (b)
@@ -598,7 +598,7 @@
PMC* clone() {
PMC *dest;
- Hash *hash = PMC_struct_val(SELF);
+ Hash *hash = (Hash *)PMC_struct_val(SELF);
Hash *h_dest;
HashBucket *b;
UINTVAL i;
@@ -609,7 +609,7 @@
parrot_new_pmc_hash_x(INTERP, dest, hash->entry_type,
hash->key_type, hash->compare, hash->hash_val);
- h_dest = PMC_struct_val(dest);
+ h_dest = (Hash *)PMC_struct_val(dest);
for (i = 0; i <= hash->mask; i++) {
b = hash->bs + i;
@@ -648,7 +648,7 @@
void visit(visit_info *info) {
UINTVAL i;
HashBucket *b;
- void *key;
+ STRING *key;
IMAGE_IO *io = info->image_io;
Hash *hash = (Hash *)PMC_struct_val(SELF);
@@ -664,13 +664,13 @@
case VISIT_FREEZE_AT_DESTRUCT:
for (i = 0; i <= hash->mask; i++) {
b = hash->bs + i;
- key = b->key;
+ key = (STRING *)b->key;
if (!key)
continue;
io->vtable->push_string(interp, io, key);
- (info->visit_pmc_now)(interp, b->value, info);
+ (info->visit_pmc_now)(interp, (PMC *)b->value, info);
}
break;
default:
Modified: trunk/src/pmc/parrotinterpreter.pmc
==============================================================================
--- trunk/src/pmc/parrotinterpreter.pmc (original)
+++ trunk/src/pmc/parrotinterpreter.pmc Tue May 1 23:53:54 2007
@@ -293,7 +293,7 @@
*/
- opcode_t* invoke(void* next) {
+ opcode_t* invoke(void *next) {
Interp * new_interp =
(Interp *)PMC_data(SELF);
/*
@@ -310,7 +310,8 @@
/* calculate offset and run */
runops(new_interp, (opcode_t *)PMC_struct_val(SELF) -
(opcode_t *)interp->code->base.data);
- return next;
+
+ return (opcode_t *)next;
}
/*
@@ -655,7 +656,7 @@
}
METHOD void run_gc() {
- Parrot_do_dod_run(PMC_data(SELF), 0);
+ Parrot_do_dod_run(PMC_data_typed(SELF, Parrot_Interp), 0);
}
}
Modified: trunk/src/pmc/parrotthread.pmc
==============================================================================
--- trunk/src/pmc/parrotthread.pmc (original)
+++ trunk/src/pmc/parrotthread.pmc Tue May 1 23:53:54 2007
@@ -123,16 +123,15 @@
*/
void init() {
- /*
- * protect interpreter creation and list handling
- */
+ /* protect interpreter creation and list handling */
LOCK(interpreter_array_mutex);
+
SUPER();
- pt_add_to_interpreters(INTERP, PMC_data(SELF));
+ pt_add_to_interpreters(INTERP, PMC_data_typed(SELF, Parrot_Interp));
+
UNLOCK(interpreter_array_mutex);
- /*
- * can't allow DOD runs for now
- */
+
+ /* can't allow DOD runs for now */
stop_GC(INTERP, PMC_data_typed(SELF, Parrot_Interp));
}
@@ -154,10 +153,9 @@
PMC_data_typed(SELF, Parrot_Interp));
UNLOCK(interpreter_array_mutex);
- /*
- * can't allow DOD runs for now
- */
- stop_GC(INTERP, PMC_data(SELF));
+
+ /* can't allow DOD runs for now */
+ stop_GC(INTERP, PMC_data_typed(SELF, Parrot_Interp));
}
}
Modified: trunk/src/pmc/resizablestringarray.pmc
==============================================================================
--- trunk/src/pmc/resizablestringarray.pmc (original)
+++ trunk/src/pmc/resizablestringarray.pmc Tue May 1 23:53:54 2007
@@ -424,16 +424,18 @@
*/
void unshift_string(STRING *value) {
- STRING **data;
- INTVAL size, i;
+ STRING **data = PMC_data_typed(SELF, STRING **);
+ INTVAL size = PMC_int_val(SELF);
+ INTVAL i;
- size = PMC_int_val(SELF);
- data = (STRING**)PMC_data(SELF);
DYNSELF.set_integer_native(size + 1);
- data = PMC_data(SELF);
+
+ data = PMC_data_typed(SELF, STRING **);
+
for (i = size; i; --i)
data[i] = data[i - 1];
+
DYNSELF.set_string_keyed_int(0, value);
}
@@ -507,13 +509,13 @@
*/
void delete_keyed_int(INTVAL key) {
- STRING **data;
- INTVAL size, i;
- size = PMC_int_val(SELF);
+ STRING **data = PMC_data_typed(SELF, STRING **);
+ INTVAL size = PMC_int_val(SELF);
+ INTVAL i;
- data = PMC_data(SELF);
for (i = key; i < size - 1; ++i)
data[i] = data[i + 1];
+
DYNSELF.set_integer_native(size - 1);
}
@@ -527,15 +529,15 @@
*/
- void delete_keyed(PMC* key) {
- STRING **data;
- INTVAL size, idx, i;
- size = PMC_int_val(SELF);
- idx = key_integer(INTERP, key);
+ void delete_keyed(PMC *key) {
+ INTVAL idx = key_integer(INTERP, key);
+ STRING **data = PMC_data_typed(SELF, STRING **);
+ INTVAL size = PMC_int_val(SELF);
+ INTVAL i;
- data = PMC_data(SELF);
for (i = idx; i < size - 1; ++i)
data[i] = data[i + 1];
+
DYNSELF.set_integer_native(size - 1);
}