[svn:parrot] r40108 - trunk/src/pmc
petdance at svn.parrot.org
petdance at svn.parrot.org
Wed Jul 15 15:08:22 UTC 2009
Author: petdance
Date: Wed Jul 15 15:08:21 2009
New Revision: 40108
URL: https://trac.parrot.org/parrot/changeset/40108
Log:
lots of consting.
Modified:
trunk/src/pmc/hash.pmc
Modified: trunk/src/pmc/hash.pmc
==============================================================================
--- trunk/src/pmc/hash.pmc Wed Jul 15 15:06:53 2009 (r40107)
+++ trunk/src/pmc/hash.pmc Wed Jul 15 15:08:21 2009 (r40108)
@@ -129,8 +129,8 @@
case Hash_key_type_int:
{
/* Pacify compiler about casting INVTAL to void */
- INTVAL int_key = Parrot_str_to_int(interp, key);
- ret = INTVAL2PTR(void *, int_key);
+ const INTVAL int_key = Parrot_str_to_int(interp, key);
+ ret = INTVAL2PTR(void *, int_key);
break;
}
/* Currently PMCs are stringified */
@@ -152,15 +152,15 @@
switch (hash->key_type) {
case Hash_key_type_int:
{
- INTVAL int_key = VTABLE_get_integer(interp, key);
- ret = INTVAL2PTR(void *, int_key);
+ const INTVAL int_key = VTABLE_get_integer(interp, key);
+ ret = INTVAL2PTR(void *, int_key);
break;
}
/* Currently PMCs are stringified */
case Hash_key_type_PMC:
case Hash_key_type_STRING:
{
- STRING *tmp = VTABLE_get_string(interp, key);
+ STRING * const tmp = VTABLE_get_string(interp, key);
if (!tmp)
Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_UNEXPECTED_NULL,
"hash: can't use null as key");
@@ -187,7 +187,7 @@
break;
case enum_type_PMC:
{
- PMC *tmp = get_integer_pmc(interp);
+ PMC * const tmp = get_integer_pmc(interp);
VTABLE_set_integer_native(interp, tmp, value);
ret = INTVAL2PTR(void *, tmp);
}
@@ -209,8 +209,8 @@
switch (hash->entry_type) {
case enum_type_INTVAL:
{
- INTVAL int_val = Parrot_str_to_int(interp, value);
- ret = INTVAL2PTR(void *, int_val);
+ const INTVAL int_val = Parrot_str_to_int(interp, value);
+ ret = INTVAL2PTR(void *, int_val);
break;
}
case enum_type_STRING:
@@ -218,7 +218,7 @@
break;
case enum_type_PMC:
{
- PMC *s = get_string_pmc(interp);
+ PMC * const s = get_string_pmc(interp);
VTABLE_set_string_native(interp, s, value);
ret = (void *)s;
}
@@ -237,8 +237,8 @@
switch (hash->entry_type) {
case enum_type_INTVAL:
{
- INTVAL int_val = VTABLE_get_integer(interp, value);
- ret = INTVAL2PTR(void *, int_val);
+ const INTVAL int_val = VTABLE_get_integer(interp, value);
+ ret = INTVAL2PTR(void *, int_val);
break;
}
case enum_type_STRING:
@@ -261,7 +261,7 @@
switch (hash->entry_type) {
case enum_type_INTVAL:
{
- INTVAL tmp = value;
+ const INTVAL tmp = value;
ret = (void*)tmp;
}
break;
@@ -270,7 +270,7 @@
break;
case enum_type_PMC:
{
- PMC *tmp = get_number_pmc(interp);
+ PMC * const tmp = get_number_pmc(interp);
VTABLE_set_number_native(interp, tmp, value);
ret = (void *)tmp;
}
@@ -355,7 +355,7 @@
case enum_type_INTVAL:
{
/* Pacify compiler about casting */
- INTVAL tmp = (INTVAL)value;
+ const INTVAL tmp = (INTVAL)value;
ret = tmp;
}
break;
@@ -404,7 +404,7 @@
}
VTABLE void destroy() {
- Hash *hash = (Hash *)SELF.get_pointer();
+ Hash * const hash = (Hash *)SELF.get_pointer();
if (hash)
parrot_hash_destroy(INTERP, hash);
@@ -421,7 +421,7 @@
*/
VTABLE void mark() {
- Hash *hash = (Hash *)SELF.get_pointer();
+ Hash * const hash = (Hash *)SELF.get_pointer();
if (hash != NULL)
parrot_mark_hash(INTERP, hash);
}
@@ -456,8 +456,8 @@
*/
VTABLE void set_pointer(void *ptr) {
- Hash *old_hash = (Hash *)SELF.get_pointer();
- Hash *new_hash = (Hash *)ptr;
+ Hash * const old_hash = (Hash *)SELF.get_pointer();
+ Hash * const new_hash = (Hash *)ptr;
PARROT_HASH(SELF)->hash = new_hash;
new_hash->container = SELF;
@@ -476,8 +476,8 @@
=cut
*/
VTABLE void set_integer_native(INTVAL type) {
- Hash *old_hash = (Hash *)SELF.get_pointer();
- Hash *new_hash = 0;
+ Hash * const old_hash = (Hash *)SELF.get_pointer();
+ Hash *new_hash;
if (type == Hash_key_type_STRING)
new_hash = parrot_new_hash(INTERP);
@@ -509,7 +509,7 @@
}
METHOD get_key_type() {
- INTVAL ret = ((Hash *)SELF.get_pointer())->key_type;
+ const INTVAL ret = ((Hash *)SELF.get_pointer())->key_type;
RETURN(INTVAL ret);
}
@@ -526,7 +526,7 @@
*/
METHOD set_value_type(INTVAL type) {
Hash *old_hash = (Hash *)SELF.get_pointer();
- Hash *new_hash = 0;
+ Hash *new_hash;
/*
If someone called Hash.set_pointer with NULL pointer...
@@ -628,7 +628,7 @@
PMC *val;
for (i = 0; i < (int)key->strlen; ++i) {
- if (!isdigit((unsigned char)((char *)key->strstart)[i])) {
+ if (!isdigit((unsigned char)((const char *)key->strstart)[i])) {
all_digit = 0;
break;
}
@@ -700,7 +700,7 @@
/* Handling Keys */
VTABLE INTVAL get_integer_keyed(PMC *key) {
const Hash * const hash = (Hash *)SELF.get_pointer();
- HashBucket *b = parrot_hash_get_bucket(INTERP, hash,
+ HashBucket * const b = parrot_hash_get_bucket(INTERP, hash,
hash_key_from_pmc(INTERP, hash, key));
PMC *valpmc;
PMC *nextkey;
@@ -728,10 +728,10 @@
*/
VTABLE void set_integer_keyed(PMC *key, INTVAL value) {
- Hash *hash = (Hash *)SELF.get_pointer();
- void *keystr = hash_key_from_pmc(INTERP, hash, key);
- PMC *nextkey = key_next(INTERP, key);
- PMC *box = NULL;
+ Hash * const hash = (Hash *)SELF.get_pointer();
+ void * const keystr = hash_key_from_pmc(INTERP, hash, key);
+ PMC * const nextkey = key_next(INTERP, key);
+ PMC *box;
HashBucket *b;
if (!nextkey) {
@@ -820,7 +820,7 @@
PMC *nextkey;
PMC *valpmc;
const Hash * const hash = (Hash *)VTABLE_get_pointer(interp, pmc);
- void *keystr = hash_key_from_pmc(INTERP, hash, key);
+ void * const keystr = hash_key_from_pmc(INTERP, hash, key);
HashBucket * const b = parrot_hash_get_bucket(INTERP, hash, keystr);
if (!b)
@@ -880,7 +880,7 @@
VTABLE STRING *get_string_keyed(PMC *key) {
const Hash * const hash = (Hash *)SELF.get_pointer();
- HashBucket *b = parrot_hash_get_bucket(INTERP, hash,
+ HashBucket * const b = parrot_hash_get_bucket(INTERP, hash,
hash_key_from_pmc(INTERP, hash, key));
PMC *valpmc;
PMC *nextkey;
@@ -908,13 +908,12 @@
*/
VTABLE void set_string_keyed(PMC *key, STRING *value) {
- Hash *hash = (Hash *)SELF.get_pointer();
- void *keystr = hash_key_from_pmc(INTERP, hash, key);
- PMC *nextkey;
- PMC *box = NULL;
+ Hash * const hash = (Hash *)SELF.get_pointer();
+ void * const keystr = hash_key_from_pmc(INTERP, hash, key);
+ PMC * const nextkey = key_next(INTERP, key);
+ PMC *box;
HashBucket *b;
- nextkey = key_next(INTERP, key);
if (!nextkey) {
parrot_hash_put(INTERP, hash, keystr,
hash_value_from_string(INTERP, hash, value));
@@ -943,14 +942,14 @@
*/
VTABLE void set_string_keyed_str(STRING *key, STRING *value) {
- Hash *hash = (Hash *)SELF.get_pointer();
+ Hash * const hash = (Hash *)SELF.get_pointer();
parrot_hash_put(INTERP, hash,
hash_key_from_string(INTERP, hash, key),
hash_value_from_string(INTERP, hash, value));
}
VTABLE void set_string_keyed_int(INTVAL key, STRING *value) {
- Hash *hash = (Hash *)SELF.get_pointer();
+ Hash * const hash = (Hash *)SELF.get_pointer();
parrot_hash_put(INTERP, hash,
hash_key_from_int(INTERP, hash, key),
hash_value_from_string(INTERP, hash, value));
@@ -995,7 +994,7 @@
/* Compound Key */
VTABLE PMC *get_pmc_keyed(PMC *key) {
const Hash * const hash = (Hash *)SELF.get_pointer();
- HashBucket *b = parrot_hash_get_bucket(INTERP, hash,
+ HashBucket * const b = parrot_hash_get_bucket(INTERP, hash,
hash_key_from_pmc(INTERP, hash, key));
PMC *valpmc;
PMC *nextkey;
@@ -1023,17 +1022,15 @@
*/
VTABLE void set_number_keyed(PMC *key, FLOATVAL value) {
- Hash *hash = (Hash *)SELF.get_pointer();
- void *keystr;
- PMC *nextkey;
+ Hash * const hash = (Hash *)SELF.get_pointer();
+ void * const keystr = hash_key_from_pmc(INTERP, hash, key);
+ PMC * const nextkey = key_next(INTERP, key);
PMC *box;
HashBucket *b;
- keystr = hash_key_from_pmc(INTERP, hash, key);
- nextkey = key_next(INTERP, key);
if (!nextkey) {
- PMC *val = get_number_pmc(INTERP);
+ PMC * const val = get_number_pmc(INTERP);
VTABLE_set_number_native(INTERP, val, value);
parrot_hash_put(INTERP, hash, keystr, hash_value_from_pmc(INTERP, hash, val));
return;
@@ -1076,15 +1073,12 @@
*/
VTABLE void set_pmc_keyed(PMC *key, PMC *value) {
- Hash *hash = (Hash *)SELF.get_pointer();
- void *keystr;
- PMC *nextkey;
+ Hash * const hash = (Hash *)SELF.get_pointer();
+ void * const keystr = hash_key_from_pmc(INTERP, hash, key);
+ PMC * const nextkey = key_next(INTERP, key);
PMC *box;
HashBucket *b;
- keystr = hash_key_from_pmc(INTERP, hash, key);
- nextkey = key_next(INTERP, key);
-
if (!nextkey) {
parrot_hash_put(INTERP, hash, keystr, value);
return;
@@ -1115,7 +1109,7 @@
*/
VTABLE void set_pmc_keyed_str(STRING *key, PMC *value) {
- Hash *hash = (Hash *)SELF.get_pointer();
+ Hash * const hash = (Hash *)SELF.get_pointer();
parrot_hash_put(INTERP, hash, hash_key_from_string(INTERP, hash, key),
hash_value_from_pmc(INTERP, hash, value));
}
@@ -1129,7 +1123,7 @@
*/
VTABLE INTVAL exists_keyed_str(STRING *key) {
- Hash *hash = (Hash *)SELF.get_pointer();
+ Hash * const hash = (Hash *)SELF.get_pointer();
HashBucket * const b = parrot_hash_get_bucket(INTERP, hash,
hash_key_from_string(INTERP, hash, key));
return b != NULL;
@@ -1146,9 +1140,9 @@
*/
VTABLE INTVAL exists_keyed(PMC *key) {
- Hash * const h = (Hash *)SELF.get_pointer();
- void *sx = hash_key_from_pmc(INTERP, h, key);
- HashBucket *b = parrot_hash_get_bucket(INTERP, h, sx);
+ Hash * const h = (Hash *)SELF.get_pointer();
+ void * const sx = hash_key_from_pmc(INTERP, h, key);
+ HashBucket * const b = parrot_hash_get_bucket(INTERP, h, sx);
/* no such key */
if (!b)
@@ -1194,9 +1188,9 @@
*/
VTABLE INTVAL defined_keyed(PMC *key) {
- Hash * const h = (Hash *)SELF.get_pointer();
- void *sx = hash_key_from_pmc(INTERP, h, key);
- HashBucket *b = parrot_hash_get_bucket(INTERP, h, sx);
+ Hash * const h = (Hash *)SELF.get_pointer();
+ void * const sx = hash_key_from_pmc(INTERP, h, key);
+ HashBucket * const b = parrot_hash_get_bucket(INTERP, h, sx);
/* no such key */
if (!b)
@@ -1220,7 +1214,7 @@
*/
VTABLE void delete_keyed_str(STRING *key) {
- Hash *hash = (Hash *)SELF.get_pointer();
+ Hash * const hash = (Hash *)SELF.get_pointer();
parrot_hash_delete(INTERP, hash, hash_key_from_string(INTERP, hash, key));
}
@@ -1235,9 +1229,9 @@
*/
VTABLE void delete_keyed(PMC *key) {
- Hash * const h = (Hash *)SELF.get_pointer();
- void *sx = hash_key_from_pmc(INTERP, h, key);
- HashBucket *b = parrot_hash_get_bucket(INTERP, h, sx);
+ Hash * const h = (Hash *)SELF.get_pointer();
+ void * const sx = hash_key_from_pmc(INTERP, h, key);
+ HashBucket * const b = parrot_hash_get_bucket(INTERP, h, sx);
/* no such key */
if (!b)
@@ -1403,7 +1397,7 @@
VTABLE void freeze(visit_info *info) {
IMAGE_IO * const io = info->image_io;
- Hash * const hash = (Hash *)SELF.get_pointer();;
+ Hash * const hash = (Hash *)SELF.get_pointer();;
SUPER(info);
VTABLE_push_integer(INTERP, io, VTABLE_elements(INTERP, SELF));
More information about the parrot-commits
mailing list