Author: petdance
Date: Wed May 3 23:20:10 2006
New Revision: 12496
Modified:
trunk/src/exceptions.c
trunk/src/pmc/float.pmc
trunk/src/pmc/hash.pmc
trunk/src/pmc/resizablebooleanarray.pmc
trunk/src/pmc/sub.pmc
Log:
consting of local parms on my way to shrinking the 64-byte bits
Modified: trunk/src/exceptions.c
==============================================================================
--- trunk/src/exceptions.c (original)
+++ trunk/src/exceptions.c Wed May 3 23:20:10 2006
@@ -1,5 +1,5 @@
/*
-Copyright: 2001-2003 The Perl Foundation. All Rights Reserved.
+Copyright: 2001-2006 The Perl Foundation. All Rights Reserved.
$Id$
=head1 NAME
@@ -668,7 +668,7 @@
int exitcode, const char *format, ...)
{
STRING *msg;
- Parrot_exception *the_exception = interpreter->exceptions;
+ Parrot_exception * const the_exception = interpreter->exceptions;
/*
* if profiling remember end time of lastop and
@@ -676,8 +676,8 @@
*/
if (interpreter->profile &&
Interp_flags_TEST(interpreter, PARROT_PROFILE_FLAG)) {
- RunProfile *profile = interpreter->profile;
- FLOATVAL now = Parrot_floatval_time();
+ RunProfile * const profile = interpreter->profile;
+ const FLOATVAL now = Parrot_floatval_time();
profile->data[profile->cur_op].time += now - profile->starttime;
profile->cur_op = PARROT_PROF_EXCEPTION;
profile->starttime = now;
@@ -726,12 +726,11 @@
void
Parrot_init_exceptions(Interp *interpreter) {
int i;
- PMC *ex;
interpreter->exception_list = mem_sys_allocate(
sizeof(PMC*) * (E_LAST_PYTHON_E + 1));
for (i = 0; i <= E_LAST_PYTHON_E; ++i) {
- ex = pmc_new(interpreter, enum_class_Exception);
+ PMC * const ex = pmc_new(interpreter, enum_class_Exception);
interpreter->exception_list[i] = ex;
VTABLE_set_integer_keyed_int(interpreter, ex, 1, i);
}
Modified: trunk/src/pmc/float.pmc
==============================================================================
--- trunk/src/pmc/float.pmc (original)
+++ trunk/src/pmc/float.pmc Wed May 3 23:20:10 2006
@@ -1,5 +1,5 @@
/*
-Copyright: 2003 The Perl Foundation. All Rights Reserved.
+Copyright: 2003-2006 The Perl Foundation. All Rights Reserved.
$Id$
=head1 NAME
@@ -46,10 +46,9 @@
*/
PMC* new_from_string(STRING *rep, INTVAL flags) {
- INTVAL type;
PMC *res;
+ const INTVAL type = SELF->vtable->base_type;
- type = SELF->vtable->base_type;
if (flags & PObj_constant_FLAG)
res = constant_pmc_new(INTERP, type);
else
@@ -118,9 +117,7 @@
STRING* get_repr () {
double d = (double) PMC_num_val(SELF);
- const char *sign = "-";
- if (!signbit(PMC_num_val(SELF)))
- sign = "";
+ const char * const sign = signbit(PMC_num_val(SELF)) ? "-" : "";
d = fabs(d);
return Parrot_sprintf_c(INTERP, "%s" FLOATVAL_FMT, sign, d);
}
@@ -232,7 +229,7 @@
*/
PMC* neg (PMC * dest) {
- FLOATVAL a = - DYNSELF.get_number();
+ const FLOATVAL a = - DYNSELF.get_number();
if (!dest)
dest = pmc_new(INTERP, SELF->vtable->base_type);
VTABLE_set_number_native(INTERP, dest, a);
@@ -240,7 +237,7 @@
}
void i_neg() {
- FLOATVAL a = - DYNSELF.get_number();
+ const FLOATVAL a = - DYNSELF.get_number();
VTABLE_set_number_native(INTERP, SELF, a);
}
@@ -284,13 +281,11 @@
INTVAL cmp(PMC* value) {
MMD_Float: {
- FLOATVAL diff;
- diff = PMC_num_val(SELF) - PMC_num_val(value);
+ const FLOATVAL diff = PMC_num_val(SELF) - PMC_num_val(value);
return diff > 0 ? 1 : diff < 0 ? -1 : 0;
}
MMD_DEFAULT: {
- FLOATVAL diff;
- diff = PMC_num_val(SELF) - VTABLE_get_number(INTERP, value);
+ const FLOATVAL diff = PMC_num_val(SELF) -
VTABLE_get_number(INTERP, value);
return diff > 0 ? 1 : diff < 0 ? -1 : 0;
}
}
@@ -307,13 +302,11 @@
INTVAL cmp_num(PMC* value) {
MMD_Float: {
- FLOATVAL diff;
- diff = PMC_num_val(SELF) - PMC_num_val(value);
+ const FLOATVAL diff = PMC_num_val(SELF) - PMC_num_val(value);
return diff > 0 ? 1 : diff < 0 ? -1 : 0;
}
MMD_DEFAULT: {
- FLOATVAL diff;
- diff = PMC_num_val(SELF) - VTABLE_get_number(INTERP, value);
+ const FLOATVAL diff = PMC_num_val(SELF) -
VTABLE_get_number(INTERP, value);
return diff > 0 ? 1 : diff < 0 ? -1 : 0;
}
}
@@ -358,7 +351,7 @@
*/
PMC* absolute(PMC *dest) {
- FLOATVAL a = fabs(DYNSELF.get_number());
+ const FLOATVAL a = fabs(DYNSELF.get_number());
if (!dest)
dest = pmc_new(INTERP, SELF->vtable->base_type);
VTABLE_set_number_native(INTERP, dest, a);
@@ -366,7 +359,7 @@
}
void i_absolute() {
- FLOATVAL a = fabs(DYNSELF.get_number());
+ const FLOATVAL a = fabs(DYNSELF.get_number());
VTABLE_set_number_native(INTERP, SELF, a);
}
@@ -380,7 +373,7 @@
*/
void freeze(visit_info *info) {
- IMAGE_IO *io = info->image_io;
+ IMAGE_IO * const io = info->image_io;
SUPER(info);
io->vtable->push_float(INTERP, io, PMC_num_val(SELF));
}
@@ -395,7 +388,7 @@
*/
void thaw(visit_info *info) {
- IMAGE_IO *io = info->image_io;
+ IMAGE_IO * const io = info->image_io;
SUPER(info);
if (info->extra_flags == EXTRA_IS_NULL)
PMC_num_val(SELF) = io->vtable->shift_float(INTERP, io);
@@ -447,94 +440,94 @@
*/
METHOD PMC* acos() {
- PMC *d = pmc_new(INTERP, SELF->vtable->base_type);
+ PMC * const d = pmc_new(INTERP, SELF->vtable->base_type);
PMC_num_val(d) = acos(PMC_num_val(SELF));
return d;
}
METHOD PMC* cos() {
- PMC *d = pmc_new(INTERP,
+ PMC * const d = pmc_new(INTERP,
Parrot_get_ctx_HLL_type(INTERP, enum_class_Float));
PMC_num_val(d) = cos(VTABLE_get_number(interpreter, SELF));
return d;
}
METHOD PMC* asec() {
- PMC *d = pmc_new(INTERP, SELF->vtable->base_type);
+ PMC * const d = pmc_new(INTERP, SELF->vtable->base_type);
PMC_num_val(d) = acos(1.0 / PMC_num_val(SELF));
return d;
}
METHOD PMC* asin() {
- PMC *d = pmc_new(INTERP, SELF->vtable->base_type);
+ PMC * const d = pmc_new(INTERP, SELF->vtable->base_type);
PMC_num_val(d) = asin(PMC_num_val(SELF));
return d;
}
METHOD PMC* atan() {
- PMC *d = pmc_new(INTERP, SELF->vtable->base_type);
+ PMC * const d = pmc_new(INTERP, SELF->vtable->base_type);
PMC_num_val(d) = atan(PMC_num_val(SELF));
return d;
}
METHOD PMC* atan2(PMC *val) {
- PMC *d = pmc_new(INTERP, SELF->vtable->base_type);
+ PMC * const d = pmc_new(INTERP, SELF->vtable->base_type);
PMC_num_val(d) = atan2(PMC_num_val(SELF), PMC_num_val(val));
return d;
}
METHOD PMC* cosh() {
- PMC *d = pmc_new(INTERP, SELF->vtable->base_type);
+ PMC * const d = pmc_new(INTERP, SELF->vtable->base_type);
PMC_num_val(d) = cosh(PMC_num_val(SELF));
return d;
}
METHOD PMC* exp() {
- PMC *d = pmc_new(INTERP, SELF->vtable->base_type);
+ PMC * const d = pmc_new(INTERP, SELF->vtable->base_type);
PMC_num_val(d) = exp(PMC_num_val(SELF));
return d;
}
METHOD PMC* ln() {
- PMC *d = pmc_new(INTERP, SELF->vtable->base_type);
+ PMC * const d = pmc_new(INTERP, SELF->vtable->base_type);
PMC_num_val(d) = log(PMC_num_val(SELF));
return d;
}
METHOD PMC* log10() {
- PMC *d = pmc_new(INTERP, SELF->vtable->base_type);
+ PMC * const d = pmc_new(INTERP, SELF->vtable->base_type);
PMC_num_val(d) = log10(PMC_num_val(SELF));
return d;
}
METHOD PMC* log2() {
- PMC *d = pmc_new(INTERP, SELF->vtable->base_type);
+ PMC * const d = pmc_new(INTERP, SELF->vtable->base_type);
PMC_num_val(d) = log(PMC_num_val(SELF)) / log(2.0);
return d;
}
METHOD PMC* sec() {
- PMC *d = pmc_new(INTERP, SELF->vtable->base_type);
+ PMC * const d = pmc_new(INTERP, SELF->vtable->base_type);
PMC_num_val(d) = 1.0 / cos(PMC_num_val(SELF));
return d;
}
METHOD PMC* sech() {
- PMC *d = pmc_new(INTERP, SELF->vtable->base_type);
+ PMC * const d = pmc_new(INTERP, SELF->vtable->base_type);
PMC_num_val(d) = 1.0 / cosh(PMC_num_val(SELF));
return d;
}
METHOD PMC* sin() {
- PMC *d = pmc_new(INTERP, SELF->vtable->base_type);
+ PMC * const d = pmc_new(INTERP, SELF->vtable->base_type);
PMC_num_val(d) = sin(PMC_num_val(SELF));
return d;
}
METHOD PMC* sinh() {
- PMC *d = pmc_new(INTERP, SELF->vtable->base_type);
+ PMC * const d = pmc_new(INTERP, SELF->vtable->base_type);
PMC_num_val(d) = sinh(PMC_num_val(SELF));
return d;
}
METHOD PMC* tan() {
- PMC *d = pmc_new(INTERP, SELF->vtable->base_type);
+ PMC * const d = pmc_new(INTERP, SELF->vtable->base_type);
PMC_num_val(d) = tan(PMC_num_val(SELF));
return d;
}
METHOD PMC* tanh() {
- PMC *d = pmc_new(INTERP, SELF->vtable->base_type);
+ PMC * const d = pmc_new(INTERP, SELF->vtable->base_type);
PMC_num_val(d) = tanh(PMC_num_val(SELF));
return d;
}
METHOD PMC* sqrt() {
- PMC *d = pmc_new(INTERP, SELF->vtable->base_type);
+ PMC * const d = pmc_new(INTERP, SELF->vtable->base_type);
PMC_num_val(d) = sqrt(PMC_num_val(SELF));
return d;
}
Modified: trunk/src/pmc/hash.pmc
==============================================================================
--- trunk/src/pmc/hash.pmc (original)
+++ trunk/src/pmc/hash.pmc Wed May 3 23:20:10 2006
@@ -173,10 +173,10 @@
*/
INTVAL type_keyed_str (STRING* key) {
- HashBucket* b = hash_get_bucket(INTERP, (Hash*) PMC_struct_val(SELF),
+ HashBucket* const b = hash_get_bucket(INTERP, (Hash*)
PMC_struct_val(SELF),
key);
if (b == NULL) {
- PMC * none = get_none_pmc(INTERP, SELF->vtable->base_type);
+ PMC * const none = get_none_pmc(INTERP, SELF->vtable->base_type);
return VTABLE_type(INTERP, none);
}
@@ -196,11 +196,11 @@
INTVAL type_keyed (PMC* key) {
PMC* valpmc;
PMC* nextkey;
- STRING* keystr = make_hash_key(INTERP, key);
- HashBucket* b = hash_get_bucket(INTERP, (Hash*) PMC_struct_val(SELF),
+ STRING* const keystr = make_hash_key(INTERP, key);
+ HashBucket* const b = hash_get_bucket(INTERP, (Hash*)
PMC_struct_val(SELF),
keystr);
if (b == NULL) {
- PMC * none = get_none_pmc(INTERP, SELF->vtable->base_type);
+ PMC * const none = get_none_pmc(INTERP, SELF->vtable->base_type);
return VTABLE_type(INTERP, none);
}
@@ -222,7 +222,7 @@
*/
PMC* clone () {
- PMC* dest = pmc_new_noinit(INTERP, SELF->vtable->base_type);
+ PMC* const dest = pmc_new_noinit(INTERP, SELF->vtable->base_type);
PObj_custom_mark_destroy_SETALL(dest);
hash_clone(INTERP, (Hash *)PMC_struct_val(SELF),
(Hash**)&PMC_struct_val(dest));
@@ -255,11 +255,11 @@
*/
INTVAL get_integer_keyed_str (STRING* key) {
- HashBucket *b = hash_get_bucket(INTERP, (Hash*) PMC_struct_val(SELF),
+ HashBucket * const b = hash_get_bucket(INTERP, (Hash*)
PMC_struct_val(SELF),
key);
if (b == NULL) {
/* XXX Warning: use of uninitialized value */
- PMC * none = get_none_pmc(INTERP, SELF->vtable->base_type);
+ PMC * const none = get_none_pmc(INTERP, SELF->vtable->base_type);
return VTABLE_get_integer(INTERP, none);
}
@@ -267,7 +267,7 @@
}
INTVAL get_integer_keyed_int (INTVAL key) {
- STRING *s = string_from_int(INTERP, key);
+ STRING * const s = string_from_int(INTERP, key);
return SELF.get_integer_keyed_str(s);
}
/*
@@ -283,7 +283,7 @@
INTVAL get_integer_keyed (PMC* key) {
PMC* valpmc;
STRING* keystr;
- Hash *hash = PMC_struct_val(SELF);
+ Hash * const hash = PMC_struct_val(SELF);
HashBucket *b;
PMC* nextkey;
@@ -305,7 +305,7 @@
b = hash_get_bucket(INTERP, hash, keystr);
if (b == NULL) {
/* XXX Warning: use of uninitialized value */
- PMC * none = get_none_pmc(INTERP, SELF->vtable->base_type);
+ PMC * const none = get_none_pmc(INTERP, SELF->vtable->base_type);
return VTABLE_get_integer(INTERP, none);
}
@@ -327,11 +327,11 @@
*/
FLOATVAL get_number_keyed_str (STRING* key) {
- HashBucket *b = hash_get_bucket(INTERP, (Hash*) PMC_struct_val(SELF),
+ HashBucket * const b = hash_get_bucket(INTERP, (Hash*)
PMC_struct_val(SELF),
key);
if (b == NULL) {
/* XXX Warning: Use of uninitialized value */
- PMC * none = get_none_pmc(INTERP, SELF->vtable->base_type);
+ PMC * const none = get_none_pmc(INTERP, SELF->vtable->base_type);
return VTABLE_get_number(INTERP, none);
}
@@ -339,7 +339,7 @@
}
FLOATVAL get_number_keyed_int (INTVAL key) {
- STRING *s = string_from_int(INTERP, key);
+ STRING * const s = string_from_int(INTERP, key);
return SELF.get_number_keyed_str(s);
}
/*
@@ -354,13 +354,13 @@
FLOATVAL get_number_keyed (PMC* key) {
PMC* valpmc;
- STRING* keystr = make_hash_key(INTERP, key);
- HashBucket *b = hash_get_bucket(INTERP, (Hash*) PMC_struct_val(SELF),
+ STRING* const keystr = make_hash_key(INTERP, key);
+ HashBucket * const b = hash_get_bucket(INTERP, (Hash*)
PMC_struct_val(SELF),
keystr);
PMC* nextkey;
if (b == NULL) {
/* XXX Warning: Use of uninitialized value */
- PMC * none = get_none_pmc(INTERP, SELF->vtable->base_type);
+ PMC * const none = get_none_pmc(INTERP, SELF->vtable->base_type);
return VTABLE_get_number(INTERP, none);
}
@@ -393,14 +393,13 @@
STRING* get_repr () {
/* TODO use freeze */
- PMC *iter = VTABLE_get_iter(INTERP, SELF);
- STRING *res;
- INTVAL j, n;
+ PMC * const iter = VTABLE_get_iter(INTERP, SELF);
+ STRING *res = string_from_cstring(INTERP, "{", 0);
+ const INTVAL n = VTABLE_elements(INTERP, SELF);
+ INTVAL j;
- res = string_from_cstring(INTERP, "{", 0);
- n = VTABLE_elements(INTERP, SELF);
for (j = 0; j < n; ++j) {
- STRING *key = VTABLE_shift_string(INTERP, iter);
+ STRING * const key = VTABLE_shift_string(INTERP, iter);
int i,all_digit = 1;
PMC *val;
@@ -445,11 +444,11 @@
*/
STRING* get_string_keyed_str (STRING* key) {
- HashBucket *b = hash_get_bucket(INTERP, (Hash*) PMC_struct_val(SELF),
+ HashBucket * const b = hash_get_bucket(INTERP, (Hash*)
PMC_struct_val(SELF),
key);
if (b == NULL) {
/* XXX Warning: use of uninitialized value */
- PMC * none = get_none_pmc(INTERP, SELF->vtable->base_type);
+ PMC * const none = get_none_pmc(INTERP, SELF->vtable->base_type);
return VTABLE_get_string(INTERP, none);
}
@@ -457,7 +456,7 @@
}
STRING* get_string_keyed_int (INTVAL key) {
- STRING *s = string_from_int(INTERP, key);
+ STRING * const s = string_from_int(INTERP, key);
return SELF.get_string_keyed_str(s);
}
@@ -475,7 +474,7 @@
PMC* valpmc;
STRING* keystr;
HashBucket *b;
- Hash *hash = PMC_struct_val(SELF);
+ Hash * const hash = PMC_struct_val(SELF);
PMC* nextkey;
switch (PObj_get_FLAGS(key) & KEY_type_FLAGS) {
@@ -492,7 +491,7 @@
b = hash_get_bucket(INTERP, hash, keystr);
if (b == NULL) {
/* XXX Warning: use of uninitialized value */
- PMC * none = get_none_pmc(INTERP, SELF->vtable->base_type);
+ PMC * const none = get_none_pmc(INTERP, SELF->vtable->base_type);
return VTABLE_get_string(INTERP, none);
}
@@ -542,8 +541,8 @@
*/
PMC* get_pmc_keyed_str (STRING* key) {
- HashBucket *b = hash_get_bucket(INTERP, (Hash*) PMC_struct_val(SELF),
- key);
+ HashBucket * const b =
+ hash_get_bucket(INTERP, (Hash*) PMC_struct_val(SELF), key);
if (b == NULL) {
/* XXX should store the undef for consistency */
return get_none_pmc(INTERP, SELF->vtable->base_type);
@@ -552,7 +551,7 @@
}
PMC* get_pmc_keyed_int (INTVAL key) {
- STRING *s = string_from_int(INTERP, key);
+ STRING * const s = string_from_int(INTERP, key);
return SELF.get_pmc_keyed_str(s);
}
@@ -571,8 +570,9 @@
*/
PMC* get_iter () {
- PMC *iter = pmc_new_init(INTERP, enum_class_Iterator, SELF);
- PMC *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;
@@ -586,8 +586,8 @@
}
PMC* get_pmc_keyed (PMC* key) {
+ Hash * const hash = PMC_struct_val(SELF);
STRING* keystr;
- Hash *hash = PMC_struct_val(SELF);
HashBucket *b;
PMC* nextkey;
PMC* result;
@@ -598,12 +598,12 @@
* check if we really have Hash_key_type_int
*/
if (hash->key_type == Hash_key_type_int) {
- INTVAL i = (INTVAL)hash_get_idx(INTERP, hash, key);
+ const INTVAL i = (INTVAL)hash_get_idx(INTERP, hash, key);
result = pmc_new(INTERP, enum_class_Integer);
PMC_int_val(result) = i;
}
else {
- STRING *s = hash_get_idx(INTERP, hash, key);
+ STRING * const s = hash_get_idx(INTERP, hash, key);
result = pmc_new(INTERP, enum_class_String);
VTABLE_set_string_native(INTERP, result, s);
}
@@ -678,7 +678,7 @@
*/
void set_integer_keyed_str (STRING* key, INTVAL value) {
- PMC* val = get_integer_pmc(INTERP, SELF->vtable->base_type);
+ PMC* const val = get_integer_pmc(INTERP, SELF->vtable->base_type);
PMC_int_val(val) = value;
hash_put(INTERP, PMC_struct_val(SELF), key, val);
@@ -725,7 +725,7 @@
*/
void set_number_keyed_str (STRING* key, FLOATVAL value) {
- PMC* val = get_number_pmc(INTERP, SELF->vtable->base_type);
+ PMC* const val = get_number_pmc(INTERP, SELF->vtable->base_type);
PMC_num_val(val) = value;
hash_put(INTERP, PMC_struct_val(SELF), key, val);
@@ -748,7 +748,7 @@
keystr = make_hash_key(INTERP, key);
nextkey = key_next(INTERP, key);
if (nextkey == NULL) {
- PMC* val = get_string_pmc(INTERP, SELF->vtable->base_type);
+ PMC* const val = get_string_pmc(INTERP, SELF->vtable->base_type);
VTABLE_set_string_native(INTERP, val, value);
hash_put(INTERP, PMC_struct_val(SELF), keystr, val);
return;
@@ -770,7 +770,7 @@
*/
void set_string_keyed_str (STRING* key, STRING* value) {
- PMC* val = get_string_pmc(INTERP, SELF->vtable->base_type);
+ PMC* const val = get_string_pmc(INTERP, SELF->vtable->base_type);
VTABLE_set_string_native(INTERP, val, value);
hash_put(INTERP, PMC_struct_val(SELF), key, val);
@@ -831,7 +831,7 @@
*/
INTVAL is_equal (PMC* value) {
- PMC *iter = VTABLE_get_iter(INTERP, SELF);
+ PMC * const iter = VTABLE_get_iter(INTERP, SELF);
INTVAL j, n;
/* TODO: comparing Hash and PerlHash should probably be possible */
@@ -841,7 +841,7 @@
if (VTABLE_elements(INTERP, value) != n)
return 0;
for (j = 0; j < n; ++j) {
- STRING *key = VTABLE_shift_string(INTERP, iter);
+ STRING * const key = VTABLE_shift_string(INTERP, iter);
PMC *item1, *item2;
if (!VTABLE_exists_keyed_str(INTERP, value, key))
return 0;
@@ -864,8 +864,8 @@
*/
INTVAL exists_keyed_str(STRING* key) {
- HashBucket *b = hash_get_bucket(INTERP, (Hash*) PMC_struct_val(SELF),
- key);
+ HashBucket * const b =
+ hash_get_bucket(INTERP, (Hash*) PMC_struct_val(SELF), key);
return b != NULL;
}
@@ -880,10 +880,10 @@
*/
INTVAL exists_keyed(PMC* key) {
- STRING * sx;
- Hash * h = (Hash *)PMC_struct_val(SELF);
+ Hash * const h = (Hash *)PMC_struct_val(SELF);
+ STRING * const sx = key_string(INTERP, key);
HashBucket *b;
- sx = key_string(INTERP, key);
+
key = key_next(INTERP, key);
b = hash_get_bucket(INTERP, h, sx);
if (b == NULL)
@@ -902,8 +902,9 @@
*/
INTVAL defined_keyed_str(STRING* key) {
- HashBucket *b = hash_get_bucket(INTERP, (Hash*) PMC_struct_val(SELF),
- key);
+ HashBucket * const b =
+ hash_get_bucket(INTERP, (Hash*) PMC_struct_val(SELF), key);
+
if (b == NULL)
return 0; /* no such key */
return VTABLE_defined(INTERP, (PMC*)b->value);
@@ -920,10 +921,10 @@
*/
INTVAL defined_keyed(PMC* key) {
- STRING * sx;
- Hash * h = (Hash *)PMC_struct_val(SELF);
+ Hash * const h = (Hash *)PMC_struct_val(SELF);
+ STRING * const sx = key_string(INTERP, key);
HashBucket *b;
- sx = key_string(INTERP, key);
+
key = key_next(INTERP, key);
b = hash_get_bucket(INTERP, h, sx);
if (b == NULL)
@@ -957,15 +958,15 @@
*/
void delete_keyed(PMC* key) {
- STRING * sx;
- Hash * h = (Hash *)PMC_struct_val(SELF);
+ Hash * const h = (Hash *)PMC_struct_val(SELF);
+ STRING * const sx = key_string(INTERP, key);
HashBucket *b;
- sx = key_string(INTERP, key);
+
key = key_next(INTERP, key);
b = hash_get_bucket(INTERP, h, sx);
if (b == NULL)
- return; /* no such key */
- else if (key == NULL)
+ return; /* no such key */
+ if (key == NULL)
hash_delete(INTERP, h, sx);
else
VTABLE_delete_keyed(INTERP, (PMC*)b->value, key);
@@ -985,7 +986,7 @@
switch (f) {
case 0:
{
- PMC *iter = pmc_new_init(INTERP,
+ PMC * const iter = pmc_new_init(INTERP,
enum_class_Iterator, SELF);
PMC_struct_val(iter) = key;
return iter;
@@ -1024,8 +1025,8 @@
*/
void freeze(visit_info *info) {
- IMAGE_IO *io = info->image_io;
- Hash *hash = (Hash *)PMC_struct_val(SELF);;
+ IMAGE_IO * const io = info->image_io;
+ Hash * const hash = (Hash *)PMC_struct_val(SELF);;
SUPER(info);
io->vtable->push_integer(INTERP, io, VTABLE_elements(INTERP, SELF));
@@ -1044,21 +1045,21 @@
*/
void thaw(visit_info *info) {
- IMAGE_IO *io = info->image_io;
- Hash *hash;
- PMC *dummy;
+ IMAGE_IO * const io = info->image_io;
if (info->extra_flags == EXTRA_IS_NULL) {
- INTVAL elems = io->vtable->shift_integer(INTERP, io);
- INTVAL k_type = io->vtable->shift_integer(INTERP, io);
- INTVAL v_type = io->vtable->shift_integer(INTERP, io);
+ const INTVAL elems = io->vtable->shift_integer(INTERP, io);
+ const INTVAL k_type = io->vtable->shift_integer(INTERP, io);
+ const INTVAL v_type = io->vtable->shift_integer(INTERP, io);
+ Hash *hash;
+
info->extra_flags = EXTRA_IS_COUNT;
info->extra = (void *)elems;
/* TODO make a better interface for hash creation
* TODO create hash with needed size in the first place
*/
if (k_type == Hash_key_type_int && v_type == enum_hash_int) {
- dummy = Parrot_new_INTVAL_hash(INTERP, 0);
+ PMC * const dummy = Parrot_new_INTVAL_hash(INTERP, 0);
PMC_struct_val(SELF) = PMC_struct_val(dummy);
PMC_struct_val(dummy) = NULL;
}
Modified: trunk/src/pmc/resizablebooleanarray.pmc
==============================================================================
--- trunk/src/pmc/resizablebooleanarray.pmc (original)
+++ trunk/src/pmc/resizablebooleanarray.pmc Wed May 3 23:20:10 2006
@@ -48,17 +48,19 @@
INTVAL get_integer_keyed_int (INTVAL key) {
/* Try to make negative index into a real index */
- if (key < 0) key = SELF.elements() + key;
+ if (key < 0) {
+ key = SELF.elements() + key;
- /* If it's still negative, we have a problem */
- if (key < 0)
- real_exception(interpreter, NULL, E_IndexError,
- "ResizableBooleanArray: index out of bounds!");
+ /* If it's still negative, we have a problem */
+ if (key < 0)
+ real_exception(interpreter, NULL, E_IndexError,
+ "ResizableBooleanArray: index out of bounds!");
+ }
/* Adjust key for the current head position */
key += PMC_int_val2(SELF);
- if(key >= PMC_int_val(SELF))
+ if (key >= PMC_int_val(SELF))
DYNSELF.set_integer_native(key+1);
return SUPER(key);
@@ -76,12 +78,14 @@
void set_integer_keyed_int (INTVAL key, INTVAL value) {
/* Try to make negative index into a real index */
- if (key < 0) key = SELF.elements() + key;
+ if (key < 0) {
+ key = SELF.elements() + key;
- /* If it's still negative, we have a problem */
- if (key < 0)
- real_exception(interpreter, NULL, E_IndexError,
- "ResizableBooleanArray: index out of bounds!");
+ /* If it's still negative, we have a problem */
+ if (key < 0)
+ real_exception(interpreter, NULL, E_IndexError,
+ "ResizableBooleanArray: index out of bounds!");
+ }
/* Adjust key for the current head position */
key += PMC_int_val2(SELF);
@@ -103,12 +107,12 @@
*/
void set_integer_native (INTVAL size) {
- Parrot_UInt1 *sd;
INTVAL newASize;
- INTVAL currSize = PMC_int_val(SELF) - PMC_int_val2(SELF);
+ const INTVAL currSize = PMC_int_val(SELF) - PMC_int_val2(SELF);
/* We are already at the requested size. Yay */
- if(size == currSize) return;
+ if (size == currSize)
+ return;
if (size < 0)
real_exception(interpreter, NULL, E_IndexError,
@@ -121,7 +125,7 @@
PMC_data(SELF) = mem_sys_allocate_zeroed(newASize);
}
else {
- sd = PMC_data(SELF);
+ Parrot_UInt1 * const sd = PMC_data(SELF);
PMC_data(SELF) = mem_sys_realloc(sd, newASize);
}
@@ -140,7 +144,7 @@
*/
void push_integer (INTVAL value) {
- INTVAL size = PMC_int_val(SELF) - PMC_int_val2(SELF);
+ const INTVAL size = PMC_int_val(SELF) - PMC_int_val2(SELF);
DYNSELF.set_integer_native(size + 1);
DYNSELF.set_integer_keyed_int(size, value);
}
@@ -181,12 +185,10 @@
*/
void unshift_integer (INTVAL value) {
- Parrot_UInt1 *sdOld, *sdNew;
-
/* If int_val2 is smaller than 0, size this thing up */
- if(PMC_int_val2(SELF) <= 0) {
- sdOld = PMC_data(SELF);
- sdNew = mem_sys_allocate_zeroed(
+ if (PMC_int_val2(SELF) <= 0) {
+ Parrot_UInt1 * const sdOld = PMC_data(SELF);
+ Parrot_UInt1 * const sdNew = mem_sys_allocate_zeroed(
((PMC_int_val2(SELF) / MIN_ALLOC) * MIN_ALLOC)
+ PMC_int_val(SELF)
+ ((PMC_int_val(SELF) / MIN_ALLOC + 1) * MIN_ALLOC)
@@ -218,7 +220,6 @@
INTVAL shift_integer () {
INTVAL value;
- Parrot_UInt1 *sdOld, *sdNew;
if (DYNSELF.elements() < 1)
real_exception(interpreter, NULL, E_IndexError,
@@ -232,9 +233,9 @@
/* If int_val2 is bigger than our allocation unit size, size
this thing down */
- if(PMC_int_val2(SELF) >= MIN_ALLOC) {
- sdOld = PMC_data(SELF);
- sdNew = mem_sys_allocate_zeroed(
+ if (PMC_int_val2(SELF) >= MIN_ALLOC) {
+ Parrot_UInt1 * const sdOld = PMC_data(SELF);
+ Parrot_UInt1 * const sdNew = mem_sys_allocate_zeroed(
((PMC_int_val2(SELF) / MIN_ALLOC) * MIN_ALLOC)
+ PMC_int_val(SELF)
+ ((PMC_int_val(SELF) / MIN_ALLOC + 1) * MIN_ALLOC)
@@ -297,9 +298,9 @@
and use it during thaw?
*/
- IMAGE_IO *io = info->image_io;
+ IMAGE_IO * const io = info->image_io;
STRING *s;
- INTVAL size = (PMC_int_val(SELF) / MIN_ALLOC + 1) * MIN_ALLOC;
+ const INTVAL size = (PMC_int_val(SELF) / MIN_ALLOC + 1) * MIN_ALLOC;
io->vtable->push_integer(INTERP, io, PMC_int_val2(SELF));
io->vtable->push_integer(INTERP, io, PMC_int_val(SELF));
@@ -317,10 +318,10 @@
*/
void thaw(visit_info *info) {
- IMAGE_IO *io = info->image_io;
- INTVAL headPos = io->vtable->shift_integer(INTERP, io);
- INTVAL tailPos = io->vtable->shift_integer(INTERP, io);
- STRING *s = io->vtable->shift_string(INTERP, io);
+ IMAGE_IO * const io = info->image_io;
+ const INTVAL headPos = io->vtable->shift_integer(INTERP, io);
+ const INTVAL tailPos = io->vtable->shift_integer(INTERP, io);
+ STRING * const s = io->vtable->shift_string(INTERP, io);
PMC_data(SELF) = mem_sys_allocate_zeroed(s->bufused);
mem_sys_memcopy(PMC_data(SELF), s->strstart, s->bufused);
Modified: trunk/src/pmc/sub.pmc
==============================================================================
--- trunk/src/pmc/sub.pmc (original)
+++ trunk/src/pmc/sub.pmc Wed May 3 23:20:10 2006
@@ -1,5 +1,5 @@
/*
-Copyright: 2001-2003 The Perl Foundation. All Rights Reserved.
+Copyright: 2001-2006 The Perl Foundation. All Rights Reserved.
$Id$
=head1 NAME
@@ -26,10 +26,8 @@
static void
print_sub_name(Interp* interpreter, PMC* sub)
{
- Interp *tracer;
-
- tracer = interpreter->debugger ?
- interpreter->debugger : interpreter;
+ Interp * const tracer =
+ interpreter->debugger ? interpreter->debugger : interpreter;
/* sub was located via globals */
PIO_eprintf(tracer, "# Calling sub '%Ss'\n# ",
@@ -93,7 +91,7 @@
*/
void destroy () {
- struct Parrot_sub * sub = PMC_sub(SELF);
+ struct Parrot_sub * const sub = PMC_sub(SELF);
if (!sub)
return;
#if 0
@@ -126,7 +124,7 @@
}
void set_string_native(STRING *subname) {
- struct Parrot_sub * sub = PMC_sub(SELF);
+ struct Parrot_sub * const sub = PMC_sub(SELF);
sub->name = string_copy(INTERP, subname);
}
@@ -159,7 +157,7 @@
*/
void* get_pointer () {
- struct Parrot_sub * sub = PMC_sub(SELF);
+ struct Parrot_sub * const sub = PMC_sub(SELF);
return sub->seg->base.data + sub->start_offs;
}
@@ -192,12 +190,12 @@
*/
INTVAL defined () {
- struct Parrot_sub * sub = PMC_sub(SELF);
+ struct Parrot_sub * const sub = PMC_sub(SELF);
return 1;
}
INTVAL get_bool () {
- struct Parrot_sub * sub = PMC_sub(SELF);
+ struct Parrot_sub * const sub = PMC_sub(SELF);
return 1;
}
@@ -337,7 +335,7 @@
PMC* clone () {
struct Parrot_sub * sub;
- PMC* ret = pmc_new_noinit(INTERP, SELF->vtable->base_type);
+ PMC* const ret = pmc_new_noinit(INTERP, SELF->vtable->base_type);
/*
* we have to mark it ourselves
*/
@@ -361,7 +359,7 @@
*/
void mark () {
- struct Parrot_sub * sub = PMC_sub(SELF);
+ struct Parrot_sub * const sub = PMC_sub(SELF);
if (!sub)
return;
if (sub->name)
@@ -418,7 +416,7 @@
*/
void visit(visit_info *info) {
- struct Parrot_sub * sub = PMC_sub(SELF);
+ struct Parrot_sub * const sub = PMC_sub(SELF);
info->thaw_ptr = &sub->namespace;
(info->visit_pmc_now)(INTERP, sub->namespace, info);
@@ -440,8 +438,8 @@
}
void freeze(visit_info *info) {
- IMAGE_IO *io = info->image_io;
- struct Parrot_sub * sub = PMC_sub(SELF);
+ IMAGE_IO * const io = info->image_io;
+ struct Parrot_sub * const sub = PMC_sub(SELF);
int i;
SUPER(info);
@@ -484,7 +482,7 @@
SUPER(info);
if (info->extra_flags == EXTRA_IS_NULL) {
- struct Parrot_sub * sub = PMC_sub(SELF);
+ struct Parrot_sub * const sub = PMC_sub(SELF);
INTVAL flags;
int i;
/*
@@ -533,17 +531,17 @@
METHOD PMC* get_namespace() {
- struct Parrot_sub * sub = PMC_sub(SELF);
+ struct Parrot_sub * const sub = PMC_sub(SELF);
return sub->namespace_stash;
}
METHOD INTVAL __get_regs_used(char *kind) {
- struct Parrot_sub * sub = PMC_sub(SELF);
+ struct Parrot_sub * const sub = PMC_sub(SELF);
/* TODO switch to canonical NiSP order
* see also imcc/reg_alloc.c
*/
- const char *types = "INSP";
+ static const char types[] = "INSP";
char *p;
assert(sub->n_regs_used);
@@ -558,17 +556,17 @@
}
METHOD PMC* get_lexinfo() {
- struct Parrot_sub * sub = PMC_sub(SELF);
+ struct Parrot_sub * const sub = PMC_sub(SELF);
return sub->lex_info ? sub->lex_info : PMCNULL;
}
METHOD PMC* get_outer() {
- struct Parrot_sub * sub = PMC_sub(SELF);
+ struct Parrot_sub * const sub = PMC_sub(SELF);
return sub->outer_sub ? sub->outer_sub : PMCNULL;
}
METHOD PMC* get_multisig() {
- struct Parrot_sub * sub = PMC_sub(SELF);
+ struct Parrot_sub * const sub = PMC_sub(SELF);
return sub->multi_signature ? sub->multi_signature : PMCNULL;
}
}
@@ -579,7 +577,7 @@
=head1 HISTORY
-Initial version by Melvin on 2002/06/6.
+Initial version by Melvin on 2002/06/06.
=cut