Author: chromatic
Date: Thu Feb 21 18:14:04 2008
New Revision: 25969

Modified:
   trunk/languages/lua/pmc/luanumber.pmc

Log:
[Lua] Cleaned up LuaNumber PMC.

Modified: trunk/languages/lua/pmc/luanumber.pmc
==============================================================================
--- trunk/languages/lua/pmc/luanumber.pmc       (original)
+++ trunk/languages/lua/pmc/luanumber.pmc       Thu Feb 21 18:14:04 2008
@@ -1,5 +1,5 @@
 /*
-Copyright (C) 2005-2007, The Perl Foundation.
+Copyright (C) 2005-2008, The Perl Foundation.
 $Id$
 
 =head1 NAME
@@ -49,7 +49,7 @@
 
 /*
 
-=item C<PMC* new_from_string(STRING *rep, INTVAL flags)>
+=item C<PMC *new_from_string(STRING *rep, INTVAL flags)>
 
 Return a LuaNumber PMC created from a string (Implementation
 is based on new_from_string() from Integer PMC).
@@ -61,7 +61,7 @@
 =cut
 
 */
-    PMC* new_from_string(STRING *rep, INTVAL flags) {
+    PMC *new_from_string(STRING *rep, INTVAL flags) {
         PMC *res;
         INTVAL type = PMC_type(SELF);
         if (flags & PObj_constant_FLAG)
@@ -94,8 +94,8 @@
 =cut
 
 */
-    PMC* clone() {
-        PMC* dest = pmc_new(INTERP, PMC_type(SELF));
+    PMC *clone() {
+        PMC *dest = pmc_new(INTERP, PMC_type(SELF));
         STRUCT_COPY(&PMC_union(dest), &PMC_union(SELF));
         return dest;
     }
@@ -110,7 +110,7 @@
 
 */
    INTVAL get_integer() {
-        return (INTVAL) PMC_num_val(SELF);
+        return (INTVAL)PMC_num_val(SELF);
    }
 
 /*
@@ -197,7 +197,7 @@
 
 */
     void increment() {
-        PMC_num_val(SELF) ++;
+        PMC_num_val(SELF)++;
     }
 
 /*
@@ -210,18 +210,18 @@
 
 */
     void decrement() {
-        PMC_num_val(SELF) --;
+        PMC_num_val(SELF)--;
     }
 
 /*
 
-=item C<PMC* neg(PMC * dest)>
+=item C<PMC *neg(PMC *dest)>
 
 =cut
 
 */
-    PMC* neg(PMC * dest) {
-        FLOATVAL a = - SELF.get_number();
+    PMC *neg(PMC *dest) {
+        FLOATVAL a = -SELF.get_number();
         dest = pmc_new(INTERP, dynpmc_LuaNumber);
         VTABLE_set_number_native(INTERP, dest, a);
         return dest;
@@ -235,7 +235,7 @@
 
 */
     void i_neg() {
-        FLOATVAL a = - SELF.get_number();
+        FLOATVAL a = -SELF.get_number();
         SELF.set_number_native(a);
     }
 
@@ -247,12 +247,12 @@
 
 =over 4
 
-=item C<PMC* add(PMC* value, PMC* dest)>
+=item C<PMC *add(PMC *value, PMC *dest)>
 
 =cut
 
 */
-    PMC* add(PMC* value, PMC* dest) {
+    PMC *add(PMC *value, PMC *dest) {
 MMD_LuaNumber: {
             dest = pmc_new(INTERP, dynpmc_LuaNumber);
             VTABLE_set_number_native(INTERP, dest,
@@ -260,166 +260,164 @@
             return dest;
         }
 MMD_LuaString: {
-            PMC* n = LuaString.value.tonumber();
-            if (PMC_type(n) == dynpmc_LuaNumber) {
+            PMC *n = LuaString.value.tonumber();
+
+            if (PMC_type(n) == dynpmc_LuaNumber)
                 return Parrot_LuaNumber_add_LuaNumber(INTERP, SELF, n, dest);
-            }
-            else {
-                real_exception(INTERP, NULL, ILL_INHERIT,
-                      "attempt to perform arithmetic on a %s value",
-                      string_to_cstring(INTERP, VTABLE_name(INTERP, value)));
-                return NULL;
-            }
+
+            real_exception(INTERP, NULL, ILL_INHERIT,
+                "attempt to perform arithmetic on a %Ss value",
+                    VTABLE_name(INTERP, value));
         }
 MMD_DEFAULT: {
             PMC *meth = find_meth(INTERP, value, "__add");
-            if (meth != NULL) {
+
+            if (meth) {
                 dest = Parrot_runops_fromc_args(INTERP, meth, "PPP",
                                                 SELF, value);
-                if (PMC_IS_NULL(dest)) {
+                if (PMC_IS_NULL(dest))
                     dest = pmc_new(INTERP, dynpmc_LuaNil);
-                }
+
                 return dest;
             }
+
             real_exception(INTERP, NULL, ILL_INHERIT,
-                  "attempt to perform arithmetic on a %s value",
-                  string_to_cstring(INTERP, VTABLE_name(INTERP, value)));
-            return NULL;
+                  "attempt to perform arithmetic on a %Ss value",
+                    VTABLE_name(INTERP, value));
         }
     }
 
 /*
 
-=item C<void i_add(PMC* value)>
+=item C<void i_add(PMC *value)>
 
 =cut
 
 */
-    void i_add(PMC* value) {
+    void i_add(PMC *value) {
 MMD_LuaNumber: {
-            FLOATVAL n = SELF.get_number()
-                         + VTABLE_get_number(INTERP, value);
+            FLOATVAL n = SELF.get_number() + VTABLE_get_number(INTERP, value);
             SELF.set_number_native(n);
         }
 MMD_LuaString: {
-            PMC* n = LuaString.value.tonumber();
-            if (PMC_type(n) == dynpmc_LuaNumber) {
+            PMC *n = LuaString.value.tonumber();
+
+            if (PMC_type(n) == dynpmc_LuaNumber)
                 Parrot_LuaNumber_i_add_LuaNumber(INTERP, SELF, n);
-            }
-            else {
+            else
                 real_exception(INTERP, NULL, ILL_INHERIT,
-                      "attempt to perform arithmetic on a %s value",
-                      string_to_cstring(INTERP, VTABLE_name(INTERP, value)));
-            }
+                    "attempt to perform arithmetic on a %Ss value",
+                        VTABLE_name(INTERP, value));
         }
 MMD_DEFAULT: {
             PMC *meth = find_meth(INTERP, value, "__add");
-            if (meth != NULL) {
+
+            if (meth) {
                 SELF = Parrot_runops_fromc_args(INTERP, meth, "PPP",
                                                 SELF, value);
-                if (NULL == SELF) {
+                if (!SELF)
                     SELF = pmc_new(INTERP, dynpmc_LuaNil);
-                }
+
                 return;
             }
+
             real_exception(INTERP, NULL, ILL_INHERIT,
-                  "attempt to perform arithmetic on a %s value",
-                  string_to_cstring(INTERP, VTABLE_name(INTERP, value)));
+                "attempt to perform arithmetic on a %Ss value",
+                    VTABLE_name(INTERP, value));
         }
     }
 
 /*
 
-=item C<PMC* subtract(PMC* value, PMC* dest)>
+=item C<PMC *subtract(PMC *value, PMC *dest)>
 
 =cut
 
 */
-    PMC* subtract(PMC* value, PMC* dest) {
+    PMC *subtract(PMC *value, PMC *dest) {
 MMD_LuaNumber: {
             dest = pmc_new(INTERP, dynpmc_LuaNumber);
+
             VTABLE_set_number_native(INTERP, dest,
                     SELF.get_number() - VTABLE_get_number(INTERP, value));
+
             return dest;
         }
 MMD_LuaString: {
-            PMC* n = LuaString.value.tonumber();
-            if (PMC_type(n) == dynpmc_LuaNumber) {
-                return Parrot_LuaNumber_subtract_LuaNumber(INTERP, SELF,
-                                                           n, dest);
-            }
-            else {
-                real_exception(INTERP, NULL, ILL_INHERIT,
-                      "attempt to perform arithmetic on a %s value",
-                      string_to_cstring(INTERP, VTABLE_name(INTERP, value)));
-            }
-            return NULL;
+            PMC *n = LuaString.value.tonumber();
+
+            if (PMC_type(n) == dynpmc_LuaNumber)
+                return Parrot_LuaNumber_subtract_LuaNumber(INTERP, SELF, n, 
dest);
+            real_exception(INTERP, NULL, ILL_INHERIT,
+                "attempt to perform arithmetic on a %Ss value",
+                    VTABLE_name(INTERP, value));
         }
 MMD_DEFAULT: {
             PMC *meth = find_meth(INTERP, value, "__sub");
-            if (meth != NULL) {
+
+            if (meth) {
                 dest = Parrot_runops_fromc_args(INTERP, meth, "PPP",
                                                 SELF, value);
                 if (PMC_IS_NULL(dest)) {
                     dest = pmc_new(INTERP, dynpmc_LuaNil);
                 }
+
                 return dest;
             }
+
             real_exception(INTERP, NULL, ILL_INHERIT,
-                  "attempt to perform arithmetic on a %s value",
-                  string_to_cstring(INTERP, VTABLE_name(INTERP, value)));
-            return NULL;
+                "attempt to perform arithmetic on a %Ss value",
+                    VTABLE_name(INTERP, value));
         }
     }
 
 /*
 
-=item C<void i_subtract(PMC* value)>
+=item C<void i_subtract(PMC *value)>
 
 =cut
 
 */
-    void i_subtract(PMC* value) {
+    void i_subtract(PMC *value) {
 MMD_LuaNumber: {
-            FLOATVAL n = SELF.get_number()
-                         - VTABLE_get_number(INTERP, value);
+            FLOATVAL n = SELF.get_number() - VTABLE_get_number(INTERP, value);
             SELF.set_number_native(n);
         }
 MMD_LuaString: {
-            PMC* n = LuaString.value.tonumber();
-            if (PMC_type(n) == dynpmc_LuaNumber) {
+            PMC *n = LuaString.value.tonumber();
+
+            if (PMC_type(n) == dynpmc_LuaNumber)
                 Parrot_LuaNumber_i_subtract_LuaNumber(INTERP, SELF, n);
-            }
-            else {
+            else
                 real_exception(INTERP, NULL, ILL_INHERIT,
-                      "attempt to perform arithmetic on a %s value",
-                      string_to_cstring(INTERP, VTABLE_name(INTERP, value)));
-            }
+                    "attempt to perform arithmetic on a %Ss value",
+                        VTABLE_name(INTERP, value));
         }
 MMD_DEFAULT: {
             PMC *meth = find_meth(INTERP, value, "__sub");
-            if (meth != NULL) {
+            if (meth) {
                 SELF = Parrot_runops_fromc_args(INTERP, meth, "PPP",
                                                 SELF, value);
-                if (NULL == SELF) {
+                if (! SELF)
                     SELF = pmc_new(INTERP, dynpmc_LuaNil);
-                }
+
                 return;
             }
+
             real_exception(INTERP, NULL, ILL_INHERIT,
-                  "attempt to perform arithmetic on a %s value",
-                  string_to_cstring(INTERP, VTABLE_name(INTERP, value)));
+                "attempt to perform arithmetic on a %Ss value",
+                    VTABLE_name(INTERP, value));
         }
     }
 
 /*
 
-=item C<PMC* multiply(PMC* value, PMC* dest)>
+=item C<PMC *multiply(PMC *value, PMC *dest)>
 
 =cut
 
 */
-    PMC* multiply(PMC* value, PMC* dest) {
+    PMC *multiply(PMC *value, PMC *dest) {
 MMD_LuaNumber: {
             dest = pmc_new(INTERP, dynpmc_LuaNumber);
             VTABLE_set_number_native(INTERP, dest,
@@ -427,83 +425,78 @@
             return dest;
         }
 MMD_LuaString: {
-            PMC* n = LuaString.value.tonumber();
-            if (PMC_type(n) == dynpmc_LuaNumber) {
+            PMC *n = LuaString.value.tonumber();
+
+            if (PMC_type(n) == dynpmc_LuaNumber)
                 return Parrot_LuaNumber_multiply_LuaNumber(INTERP, SELF,
                                                            n, dest);
-            }
-            else {
-                real_exception(INTERP, NULL, ILL_INHERIT,
-                      "attempt to perform arithmetic on a %s value",
-                      string_to_cstring(INTERP, VTABLE_name(INTERP, value)));
-                return NULL;
-            }
+            real_exception(INTERP, NULL, ILL_INHERIT,
+                "attempt to perform arithmetic on a %Ss value",
+                    VTABLE_name(INTERP, value));
         }
 MMD_DEFAULT: {
             PMC *meth = find_meth(INTERP, value, "__mul");
-            if (meth != NULL) {
+            if (meth) {
                 dest = Parrot_runops_fromc_args(INTERP, meth, "PPP",
                                                 SELF, value);
-                if (PMC_IS_NULL(dest)) {
+                if (PMC_IS_NULL(dest))
                     dest = pmc_new(INTERP, dynpmc_LuaNil);
-                }
+
                 return dest;
             }
+
             real_exception(INTERP, NULL, ILL_INHERIT,
-                  "attempt to perform arithmetic on a %s value",
-                  string_to_cstring(INTERP, VTABLE_name(INTERP, value)));
-            return NULL;
+                "attempt to perform arithmetic on a %Ss value",
+                    VTABLE_name(INTERP, value));
         }
     }
 
 /*
 
-=item C<void i_multiply(PMC* value)>
+=item C<void i_multiply(PMC *value)>
 
 =cut
 
 */
-    void i_multiply(PMC* value) {
+    void i_multiply(PMC *value) {
 MMD_LuaNumber: {
-            FLOATVAL n = SELF.get_number()
-                         * VTABLE_get_number(INTERP, value);
+            FLOATVAL n = SELF.get_number() * VTABLE_get_number(INTERP, value);
             SELF.set_number_native(n);
         }
 MMD_LuaString: {
-            PMC* n = LuaString.value.tonumber();
-            if (PMC_type(n) == dynpmc_LuaNumber) {
+            PMC *n = LuaString.value.tonumber();
+            if (PMC_type(n) == dynpmc_LuaNumber)
                 Parrot_LuaNumber_i_multiply_LuaNumber(INTERP, SELF, n);
-            }
-            else {
+            else
                 real_exception(INTERP, NULL, ILL_INHERIT,
-                      "attempt to perform arithmetic on a %s value",
-                      string_to_cstring(INTERP, VTABLE_name(INTERP, value)));
-            }
+                    "attempt to perform arithmetic on a %Ss value",
+                        VTABLE_name(INTERP, value));
         }
 MMD_DEFAULT: {
             PMC *meth = find_meth(INTERP, value, "__mul");
-            if (meth != NULL) {
+            if (meth) {
                 SELF = Parrot_runops_fromc_args(INTERP, meth, "PPP",
                                                 SELF, value);
-                if (NULL == SELF) {
+                if (! SELF)
                     SELF = pmc_new(INTERP, dynpmc_LuaNil);
-                }
+
                 return;
             }
+
             real_exception(INTERP, NULL, ILL_INHERIT,
-                  "attempt to perform arithmetic on a %s value",
-                  string_to_cstring(INTERP, VTABLE_name(INTERP, value)));
+                "attempt to perform arithmetic on a %Ss value",
+                    VTABLE_name(INTERP, value));
         }
     }
 
 /*
 
-=item C<PMC* divide(PMC* value, PMC* dest)>
+=item C<PMC *divide(PMC *value, PMC *dest)>
 
 =cut
 
 */
-    PMC* divide(PMC* value, PMC* dest) {
+    PMC *divide(PMC *value, PMC *dest) {
 MMD_LuaNumber: {
             dest = pmc_new(INTERP, dynpmc_LuaNumber);
             VTABLE_set_number_native(INTERP, dest,
@@ -511,128 +504,121 @@
             return dest;
         }
 MMD_LuaString: {
-            PMC* n = LuaString.value.tonumber();
-            if (PMC_type(n) == dynpmc_LuaNumber) {
+            PMC *n = LuaString.value.tonumber();
+            if (PMC_type(n) == dynpmc_LuaNumber)
                 return Parrot_LuaNumber_divide_LuaNumber(INTERP, SELF,
                                                          n, dest);
-            }
-            else {
-                real_exception(INTERP, NULL, ILL_INHERIT,
-                      "attempt to perform arithmetic on a %s value",
-                      string_to_cstring(INTERP, VTABLE_name(INTERP, value)));
-                return NULL;
-            }
+            real_exception(INTERP, NULL, ILL_INHERIT,
+                "attempt to perform arithmetic on a %Ss value",
+                    VTABLE_name(INTERP, value));
         }
 MMD_DEFAULT: {
             PMC *meth = find_meth(INTERP, value, "__div");
-            if (meth != NULL) {
+            if (meth) {
                 dest = Parrot_runops_fromc_args(INTERP, meth, "PPP",
                                                 SELF, value);
-                if (PMC_IS_NULL(dest)) {
+                if (PMC_IS_NULL(dest))
                     dest = pmc_new(INTERP, dynpmc_LuaNil);
-                }
+
                 return dest;
             }
+
             real_exception(INTERP, NULL, ILL_INHERIT,
-                  "attempt to perform arithmetic on a %s value",
-                  string_to_cstring(INTERP, VTABLE_name(INTERP, value)));
-            return NULL;
+                "attempt to perform arithmetic on a %Ss value",
+                    VTABLE_name(INTERP, value));
         }
     }
 
 /*
 
-=item C<void i_divide(PMC* value)>
+=item C<void i_divide(PMC *value)>
 
 =cut
 
 */
-    void i_divide(PMC* value) {
+    void i_divide(PMC *value) {
 MMD_LuaNumber: {
             FLOATVAL n = SELF.get_number()
                          / VTABLE_get_number(INTERP, value);
             SELF.set_number_native(n);
         }
 MMD_LuaString: {
-            PMC* n = LuaString.value.tonumber();
-            if (PMC_type(n) == dynpmc_LuaNumber) {
+            PMC *n = LuaString.value.tonumber();
+            if (PMC_type(n) == dynpmc_LuaNumber)
                 Parrot_LuaNumber_i_divide_LuaNumber(INTERP, SELF, n);
-            }
-            else {
+            else
                 real_exception(INTERP, NULL, ILL_INHERIT,
-                      "attempt to perform arithmetic on a %s value",
-                      string_to_cstring(INTERP, VTABLE_name(INTERP, value)));
-            }
+                    "attempt to perform arithmetic on a %Ss value",
+                        VTABLE_name(INTERP, value));
         }
 MMD_DEFAULT: {
             PMC *meth = find_meth(INTERP, value, "__div");
-            if (meth != NULL) {
+            if (meth) {
                 SELF = Parrot_runops_fromc_args(INTERP, meth, "PPP",
                                                 SELF, value);
-                if (NULL == SELF) {
+                if (! SELF)
                     SELF = pmc_new(INTERP, dynpmc_LuaNil);
-                }
+
                 return;
             }
+
             real_exception(INTERP, NULL, ILL_INHERIT,
-                  "attempt to perform arithmetic on a %s value",
-                  string_to_cstring(INTERP, VTABLE_name(INTERP, value)));
+                "attempt to perform arithmetic on a %Ss value",
+                    VTABLE_name(INTERP, value));
         }
     }
 
 /*
 
-=item C<PMC* modulus(PMC* value, PMC* dest)>
+=item C<PMC *modulus(PMC *value, PMC *dest)>
 
 =cut
 
 */
-    PMC* modulus(PMC* value, PMC* dest) {
+    PMC *modulus(PMC *value, PMC *dest) {
 MMD_LuaNumber: {
             FLOATVAL a = SELF.get_number();
             FLOATVAL b = VTABLE_get_number(INTERP, value);
-            dest = pmc_new(INTERP, dynpmc_LuaNumber);
+            dest       = pmc_new(INTERP, dynpmc_LuaNumber);
+
             VTABLE_set_number_native(INTERP, dest, a - floor(a/b)*b);
+
             return dest;
         }
 MMD_LuaString: {
-            PMC* n = LuaString.value.tonumber();
-            if (PMC_type(n) == dynpmc_LuaNumber) {
+            PMC *n = LuaString.value.tonumber();
+            if (PMC_type(n) == dynpmc_LuaNumber)
                 return Parrot_LuaNumber_modulus_LuaNumber(INTERP, SELF,
                                                           n, dest);
-            }
-            else {
-                real_exception(INTERP, NULL, ILL_INHERIT,
-                      "attempt to perform arithmetic on a %s value",
-                      string_to_cstring(INTERP, VTABLE_name(INTERP, value)));
-                return NULL;
-            }
+            real_exception(INTERP, NULL, ILL_INHERIT,
+                "attempt to perform arithmetic on a %Ss value",
+                    VTABLE_name(INTERP, value));
         }
 MMD_DEFAULT: {
             PMC *meth = find_meth(INTERP, value, "__mod");
-            if (meth != NULL) {
+            if (meth) {
                 dest = Parrot_runops_fromc_args(INTERP, meth, "PPP",
                                                 SELF, value);
-                if (PMC_IS_NULL(dest)) {
+                if (PMC_IS_NULL(dest))
                     dest = pmc_new(INTERP, dynpmc_LuaNil);
-                }
+
                 return dest;
             }
+
             real_exception(INTERP, NULL, ILL_INHERIT,
-                  "attempt to perform arithmetic on a %s value",
-                  string_to_cstring(INTERP, VTABLE_name(INTERP, value)));
-            return NULL;
+                "attempt to perform arithmetic on a %Ss value",
+                    VTABLE_name(INTERP, value));
         }
     }
 
 /*
 
-=item C<void i_modulus(PMC* value)>
+=item C<void i_modulus(PMC *value)>
 
 =cut
 
 */
-    void i_modulus(PMC* value) {
+    void i_modulus(PMC *value) {
 MMD_LuaNumber: {
             FLOATVAL a = SELF.get_number();
             FLOATVAL b = VTABLE_get_number(INTERP, value);
@@ -640,40 +626,40 @@
             SELF.set_number_native(a - floor(a/b)*b);
         }
 MMD_LuaString: {
-            PMC* n = LuaString.value.tonumber();
-            if (PMC_type(n) == dynpmc_LuaNumber) {
+            PMC *n = LuaString.value.tonumber();
+
+            if (PMC_type(n) == dynpmc_LuaNumber)
                 Parrot_LuaNumber_i_modulus_LuaNumber(INTERP, SELF, n);
-            }
-            else {
+            else
                 real_exception(INTERP, NULL, ILL_INHERIT,
-                      "attempt to perform arithmetic on a %s value",
-                      string_to_cstring(INTERP, VTABLE_name(INTERP, value)));
-            }
+                      "attempt to perform arithmetic on a %Ss value",
+                      VTABLE_name(INTERP, value));
         }
 MMD_DEFAULT: {
             PMC *meth = find_meth(INTERP, value, "__mod");
-            if (meth != NULL) {
+            if (meth) {
                 SELF = Parrot_runops_fromc_args(INTERP, meth, "PPP",
                                                 SELF, value);
-                if (NULL == SELF) {
+                if (! SELF)
                     SELF = pmc_new(INTERP, dynpmc_LuaNil);
-                }
+
                 return;
             }
+
             real_exception(INTERP, NULL, ILL_INHERIT,
-                  "attempt to perform arithmetic on a %s value",
-                  string_to_cstring(INTERP, VTABLE_name(INTERP, value)));
+                "attempt to perform arithmetic on a %Ss value",
+                    VTABLE_name(INTERP, value));
         }
     }
 
 /*
 
-=item C<PMC* pow(PMC* value, PMC* dest)>
+=item C<PMC *pow(PMC *value, PMC *dest)>
 
 =cut
 
 */
-    PMC* pow(PMC* value, PMC* dest) {
+    PMC *pow(PMC *value, PMC *dest) {
 MMD_LuaNumber: {
             dest = pmc_new(INTERP, dynpmc_LuaNumber);
             VTABLE_set_number_native(INTERP, dest,
@@ -681,82 +667,78 @@
             return dest;
         }
 MMD_LuaString: {
-            PMC* n = LuaString.value.tonumber();
-            if (PMC_type(n) == dynpmc_LuaNumber) {
+            PMC *n = LuaString.value.tonumber();
+            if (PMC_type(n) == dynpmc_LuaNumber)
                 return Parrot_LuaNumber_pow_LuaNumber(INTERP, SELF, n, dest);
-            }
-            else {
-                real_exception(INTERP, NULL, ILL_INHERIT,
-                      "attempt to perform arithmetic on a %s value",
-                      string_to_cstring(INTERP, VTABLE_name(INTERP, value)));
-                return NULL;
-            }
+
+            real_exception(INTERP, NULL, ILL_INHERIT,
+                "attempt to perform arithmetic on a %Ss value",
+                    VTABLE_name(INTERP, value));
         }
 MMD_DEFAULT: {
             PMC *meth = find_meth(INTERP, value, "__pow");
-            if (meth != NULL) {
+            if (meth) {
                 dest = Parrot_runops_fromc_args(INTERP, meth, "PPP",
                                                 SELF, value);
-                if (PMC_IS_NULL(dest)) {
+                if (PMC_IS_NULL(dest))
                     dest = pmc_new(INTERP, dynpmc_LuaNil);
-                }
+
                 return dest;
             }
+
             real_exception(INTERP, NULL, ILL_INHERIT,
-                  "attempt to perform arithmetic on a %s value",
-                  string_to_cstring(INTERP, VTABLE_name(INTERP, value)));
-            return NULL;
+                "attempt to perform arithmetic on a %Ss value",
+                    VTABLE_name(INTERP, value));
         }
     }
 
 /*
 
-=item C<void i_pow(PMC* value)>
+=item C<void i_pow(PMC *value)>
 
 =cut
 
 */
-    void i_pow(PMC* value) {
+    void i_pow(PMC *value) {
 MMD_LuaNumber: {
             FLOATVAL n = pow(SELF.get_number(),
                              VTABLE_get_number(INTERP, value));
             SELF.set_number_native(n);
         }
 MMD_LuaString: {
-            PMC* n = LuaString.value.tonumber();
-            if (PMC_type(n) == dynpmc_LuaNumber) {
+            PMC *n = LuaString.value.tonumber();
+            if (PMC_type(n) == dynpmc_LuaNumber)
                 Parrot_LuaNumber_i_pow_LuaNumber(INTERP, SELF, n);
-            }
-            else {
+            else
                 real_exception(INTERP, NULL, ILL_INHERIT,
-                    "attempt to perform arithmetic on a %s value",
-                    string_to_cstring(INTERP, VTABLE_name(INTERP, value)));
-            }
+                    "attempt to perform arithmetic on a %Ss value",
+                        VTABLE_name(INTERP, value));
         }
 MMD_DEFAULT: {
             PMC *meth = find_meth(INTERP, value, "__pow");
-            if (meth != NULL) {
+            if (meth) {
                 SELF = Parrot_runops_fromc_args(INTERP, meth, "PPP",
                                                 SELF, value);
-                if (NULL == SELF) {
+                if (! SELF)
                     SELF = pmc_new(INTERP, dynpmc_LuaNil);
-                }
+
                 return;
             }
+
             real_exception(INTERP, NULL, ILL_INHERIT,
-                  "attempt to perform arithmetic on a %s value",
-                  string_to_cstring(INTERP, VTABLE_name(INTERP, value)));
+                "attempt to perform arithmetic on a %Ss value",
+                    VTABLE_name(INTERP, value));
         }
     }
 
 /*
 
-=item C<INTVAL is_equal(PMC* value)>
+=item C<INTVAL is_equal(PMC *value)>
 
 =cut
 
 */
-    INTVAL is_equal(PMC* value) {
+    INTVAL is_equal(PMC *value) {
 MMD_LuaNumber: {
             return (INTVAL)(PMC_num_val(SELF) == PMC_num_val(value));
         }
@@ -767,97 +749,103 @@
 
 /*
 
-=item C<INTVAL cmp(PMC* value)>
+=item C<INTVAL cmp(PMC *value)>
 
 =cut
 
 */
-    INTVAL cmp(PMC* value) {
+    INTVAL cmp(PMC *value) {
 MMD_LuaNumber: {
-            FLOATVAL diff;
-            diff = PMC_num_val(SELF) - PMC_num_val(value);
+            FLOATVAL diff = PMC_num_val(SELF)
+                - VTABLE_get_number(INTERP, value);
+
             return diff > 0 ? (INTVAL)1 : diff < 0 ? (INTVAL)-1 : (INTVAL)0;
         }
 MMD_DEFAULT: {
             real_exception(INTERP, NULL, ILL_INHERIT,
-                  "attempt to compare number with %s",
-                  string_to_cstring(INTERP, VTABLE_name(INTERP, value)));
-            return (INTVAL)0;
+                "attempt to compare number with %Ss",
+                    VTABLE_name(INTERP, value));
         }
     }
 
 /*
 
-=item C<PMC* concatenate(PMC *value, PMC *dest)>
+=item C<PMC *concatenate(PMC *value, PMC *dest)>
 
 =cut
 
 */
-    PMC* concatenate(PMC* value,  PMC* dest) {
+    PMC *concatenate(PMC *value,  PMC *dest) {
 MMD_LuaNumber: {
-            STRING* s = string_concat(INTERP,
-                SELF.get_string(),
+            STRING *s = string_concat(INTERP, SELF.get_string(),
                 LuaNumber.value.get_string(), 0);
+
             dest = pmc_new(INTERP, dynpmc_LuaNumber);
             VTABLE_set_string_native(INTERP, dest, s);
+
             return dest;
         }
 MMD_LuaString: {
-            STRING* s = string_concat(INTERP,
-                SELF.get_string(),
+            STRING *s = string_concat(INTERP, SELF.get_string(),
                 LuaString.value.get_string(), 0);
+
             dest = pmc_new(INTERP, dynpmc_LuaNumber);
             VTABLE_set_string_native(INTERP, dest, s);
+
             return dest;
         }
 MMD_DEFAULT: {
             PMC *meth = find_meth(INTERP, value, "__concat");
-            if (meth != NULL) {
+
+            if (meth) {
                 dest = Parrot_runops_fromc_args(INTERP, meth, "PPP",
                                                 SELF, value);
-                if (PMC_IS_NULL(dest)) {
+
+                if (PMC_IS_NULL(dest))
                     dest = pmc_new(INTERP, dynpmc_LuaNil);
-                }
+
                 return dest;
             }
+
             real_exception(INTERP, NULL, ILL_INHERIT,
-                  "attempt to concatenate a %s value",
-                  string_to_cstring(INTERP, VTABLE_name(INTERP, value)));
-            return NULL;
+                "attempt to concatenate a %Ss value",
+                    VTABLE_name(INTERP, value));
         }
     }
 
 /*
 
-=item C<void i_concatenate(PMC* value)>
+=item C<void i_concatenate(PMC *value)>
 
 =cut
 
 */
-    void i_concatenate(PMC* value) {
+    void i_concatenate(PMC *value) {
 MMD_LuaNumber: {
-            STRING* s = SELF.get_string();
-            STRING* v = LuaNumber.value.get_string();
+            STRING *s = SELF.get_string();
+            STRING *v = LuaNumber.value.get_string();
             SELF.set_string_native(string_append(INTERP, s, v));
         }
 MMD_LuaString: {
-            STRING* s = SELF.get_string();
-            STRING* v = LuaString.value.get_string();
+            STRING *s = SELF.get_string();
+            STRING *v = LuaString.value.get_string();
             SELF.set_string_native(string_append(INTERP, s, v));
         }
 MMD_DEFAULT: {
             PMC *meth = find_meth(INTERP, value, "__concat");
-            if (meth != NULL) {
+            if (meth) {
                 SELF = Parrot_runops_fromc_args(INTERP, meth, "PPP",
                                                 SELF, value);
-                if (NULL == SELF) {
+
+                if (! SELF)
                     SELF = pmc_new(INTERP, dynpmc_LuaNil);
-                }
+
                 return;
             }
+
             real_exception(INTERP, NULL, ILL_INHERIT,
-                  "attempt to concatenate a %s value",
-                  string_to_cstring(INTERP, VTABLE_name(INTERP, value)));
+                "attempt to concatenate a %Ss value",
+                    VTABLE_name(INTERP, value));
         }
     }
 
@@ -869,29 +857,31 @@
 
 =over 4
 
-=item C<PMC* rawequal(PMC* value)>
+=item C<PMC *rawequal(PMC *value)>
 
 =cut
 
 */
-    METHOD PMC* rawequal(PMC* value) {
+    METHOD PMC *rawequal(PMC *value) {
         PMC *retval = pmc_new(INTERP, dynpmc_LuaBoolean);
-        if (PMC_type(SELF) == PMC_type(value)
-         && PMC_num_val(SELF) == PMC_num_val(value))
-            PMC_int_val(retval) = 1;
+
+        if (PMC_type(SELF)    == PMC_type(value)
+        &&  PMC_num_val(SELF) == PMC_num_val(value))
+            VTABLE_set_integer_native(INTERP, retval, 1);
         else
-            PMC_int_val(retval) = 0;
+            VTABLE_set_integer_native(INTERP, retval, 0);
+
         return retval;
     }
 
 /*
 
-=item C<PMC* tonumber()>
+=item C<PMC *tonumber()>
 
 =cut
 
 */
-    METHOD PMC* tonumber() {
+    METHOD PMC *tonumber() {
         return SELF.clone();
     }
 

Reply via email to