[svn:parrot] r36655 - in trunk/src: . dynpmc pmc

petdance at svn.parrot.org petdance at svn.parrot.org
Fri Feb 13 02:24:13 UTC 2009


Author: petdance
Date: Fri Feb 13 02:24:12 2009
New Revision: 36655
URL: https://trac.parrot.org/parrot/changeset/36655

Log:
lots of random consting

Modified:
   trunk/src/dynpmc/rational.pmc
   trunk/src/oo.c
   trunk/src/pmc/bigint.pmc
   trunk/src/pmc/float.pmc
   trunk/src/pmc/hash.pmc
   trunk/src/pmc/iterator.pmc
   trunk/src/pmc/key.pmc
   trunk/src/thread.c

Modified: trunk/src/dynpmc/rational.pmc
==============================================================================
--- trunk/src/dynpmc/rational.pmc	Fri Feb 13 02:02:09 2009	(r36654)
+++ trunk/src/dynpmc/rational.pmc	Fri Feb 13 02:24:12 2009	(r36655)
@@ -1,5 +1,5 @@
 /*
-Copyright (C) 2008, The Perl Foundation.
+Copyright (C) 2008-2009, The Perl Foundation.
 $Id$
 
 =pod
@@ -54,8 +54,8 @@
 */
 static STRING *rat_get_string_to_base(PARROT_INTERP, PMC *self, int base) {
   #ifdef PARROT_HAS_GMP
-    char * const cstr = mpq_get_str(NULL, (int) base, RT(self));
-    STRING * pstr     = Parrot_str_new(interp, cstr, 0);
+    char * const cstr   = mpq_get_str(NULL, (int) base, RT(self));
+    STRING * const pstr = Parrot_str_new(interp, cstr, 0);
     Parrot_str_free_cstring(cstr);
     return pstr;
   #else
@@ -320,7 +320,7 @@
     VTABLE PMC *clone() {
       #ifdef PARROT_HAS_GMP
         mpz_t num, den;
-        PMC *ret = pmc_new(INTERP, SELF->vtable->base_type);
+        PMC * const ret = pmc_new(INTERP, SELF->vtable->base_type);
         mpq_get_num(num, RT(SELF));
         mpq_get_den(den, RT(SELF));
         mpq_set_num(RT(ret), num);
@@ -431,7 +431,7 @@
         mpz_init(q);
         mpz_tdiv_q(q, mpq_numref(RT(SELF)), mpq_denref(RT(SELF)));
         if (mpz_fits_slong_p(q)) {
-            INTVAL ret = (INTVAL) mpz_get_si(q);
+            const INTVAL ret = (INTVAL) mpz_get_si(q);
             mpz_clear(q);
             return ret;
         }
@@ -454,8 +454,7 @@
 */
     VTABLE FLOATVAL get_number() {
       #ifdef PARROT_HAS_GMP
-        double d;
-        d = mpq_get_d(RT(SELF));
+        const double d = mpq_get_d(RT(SELF));
         return (FLOATVAL) d;
       #else
         RAISE_EXCEPTION

Modified: trunk/src/oo.c
==============================================================================
--- trunk/src/oo.c	Fri Feb 13 02:02:09 2009	(r36654)
+++ trunk/src/oo.c	Fri Feb 13 02:24:12 2009	(r36655)
@@ -527,7 +527,7 @@
     INTVAL type;
     const INTVAL typeid_exists = fail_if_type_exists(interp, name);
 
-    PMC *classobj = VTABLE_get_class(interp, _namespace);
+    PMC * const classobj = VTABLE_get_class(interp, _namespace);
     if (!PMC_IS_NULL(classobj)) {
         STRING *classname = VTABLE_get_string(interp, _namespace);
         Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_INVALID_OPERATION,

Modified: trunk/src/pmc/bigint.pmc
==============================================================================
--- trunk/src/pmc/bigint.pmc	Fri Feb 13 02:02:09 2009	(r36654)
+++ trunk/src/pmc/bigint.pmc	Fri Feb 13 02:24:12 2009	(r36655)
@@ -1,5 +1,5 @@
 /*
-Copyright (C) 2004-2008, The Perl Foundation.
+Copyright (C) 2004-2009, The Perl Foundation.
 $Id$
 
 =head1 NAME
@@ -792,21 +792,21 @@
 */
 
     VTABLE STRING *get_string() {
-        char   *s  = bigint_get_string(INTERP, SELF, 10);
-        STRING *ps = Parrot_str_new(INTERP, s, 0);
+        char   * const s  = bigint_get_string(INTERP, SELF, 10);
+        STRING * const ps = Parrot_str_new(INTERP, s, 0);
         mem_sys_free(s);
         return ps;
     }
 
     VTABLE STRING *get_string_keyed_int(INTVAL base) {
-        char   *s  = bigint_get_string(INTERP, SELF, base);
-        STRING *ps = Parrot_str_new(INTERP, s, 0);
+        char   * const s  = bigint_get_string(INTERP, SELF, base);
+        STRING * const ps = Parrot_str_new(INTERP, s, 0);
         mem_sys_free(s);
         return ps;
     }
 
     VTABLE STRING *get_repr() {
-        STRING *s = SELF.get_string();
+        STRING * const s = SELF.get_string();
         return Parrot_str_append(INTERP, s, CONST_STRING(INTERP, "L"));
     }
 /*
@@ -1017,7 +1017,7 @@
 
     MULTI PMC *pow(PMC *value, PMC *dest) {
         /* XXX only Integer RHS currently */
-        INTVAL r = VTABLE_get_integer(INTERP, value);
+        const INTVAL r = VTABLE_get_integer(INTERP, value);
         dest = pmc_new(INTERP, SELF->vtable->base_type);
 
         bigint_pow_bigint_int(INTERP, SELF, r, dest);

Modified: trunk/src/pmc/float.pmc
==============================================================================
--- trunk/src/pmc/float.pmc	Fri Feb 13 02:02:09 2009	(r36654)
+++ trunk/src/pmc/float.pmc	Fri Feb 13 02:24:12 2009	(r36655)
@@ -1,5 +1,5 @@
 /*
-Copyright (C) 2003-2008, The Perl Foundation.
+Copyright (C) 2003-2009, The Perl Foundation.
 $Id$
 
 =head1 NAME
@@ -34,7 +34,7 @@
 */
 
     VTABLE void init() {
-        Parrot_Float_attributes *fattr = mem_allocate_zeroed_typed(Parrot_Float_attributes);
+        Parrot_Float_attributes * const fattr = mem_allocate_zeroed_typed(Parrot_Float_attributes);
         fattr->fv = 0.0;
         PMC_data(SELF) = fattr;
     }
@@ -63,7 +63,7 @@
 
     VTABLE PMC *clone() {
         FLOATVAL fv;
-        PMC *dest = pmc_new(INTERP, SELF->vtable->base_type);
+        PMC * const dest = pmc_new(INTERP, SELF->vtable->base_type);
         GET_ATTR_fv(INTERP, SELF, fv);
         SET_ATTR_fv(INTERP, dest, fv);
         return dest;
@@ -117,7 +117,7 @@
 
     VTABLE INTVAL get_integer() {
         /* two steps avoid casting warnings */
-        FLOATVAL n = SELF.get_number();
+        const FLOATVAL n = SELF.get_number();
         return (INTVAL) n;
     }
 

Modified: trunk/src/pmc/hash.pmc
==============================================================================
--- trunk/src/pmc/hash.pmc	Fri Feb 13 02:02:09 2009	(r36654)
+++ trunk/src/pmc/hash.pmc	Fri Feb 13 02:24:12 2009	(r36655)
@@ -1,5 +1,5 @@
 /*
-Copyright (C) 2001-2008, The Perl Foundation.
+Copyright (C) 2001-2009, The Perl Foundation.
 $Id$
 
 =head1 NAME
@@ -89,7 +89,7 @@
         Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_UNEXPECTED_NULL,
             "Hash: Cannot use NULL key");
     else {
-        STRING *keystr = key_string(interp, key);
+        STRING * const keystr = key_string(interp, key);
         if (STRING_IS_NULL(keystr))
             Parrot_ex_throw_from_c_args(interp, NULL,
                 EXCEPTION_UNEXPECTED_NULL, "Hash: Cannot use NULL STRING key");
@@ -271,7 +271,7 @@
 
     VTABLE FLOATVAL get_number() {
         /* doing this in two steps avoids dodgy cast warnings with -O */
-        INTVAL size = parrot_hash_size(INTERP, (Hash *)PMC_struct_val(SELF));
+        const INTVAL size = parrot_hash_size(INTERP, (Hash *)PMC_struct_val(SELF));
         return (FLOATVAL)size;
     }
 
@@ -554,14 +554,15 @@
     }
 
     VTABLE PMC *get_pmc_keyed(PMC *key) {
-        Hash   * const hash = (Hash *)PMC_struct_val(SELF);
+        const Hash * const hash = (Hash *)PMC_struct_val(SELF);
         STRING        *keystr;
         HashBucket    *b;
         PMC           *nextkey;
-        PMC           *result;
 
         /* called from iterator with an integer idx in key */
         if ((PObj_get_FLAGS(key) & KEY_type_FLAGS) == KEY_hash_iterator_FLAGS) {
+            PMC *result;
+
             /* check if we really have Hash_key_type_int */
             if (hash->key_type == Hash_key_type_int) {
                 void *idx           = parrot_hash_get_idx(INTERP, hash, key);

Modified: trunk/src/pmc/iterator.pmc
==============================================================================
--- trunk/src/pmc/iterator.pmc	Fri Feb 13 02:02:09 2009	(r36654)
+++ trunk/src/pmc/iterator.pmc	Fri Feb 13 02:24:12 2009	(r36655)
@@ -140,9 +140,9 @@
 */
 
     VTABLE PMC *clone() {
-        STRING     *name    = CONST_STRING(interp, "set_key");
-        PMC * const key     = (PMC *)PMC_struct_val(SELF);
-        PMC * const res     = pmc_new_init(INTERP, SELF->vtable->base_type,
+        STRING * const name = CONST_STRING(interp, "set_key");
+        PMC    * const key  = (PMC *)PMC_struct_val(SELF);
+        PMC    * const res  = pmc_new_init(INTERP, SELF->vtable->base_type,
                                            SELF.get_pmc());
         Parrot_PCCINVOKE(interp, res, name, "P->", VTABLE_clone(interp, key));
         return res;
@@ -351,7 +351,7 @@
 */
 
     VTABLE void set_integer_native(INTVAL value) {
-        PMC *key, *agg;
+        PMC *agg;
         if (value < ITERATE_FROM_START || value > ITERATE_FROM_END)
             Parrot_ex_throw_from_c_args(INTERP, NULL, EXCEPTION_INVALID_OPERATION,
                     "Illegal set_integer on iterator");
@@ -365,6 +365,7 @@
                 VTABLE_nextkey_keyed(INTERP, agg, NULL, value);
         }
         else {
+            PMC *key;
             if (!PMC_struct_val(SELF))
                 key = key_new(INTERP);
             else
@@ -487,7 +488,7 @@
 
         /* iterator constructor */
         if (REG_INT(interp, 3) == 1) {
-            PMC *arg = REG_PMC(interp, 5);
+            PMC * const arg = REG_PMC(interp, 5);
             PMC *iter;
 
             if (PObj_is_object_TEST(arg)) {

Modified: trunk/src/pmc/key.pmc
==============================================================================
--- trunk/src/pmc/key.pmc	Fri Feb 13 02:02:09 2009	(r36654)
+++ trunk/src/pmc/key.pmc	Fri Feb 13 02:24:12 2009	(r36655)
@@ -1,5 +1,5 @@
 /*
-Copyright (C) 2001-2008, The Perl Foundation.
+Copyright (C) 2001-2009, The Perl Foundation.
 $Id$
 
 =head1 NAME
@@ -50,7 +50,6 @@
         PMC * const dest = pmc_new_noinit(INTERP, SELF->vtable->base_type);
         PMC *dkey        = dest;
         PMC *key         = SELF;
-        PMC *p;
 
         PObj_custom_mark_SET(dest);
 
@@ -71,8 +70,10 @@
                     break;
                 case KEY_pmc_FLAG:
                 case KEY_pmc_FLAG | KEY_register_FLAG:
-                    p = key_pmc(INTERP, key);
+                    {
+                    PMC * const p = key_pmc(INTERP, key);
                     key_set_pmc(INTERP, dkey, VTABLE_clone(INTERP, p));
+                    }
                     break;
                 default:
                     break;
@@ -81,7 +82,7 @@
             key = key_next(INTERP, key);
 
             if (key) {
-                p    = key_new(INTERP);
+                PMC * const p = key_new(INTERP);
                 key_append(INTERP, dkey, p);
                 dkey = p;
             }
@@ -284,7 +285,7 @@
 */
 
     VTABLE PMC *nextkey_keyed(PMC *agg, INTVAL what) {
-        PMC         *ret = SELF;
+        PMC  * const ret = SELF;
         const INTVAL n   = VTABLE_elements(INTERP, agg);
 
         switch (what) {
@@ -418,9 +419,8 @@
     }
 
     void thaw(visit_info *info) {
-        IMAGE_IO * const io    = info->image_io;
-        INTVAL     const flags = VTABLE_shift_integer(INTERP, io)
-                                    & KEY_type_FLAGS;
+        IMAGE_IO * const io = info->image_io;
+        const INTVAL flags  = VTABLE_shift_integer(INTERP, io) & KEY_type_FLAGS;
 
         PObj_get_FLAGS(SELF) |= flags;
         PObj_custom_mark_SET(SELF);

Modified: trunk/src/thread.c
==============================================================================
--- trunk/src/thread.c	Fri Feb 13 02:02:09 2009	(r36654)
+++ trunk/src/thread.c	Fri Feb 13 02:24:12 2009	(r36655)
@@ -1,5 +1,5 @@
 /*
-Copyright (C) 2001-2008, The Perl Foundation.
+Copyright (C) 2001-2009, The Perl Foundation.
 $Id$
 
 =head1 NAME
@@ -958,7 +958,7 @@
 {
     ASSERT_ARGS(remove_queued_suspend_gc)
     parrot_event *ev    = NULL;
-    QUEUE        *queue = interp->task_queue;
+    QUEUE * const queue = interp->task_queue;
     QUEUE_ENTRY  *prev  = NULL;
     QUEUE_ENTRY  *cur;
 


More information about the parrot-commits mailing list