[svn:parrot] r43845 - branches/vtable_massacre/src/ops

whiteknight at svn.parrot.org whiteknight at svn.parrot.org
Wed Feb 10 03:13:38 UTC 2010


Author: whiteknight
Date: Wed Feb 10 03:13:38 2010
New Revision: 43845
URL: https://trac.parrot.org/parrot/changeset/43845

Log:
update the shr ops. Also, remove an 'evil' lvalue cast. Seriously, it was easy to get rid of, so why write a paragraph-long explanation about why it's evil but we're living with it anyway?

Modified:
   branches/vtable_massacre/src/ops/bit.ops

Modified: branches/vtable_massacre/src/ops/bit.ops
==============================================================================
--- branches/vtable_massacre/src/ops/bit.ops	Wed Feb 10 03:00:46 2010	(r43844)
+++ branches/vtable_massacre/src/ops/bit.ops	Wed Feb 10 03:13:38 2010	(r43845)
@@ -392,11 +392,16 @@
 }
 
 inline op shr(invar PMC, in INT) :base_core {
-    VTABLE_i_bitwise_shr_int(interp, $1, $2);
+    const INTVAL a = VTABLE_get_integer(interp, $1);
+    const INTVAL b = bit_shift_left(a, -$2);
+    VTABLE_set_integer_native(interp, $1, b);
 }
 
 inline op shr(invar PMC, invar PMC) :base_core {
-    VTABLE_i_bitwise_shr(interp, $1, $2);
+    const INTVAL a = VTABLE_get_integer(interp, $1);
+    const INTVAL b = VTABLE_get_integer(interp, $2);
+    const INTVAL c = bit_shift_left(a, -b);
+    VTABLE_set_integer_native(interp, $1, c);
 }
 
 inline op shr(out INT, in INT, in INT) :base_core {
@@ -405,11 +410,16 @@
 }
 
 inline op shr(invar PMC, invar PMC, in INT) :base_core {
-    $1 = VTABLE_bitwise_shr_int(interp, $2, $3, $1);
+    const INTVAL a = VTABLE_get_integer(interp, $2);
+    const INTVAL c = bit_shift_left(a, -$3);
+    VTABLE_set_integer_native(interp, $1, c);
 }
 
 inline op shr(invar PMC, invar PMC, invar PMC) :base_core {
-    $1 = VTABLE_bitwise_shr(interp, $2, $3, $1);
+    const INTVAL a = VTABLE_get_integer(interp, $2);
+    const INTVAL b = VTABLE_get_integer(interp, $3);
+    const INTVAL c = bit_shift_left(a, -b);
+    VTABLE_set_integer_native(interp, $1, c);
 }
 
 ########################################
@@ -433,11 +443,9 @@
 =cut
 
 inline op lsr(out INT, in INT) :base_core {
-    /*
-     * lvalue casts are evil, but this one isn't evil enough to kill.
-     * it's just casting a signed integral to the equivalent unsigned.
-     */
-    LVALUE_CAST(UINTVAL, $1) >>= $2;
+    const UINTVAL a = (UINTVAL)$1;
+    const UINTVAL b = a >> $2;
+    $1 = (INTVAL)b;
 }
 
 inline op lsr(invar PMC, in INT) :base_core {


More information about the parrot-commits mailing list