Author: leo
Date: Thu Apr 21 06:22:51 2005
New Revision: 7901

Modified:
   trunk/classes/integer.pmc
   trunk/classes/perlundef.pmc
   trunk/classes/scalar.pmc
   trunk/classes/string.pmc
   trunk/config/gen/makefiles/root.in
   trunk/dynclasses/pyint.pmc
   trunk/imcc/parser_util.c
   trunk/ops/bit.ops
   trunk/t/pmc/mmd.t
   trunk/vtable.tbl
Log:
MMD 31 - convert bit functions

* done: bor, band, bxor, bors, bands, bxors, shr, shl
* new:  lsr - bitwise_lsr MMD functions
* remove pyint duplicated code
* adapt bxor test to return result in overloaded sub

Pleae make realclean; ...



Modified: trunk/classes/integer.pmc
==============================================================================
--- trunk/classes/integer.pmc   (original)
+++ trunk/classes/integer.pmc   Thu Apr 21 06:22:51 2005
@@ -1145,110 +1145,6 @@
             VTABLE_set_integer_native(INTERP, dest, -PMC_int_val(SELF));
     }
 
-/*
-
-=item C<void bitwise_or(PMC *value, PMC *dest)>
-
-Calculates the bitwise C<OR> of the integer and C<*value> and returns
-the result in C<*dest>.
-
-=cut
-
-*/
-    void bitwise_or (PMC* value, PMC* dest) {
-        VTABLE_set_integer_native(INTERP, dest,
-            PMC_int_val(SELF) |
-            VTABLE_get_integer(INTERP, value)
-        );
-    }
-
-/*
-
-=item C<void bitwise_or_int(INTVAL value, PMC *dest)>
-
-Calculates the bitwise C<OR> of the integer and C<value> and returns
-the result in C<*dest>.
-
-=cut
-
-*/
-    void bitwise_or_int (INTVAL value, PMC* dest) {
-        VTABLE_set_integer_native(INTERP, dest,
-            PMC_int_val(SELF) | value
-        );
-    }
-
-/*
-
-=item C<void bitwise_and(PMC *value, PMC *dest)>
-
-Calculates the bitwise C<AND> of the integer and C<*value> and returns
-the result in C<*dest>.
-
-=cut
-
-*/
-    void bitwise_and (PMC* value, PMC* dest) {
-        VTABLE_set_integer_native(INTERP, dest,
-            PMC_int_val(SELF) &
-            VTABLE_get_integer(INTERP, value)
-        );
-    }
-
-/*
-
-=item C<void bitwise_and_int(INTVAL value, PMC *dest)>
-
-Calculates the bitwise C<AN> of the integer and C<*value> and returns
-the result in C<*dest>.
-
-=cut
-
-*/
-    void bitwise_and_int (INTVAL value, PMC* dest) {
-        VTABLE_set_integer_native(INTERP, dest,
-            PMC_int_val(SELF) & value
-        );
-    }
-
-/*
-
-=item C<void bitwise_xor(PMC *value, PMC *dest)>
-
-Calculates the bitwise C<XOR> of the integer and C<*value> and returns
-the result in C<*dest>.
-
-=cut
-
-*/
-    void bitwise_xor (PMC* value, PMC* dest) {
-MMD_Integer: {
-        VTABLE_set_integer_native(INTERP, dest,
-            PMC_int_val(SELF) ^ PMC_int_val(value));
-             }
-MMD_DEFAULT: {
-        VTABLE_set_integer_native(INTERP, dest,
-            PMC_int_val(SELF) ^
-            VTABLE_get_integer(INTERP, value)
-        );
-             }
-    }
-
-/*
-
-=item C<void bitwise_xor_int(INTVAL value, PMC *dest)>
-
-Calculates the bitwise C<XOR> of the integer and C<value> and returns
-the result in C<*dest>.
-
-=cut
-
-*/
-    void bitwise_xor_int (INTVAL value, PMC* dest) {
-        VTABLE_set_integer_native(INTERP, dest,
-            PMC_int_val(SELF) ^ value
-        );
-    }
 
 /*
 
@@ -1265,72 +1161,6 @@
     }
 
 /*
-
-=item C<void bitwise_shr(PMC *value, PMC *dest)>
-
-Calculates the bitwise shift right (C<<<>>>>>) of the integer by
-C<*value> and returns the result in C<*dest>.
-
-=cut
-
-*/
-    void bitwise_shr (PMC* value, PMC* dest) {
-        VTABLE_set_integer_native(INTERP, dest,
-            PMC_int_val(SELF) >>
-            VTABLE_get_integer(INTERP, value)
-        );
-    }
-
-/*
-
-=item C<void bitwise_shr_int(INTVAL value, PMC *dest)>
-
-Calculates the bitwise shift right (C<<<>>>>>) of the integer by
-C<value> and returns the result in C<*dest>.
-
-=cut
-
-*/
-    void bitwise_shr_int (INTVAL value, PMC* dest) {
-        VTABLE_set_integer_native(INTERP, dest,
-            PMC_int_val(SELF) >> value
-        );
-    }
-
-/*
-
-=item C<void bitwise_shl(PMC *value, PMC *dest)>
-
-Calculates the bitwise shift left (C<<<<<>>>) of the integer by
-C<*value> and returns the result in C<*dest>.
-
-=cut
-
-*/
-    void bitwise_shl (PMC* value, PMC* dest) {
-        VTABLE_set_integer_native(INTERP, dest,
-            PMC_int_val(SELF) <<
-            VTABLE_get_integer(INTERP, value)
-        );
-    }
-
-/*
-
-=item C<void bitwise_shl_int(INTVAL value, PMC *dest)>
-
-Calculates the bitwise shift left (C<<<<<>>>) of the integer by
-C<value> and returns the result in C<*dest>.
-
-=cut
-
-*/
-    void bitwise_shl_int (INTVAL value, PMC* dest) {
-        VTABLE_set_integer_native(INTERP, dest,
-            PMC_int_val(SELF) << value
-        );
-    }
-
-/*
 
 =item C<INTVAL is_equal (PMC* value)>
 

Modified: trunk/classes/perlundef.pmc
==============================================================================
--- trunk/classes/perlundef.pmc (original)
+++ trunk/classes/perlundef.pmc Thu Apr 21 06:22:51 2005
@@ -380,105 +380,6 @@
         return SUPER(value, dest);
     }
 
-/*
-
-=item C<void bitwise_or(PMC *value, PMC *dest)>
-
-=cut
-
-*/
-
-    void bitwise_or (PMC* value, PMC* dest) {
-        Parrot_warn(INTERP, PARROT_WARNINGS_UNDEF_FLAG,
-        "Use of uninitialized value in bitwise or");
-        VTABLE_set_integer_native(INTERP, dest,
-            VTABLE_get_integer(INTERP, value));
-    }
-
-/*
-
-=item C<void bitwise_or_int(INTVAL value, PMC *dest)>
-
-=cut
-
-*/
-
-    void bitwise_or_int (INTVAL value, PMC* dest) {
-        Parrot_warn(INTERP, PARROT_WARNINGS_UNDEF_FLAG,
-        "Use of uninitialized value in bitwise or");
-        VTABLE_set_integer_native(INTERP, dest, value);
-    }
-
-/*
-
-=item C<void bitwise_and(PMC *value, PMC *dest)>
-
-=cut
-
-*/
-
-    void bitwise_and (PMC* value, PMC* dest) {
-        Parrot_warn(INTERP, PARROT_WARNINGS_UNDEF_FLAG,
-        "Use of uninitialized value in bitwise and");
-        VTABLE_set_integer_native(INTERP, dest, 0);
-    }
-
-/*
-
-=item C<void bitwise_and_int(INTVAL value, PMC *dest)>
-
-=cut
-
-*/
-
-    void bitwise_and_int (INTVAL value, PMC* dest) {
-        Parrot_warn(INTERP, PARROT_WARNINGS_UNDEF_FLAG,
-        "Use of uninitialized value in bitwise and");
-        VTABLE_set_integer_native(INTERP, dest, 0);
-    }
-
-/*
-
-=item C<void bitwise_xor(PMC *value, PMC *dest)>
-
-=cut
-
-*/
-
-    void bitwise_xor (PMC* value, PMC* dest) {
-        Parrot_warn(INTERP, PARROT_WARNINGS_UNDEF_FLAG,
-        "Use of uninitialized value in bitwise xor");
-        VTABLE_set_integer_native(INTERP, dest,
-            VTABLE_get_integer(INTERP, value));
-    }
-
-/*
-
-=item C<void bitwise_xor_int(INTVAL value, PMC *dest)>
-
-=cut
-
-*/
-
-    void bitwise_xor_int (INTVAL value, PMC* dest) {
-        Parrot_warn(INTERP, PARROT_WARNINGS_UNDEF_FLAG,
-        "Use of uninitialized value in bitwise xor");
-        VTABLE_set_integer_native(INTERP, dest, value);
-    }
-
-/*
-
-=item C<void bitwise_not(PMC *dest)>
-
-=cut
-
-*/
-
-    void bitwise_not (PMC* dest) {
-        Parrot_warn(INTERP, PARROT_WARNINGS_UNDEF_FLAG,
-        "Use of uninitialized value in bitwise not");
-        VTABLE_set_integer_native(INTERP, dest, ~((INTVAL)0));
-    }
 
 /*
 

Modified: trunk/classes/scalar.pmc
==============================================================================
--- trunk/classes/scalar.pmc    (original)
+++ trunk/classes/scalar.pmc    Thu Apr 21 06:22:51 2005
@@ -710,116 +710,161 @@
 
 =over 4
 
-=item C<void bitwise_or(PMC *value, PMC *dest)>
+=item C<PMC* bitwise_or(PMC *value, PMC *dest)>
 
-Returns in C<*dest> the bitwise C<OR> of the scalar and C<*value>.
+=item C<PMC* bitwise_or_int(INTVAL value, PMC *dest)>
+
+Returns in C<*dest> the bitwise C<OR> of the scalar and C<value>.
+
+=item C<void i_bitwise_or(PMC *value)>
+
+=item C<void i_bitwise_or_int(INTVAL value)>
+
+Inplace bitwise or.
 
 =cut
 
 */
 
-    void bitwise_or (PMC* value, PMC* dest) {
+    PMC* bitwise_or (PMC* value, PMC* dest) {
         INTVAL result;
 
-        result = DYNSELF.get_integer()
-            | VTABLE_get_integer(INTERP, value);
-
+        result = DYNSELF.get_integer() | VTABLE_get_integer(INTERP, value);
+        if (!dest)
+            dest = pmc_new(INTERP, SELF->vtable->base_type);
         VTABLE_set_integer_native(INTERP, dest, result);
+        return dest;
     }
 
-/*
 
-=item C<void bitwise_or_int(INTVAL value, PMC *dest)>
+    PMC* bitwise_or_int (INTVAL value, PMC* dest) {
+        INTVAL result;
 
-Returns in C<*dest> the bitwise C<OR> of the scalar and C<value>.
+        result = DYNSELF.get_integer() | value;
+        if (!dest)
+            dest = pmc_new(INTERP, SELF->vtable->base_type);
+        VTABLE_set_integer_native(INTERP, dest, result);
+        return dest;
+    }
 
-=cut
+    void i_bitwise_or (PMC* value) {
+        INTVAL result;
 
-*/
+        result = DYNSELF.get_integer() | VTABLE_get_integer(INTERP, value);
+        DYNSELF.set_integer_native(result);
+    }
 
-    void bitwise_or_int (INTVAL value, PMC* dest) {
-        INTVAL result;
 
-        result = DYNSELF.get_integer()
-            | value;
+    void i_bitwise_or_int (INTVAL value) {
+        INTVAL result;
 
-        VTABLE_set_integer_native(INTERP, dest, result);
+        result = DYNSELF.get_integer() | value;
+        DYNSELF.set_integer_native(result);
     }
 
 /*
 
-=item C<void bitwise_and(PMC *value, PMC *dest)>
+=item C<PMC* bitwise_and(PMC *value, PMC *dest)>
+
+=item C<PMC* bitwise_and_int(INTVAL value, PMC *dest)>
+
+Returns in C<*dest> the bitwise C<AND> of the scalar and C<value>.
+
+=item C<void i_bitwise_and(PMC *value)>
 
-Returns in C<*dest> the bitwise C<AND> of the scalar and C<*value>.
+=item C<void i_bitwise_and_int(INTVAL value)>
+
+Inplace bitwise and.
 
 =cut
 
 */
 
-    void bitwise_and (PMC* value, PMC* dest) {
+    PMC* bitwise_and (PMC* value, PMC* dest) {
         INTVAL result;
 
-        result = DYNSELF.get_integer()
-            & VTABLE_get_integer(INTERP, value);
-
+        result = DYNSELF.get_integer() & VTABLE_get_integer(INTERP, value);
+        if (!dest)
+            dest = pmc_new(INTERP, SELF->vtable->base_type);
         VTABLE_set_integer_native(INTERP, dest, result);
+        return dest;
     }
 
-/*
+    PMC* bitwise_and_int (INTVAL value, PMC* dest) {
+        INTVAL result;
 
-=item C<void bitwise_and_int(INTVAL value, PMC *dest)>
+        result = DYNSELF.get_integer() & value;
+        if (!dest)
+            dest = pmc_new(INTERP, SELF->vtable->base_type);
+        VTABLE_set_integer_native(INTERP, dest, result);
+        return dest;
+    }
 
-Returns in C<*dest> the bitwise C<AND> of the scalar and C<value>.
+    void i_bitwise_and (PMC* value) {
+        INTVAL result;
 
-=cut
+        result = DYNSELF.get_integer() & VTABLE_get_integer(INTERP, value);
+        DYNSELF.set_integer_native(result);
+    }
 
-*/
 
-    void bitwise_and_int (INTVAL value, PMC* dest) {
+    void i_bitwise_and_int (INTVAL value) {
         INTVAL result;
 
-        result = DYNSELF.get_integer()
-            & value;
-
-        VTABLE_set_integer_native(INTERP, dest, result);
+        result = DYNSELF.get_integer() & value;
+        DYNSELF.set_integer_native(result);
     }
 
 /*
 
 =item C<void bitwise_xor(PMC *value, PMC *dest)>
 
+=item C<void bitwise_xor_int(INTVAL value, PMC *dest)>
+
 Returns in C<*dest> the bitwise C<XOR> of the scalar and C<*value>.
 
+=item C<void i_bitwise_xor(PMC *value)>
+
+=item C<void i_bitwise_xor_int(INTVAL value)>
+
+Inplace bitwise and.
+
 =cut
 
 */
 
-    void bitwise_xor (PMC* value, PMC* dest) {
+    PMC* bitwise_xor (PMC* value, PMC* dest) {
         INTVAL result;
 
-        result = DYNSELF.get_integer()
-            ^ VTABLE_get_integer(INTERP, value);
-
+        result = DYNSELF.get_integer() ^ VTABLE_get_integer(INTERP, value);
+        if (!dest)
+            dest = pmc_new(INTERP, SELF->vtable->base_type);
         VTABLE_set_integer_native(INTERP, dest, result);
+        return dest;
     }
 
-/*
-
-=item C<void bitwise_xor_int(INTVAL value, PMC *dest)>
+    PMC* bitwise_xor_int (INTVAL value, PMC* dest) {
+        INTVAL result;
 
-Returns in C<*dest> the bitwise C<XOR> of the scalar and C<value>.
+        result = DYNSELF.get_integer() ^ value;
+        if (!dest)
+            dest = pmc_new(INTERP, SELF->vtable->base_type);
+        VTABLE_set_integer_native(INTERP, dest, result);
+        return dest;
+    }
 
-=cut
+    void i_bitwise_xor (PMC* value) {
+        INTVAL result;
 
-*/
+        result = DYNSELF.get_integer() ^ VTABLE_get_integer(INTERP, value);
+        DYNSELF.set_integer_native(result);
+    }
 
-    void bitwise_xor_int (INTVAL value, PMC* dest) {
+    void i_bitwise_xor_int (INTVAL value) {
         INTVAL result;
 
-        result = DYNSELF.get_integer()
-            ^ value;
-
-        VTABLE_set_integer_native(INTERP, dest, result);
+        result = DYNSELF.get_integer() ^ value;
+        DYNSELF.set_integer_native(result);
     }
 
 /*
@@ -839,78 +884,160 @@
 
 /*
 
-=item C<void bitwise_shr(PMC *value, PMC *dest)>
+=item C<PMC* bitwise_shr(PMC *value, PMC *dest)>
+
+=item C<PMC* bitwise_shr_int(INTVAL value, PMC *dest)>
+
+Returns in C<*dest> the arithmetic shift right of the scalar by C<value>.
+
+=item C<void i_bitwise_shr(PMC *value)>
+
+=item C<void i_bitwise_shr_int(INTVAL value)>
 
-Returns in C<*dest> the shift right of the scalar by C<*value>.
+Inplace shift right.
 
 =cut
 
 */
 
-    void bitwise_shr (PMC* value, PMC* dest) {
+    PMC* bitwise_shr (PMC* value, PMC* dest) {
         INTVAL result;
 
-        result = DYNSELF.get_integer()
-            >> VTABLE_get_integer(INTERP, value);
+        result = DYNSELF.get_integer() >> VTABLE_get_integer(INTERP, value);
+        if (!dest)
+            dest = pmc_new(INTERP, SELF->vtable->base_type);
+        VTABLE_set_integer_native(INTERP, dest, result);
+        return dest;
+    }
+
+    PMC* bitwise_shr_int (INTVAL value, PMC* dest) {
+        INTVAL result;
 
+        result = DYNSELF.get_integer() >> value;
+        if (!dest)
+            dest = pmc_new(INTERP, SELF->vtable->base_type);
         VTABLE_set_integer_native(INTERP, dest, result);
+        return dest;
+    }
+
+    void i_bitwise_shr (PMC* value) {
+        INTVAL result;
+
+        result = DYNSELF.get_integer() >> VTABLE_get_integer(INTERP, value);
+        DYNSELF.set_integer_native(result);
+    }
+
+    void i_bitwise_shr_int (INTVAL value) {
+        INTVAL result;
+
+        result = DYNSELF.get_integer() >> value;
+        DYNSELF.set_integer_native(result);
     }
 
 /*
 
-=item C<void bitwise_shr_int(INTVAL value, PMC *dest)>
+=item C<PMC* bitwise_lsr(PMC *value, PMC *dest)>
+
+=item C<PMC* bitwise_lsr_int(INTVAL value, PMC *dest)>
+
+Returns in C<*dest> the logical shift right of the scalar by C<*value>.
 
-Returns in C<*dest> the shift right of the scalar by C<value>.
+=item C<void i_bitwise_lsr(PMC *value)>
+
+=item C<void i_bitwise_lsr_int(INTVAL value)>
+
+Inplace shift right.
 
 =cut
 
 */
 
-    void bitwise_shr_int (INTVAL value, PMC* dest) {
+    PMC* bitwise_lsr (PMC* value, PMC* dest) {
         INTVAL result;
 
-        result = DYNSELF.get_integer()
-            >> value;
+        result = (UINTVAL)DYNSELF.get_integer() >>
+            VTABLE_get_integer(INTERP, value);
+        if (!dest)
+            dest = pmc_new(INTERP, SELF->vtable->base_type);
+        VTABLE_set_integer_native(INTERP, dest, result);
+        return dest;
+    }
 
+    PMC* bitwise_lsr_int (INTVAL value, PMC* dest) {
+        INTVAL result;
+
+        result = (UINTVAL)DYNSELF.get_integer() >> value;
+        if (!dest)
+            dest = pmc_new(INTERP, SELF->vtable->base_type);
         VTABLE_set_integer_native(INTERP, dest, result);
+        return dest;
+    }
+
+    void i_bitwise_lsr (PMC* value) {
+        INTVAL result;
+
+        result = (UINTVAL)DYNSELF.get_integer() >>
+                VTABLE_get_integer(INTERP, value);
+        DYNSELF.set_integer_native(result);
+    }
+
+    void i_bitwise_lsr_int (INTVAL value) {
+        INTVAL result;
+
+        result = (UINTVAL)DYNSELF.get_integer() >> value;
+        DYNSELF.set_integer_native(result);
     }
 
 /*
 
-=item C<void bitwise_shl(PMC *value, PMC *dest)>
+=item C<PMC* bitwise_shl(PMC *value, PMC *dest)>
+
+=item C<PMC* bitwise_shl_int(INTVAL value, PMC *dest)>
 
 Returns in C<*dest> the shift left of the scalar by C<*value>.
 
+=item C<void i_bitwise_shl(PMC *value)>
+
+=item C<void i_bitwise_shl_int(INTVAL value)>
+
+Inplace shift left.
+
 =cut
 
 */
 
-    void bitwise_shl (PMC* value, PMC* dest) {
+    PMC* bitwise_shl (PMC* value, PMC* dest) {
         INTVAL result;
 
-        result = DYNSELF.get_integer()
-            << VTABLE_get_integer(INTERP, value);
-
+        result = DYNSELF.get_integer() << VTABLE_get_integer(INTERP, value);
+        if (!dest)
+            dest = pmc_new(INTERP, SELF->vtable->base_type);
         VTABLE_set_integer_native(INTERP, dest, result);
+        return dest;
     }
 
-/*
-
-=item C<void bitwise_shl_int(INTVAL value, PMC *dest)>
+    PMC* bitwise_shl_int (INTVAL value, PMC* dest) {
+        INTVAL result;
 
-Returns in C<*dest> the shift left of the scalar by C<value>.
+        result = DYNSELF.get_integer() << value;
+        if (!dest)
+            dest = pmc_new(INTERP, SELF->vtable->base_type);
+        VTABLE_set_integer_native(INTERP, dest, result);
+        return dest;
+    }
 
-=cut
+    void i_bitwise_shl (PMC* value) {
+        INTVAL result;
 
-*/
+        result = DYNSELF.get_integer() << VTABLE_get_integer(INTERP, value);
+        DYNSELF.set_integer_native(result);
+    }
 
-    void bitwise_shl_int (INTVAL value, PMC* dest) {
+    void i_bitwise_shl_int (INTVAL value) {
         INTVAL result;
 
-        result = DYNSELF.get_integer()
-            << value;
-
-        VTABLE_set_integer_native(INTERP, dest, result);
+        result = DYNSELF.get_integer() << value;
+        DYNSELF.set_integer_native(result);
     }
 
 /*
@@ -956,41 +1083,15 @@
         VTABLE_set_string_native(INTERP, dest, s);
     }
 
+
 /*
 
 =back
 
-=head2 Comparison Methods
+=head2 Compare Methods
 
 =over 4
 
-=item C<INTVAL is_equal(PMC *value)>
-
-Returns whether the scalar is equal to C<*value>.
-
-=cut
-
-*/
-
-    INTVAL is_equal (PMC* value) {
-        /* I think we need to check everything, do the easiest first... */
-        if (DYNSELF.get_integer()
-                == VTABLE_get_integer(INTERP, value)
-            && DYNSELF.get_number()
-                == VTABLE_get_number(INTERP, value)
-            && 0 == string_compare(INTERP,
-                DYNSELF.get_string(),
-                VTABLE_get_string(INTERP, value))
-            )
-        {
-            return 1;
-        }
-        return 0;
-    }
-
-
-/*
-
 =item C<INTVAL cmp_num(PMC *value)>
 
 Returns the result of comparing the floating-point values of the scalar

Modified: trunk/classes/string.pmc
==============================================================================
--- trunk/classes/string.pmc    (original)
+++ trunk/classes/string.pmc    Thu Apr 21 06:22:51 2005
@@ -272,90 +272,132 @@
 
 /*
 
-=item C<VOID bitwise_or(PMC* value, PMC* dest)>
+=item C<PMC* bitwise_ors(PMC* value, PMC* dest)>
 
-=item C<VOID bitwise_and(PMC* value, PMC* dest)>
+=item C<PMC* bitwise_ors_str(PMC* value, PMC* dest)>
 
-=item C<VOID bitwise_xor(PMC* value, PMC* dest)>
+=item C<PMC* bitwise_ands(PMC* value, PMC* dest)>
 
-=item C<VOID bitwise_ors(PMC* value, PMC* dest)>
+=item C<PMC* bitwise_ands_str(PMC* value, PMC* dest)>
 
-=item C<VOID bitwise_ors_str(PMC* value, PMC* dest)>
+=item C<PMC* bitwise_xors(PMC* value, PMC* dest)>
 
-=item C<VOID bitwise_ands(PMC* value, PMC* dest)>
+=item C<PMC* bitwise_xors_str(PMC* value, PMC* dest)>
 
-=item C<VOID bitwise_ands_str(PMC* value, PMC* dest)>
+=item C<void bitwise_nots(PMC* value)>
 
-=item C<VOID bitwise_xors(PMC* value, PMC* dest)>
+These functions perform bitwise operations on entire
+strings, and place the result in C<dest>.
+
+=item C<void i_bitwise_ors(PMC* value)>
+
+=item C<void i_bitwise_ors_str(PMC* value)>
 
-=item C<VOID bitwise_xors_str(PMC* value, PMC* dest)>
+=item C<void i_bitwise_ands(PMC* value)>
 
-=item C<VOID bitwise_nots(PMC* value)>
+=item C<void i_bitwise_ands_str(PMC* value)>
+
+=item C<void i_bitwise_xors(PMC* value)>
+
+=item C<void i_bitwise_xors_str(PMC* value)>
+
+=item C<void bitwise_nots(PMC* value)>
 
 These functions perform bitwise operations on entire
-strings, and place the result in C<dest>.
+strings in place.
 
 =cut
 
 */
-    void bitwise_or (PMC* value, PMC* dest) {
+    PMC* bitwise_ors (PMC* value, PMC* dest) {
         STRING *s = PMC_str_val(SELF);
         STRING *v = VTABLE_get_string(INTERP, value);
+        if (!dest)
+            dest = pmc_new(INTERP, SELF->vtable->base_type);
         VTABLE_set_string_native(
             INTERP, dest, string_bitwise_or(INTERP, s, v, NULL));
+        return dest;
     }
 
-    void bitwise_and (PMC* value, PMC* dest) {
+    PMC* bitwise_ors_str (STRING* value, PMC* dest) {
         STRING *s = PMC_str_val(SELF);
-        STRING *v = VTABLE_get_string(INTERP, value);
+        if (!dest)
+            dest = pmc_new(INTERP, SELF->vtable->base_type);
         VTABLE_set_string_native(
-            INTERP, dest, string_bitwise_and(INTERP, s, v, NULL));
+            INTERP, dest, string_bitwise_or(INTERP, s, value, NULL));
+        return dest;
     }
 
-    void bitwise_xor (PMC* value, PMC* dest) {
+    void i_bitwise_ors (PMC* value) {
         STRING *s = PMC_str_val(SELF);
         STRING *v = VTABLE_get_string(INTERP, value);
-        VTABLE_set_string_native(
-            INTERP, dest, string_bitwise_xor(INTERP, s, v, NULL));
+        DYNSELF.set_string_native(string_bitwise_or(INTERP, s, v, &s));
+    }
+
+    void i_bitwise_ors_str (STRING* value) {
+        STRING *s = PMC_str_val(SELF);
+        DYNSELF.set_string_native(string_bitwise_or(INTERP, s, value, &s));
     }
 
-    void bitwise_ors (PMC* value, PMC* dest) {
+    PMC* bitwise_ands (PMC* value, PMC* dest) {
         STRING *s = PMC_str_val(SELF);
         STRING *v = VTABLE_get_string(INTERP, value);
+        if (!dest)
+            dest = pmc_new(INTERP, SELF->vtable->base_type);
         VTABLE_set_string_native(
-            INTERP, dest, string_bitwise_or(INTERP, s, v, NULL));
+            INTERP, dest, string_bitwise_and(INTERP, s, v, NULL));
+        return dest;
     }
 
-    void bitwise_ors_str (STRING* value, PMC* dest) {
+    PMC* bitwise_ands_str (STRING* value, PMC* dest) {
         STRING *s = PMC_str_val(SELF);
+        if (!dest)
+            dest = pmc_new(INTERP, SELF->vtable->base_type);
         VTABLE_set_string_native(
-            INTERP, dest, string_bitwise_or(INTERP, s, value, NULL));
+            INTERP, dest, string_bitwise_and(INTERP, s, value, NULL));
+        return dest;
     }
 
-    void bitwise_ands (PMC* value, PMC* dest) {
+
+    void i_bitwise_ands (PMC* value) {
         STRING *s = PMC_str_val(SELF);
         STRING *v = VTABLE_get_string(INTERP, value);
-        VTABLE_set_string_native(
-            INTERP, dest, string_bitwise_and(INTERP, s, v, NULL));
+        DYNSELF.set_string_native(string_bitwise_and(INTERP, s, v, &s));
     }
 
-    void bitwise_ands_str (STRING* value, PMC* dest) {
+    void i_bitwise_ands_str (STRING* value) {
         STRING *s = PMC_str_val(SELF);
-        VTABLE_set_string_native(
-            INTERP, dest, string_bitwise_and(INTERP, s, value, NULL));
+        DYNSELF.set_string_native(string_bitwise_and(INTERP, s, value, &s));
     }
 
-    void bitwise_xors (PMC* value, PMC* dest) {
+    PMC* bitwise_xors (PMC* value, PMC* dest) {
         STRING *s = PMC_str_val(SELF);
         STRING *v = VTABLE_get_string(INTERP, value);
+        if (!dest)
+            dest = pmc_new(INTERP, SELF->vtable->base_type);
         VTABLE_set_string_native(
             INTERP, dest, string_bitwise_xor(INTERP, s, v, NULL));
+        return dest;
     }
 
-    void bitwise_xors_str (STRING* value, PMC* dest) {
+    PMC* bitwise_xors_str (STRING* value, PMC* dest) {
         STRING *s = PMC_str_val(SELF);
+        if (!dest)
+            dest = pmc_new(INTERP, SELF->vtable->base_type);
         VTABLE_set_string_native(
             INTERP, dest, string_bitwise_xor(INTERP, s, value, NULL));
+        return dest;
+    }
+
+    void i_bitwise_xors (PMC* value) {
+        STRING *s = PMC_str_val(SELF);
+        STRING *v = VTABLE_get_string(INTERP, value);
+        DYNSELF.set_string_native(string_bitwise_xor(INTERP, s, v, &s));
+    }
+
+    void i_bitwise_xors_str (STRING* value) {
+        STRING *s = PMC_str_val(SELF);
+        DYNSELF.set_string_native(string_bitwise_xor(INTERP, s, value, &s));
     }
 
     void bitwise_nots (PMC* dest) {

Modified: trunk/config/gen/makefiles/root.in
==============================================================================
--- trunk/config/gen/makefiles/root.in  (original)
+++ trunk/config/gen/makefiles/root.in  Thu Apr 21 06:22:51 2005
@@ -515,7 +515,7 @@
 
 # classes PMC build utils and rules
 PMC2CD=$(PERL) build_tools/pmc2c.pl --dump
-PMC2CC=$(PERL) build_tools/pmc2c.pl --c --no-lines
+PMC2CC=$(PERL) build_tools/pmc2c.pl --c
 PMC2CV=$(PERL) build_tools/pmc2c.pl --vt
 
 .pmc.dump :

Modified: trunk/dynclasses/pyint.pmc
==============================================================================
--- trunk/dynclasses/pyint.pmc  (original)
+++ trunk/dynclasses/pyint.pmc  Thu Apr 21 06:22:51 2005
@@ -224,195 +224,6 @@
 
 /*
 
-=item C<void bitwise_and(INTVAL value, PMC *dest)>
-
-Calculates the bitwise C<AND> of the integer and C<*value> and returns
-the result in C<*dest>.
-
-=cut
-
-*/
-
-    void bitwise_and (PMC *value, PMC* dest) {
-        VTABLE_set_integer_native(INTERP, dest,
-            PMC_int_val(SELF) & VTABLE_get_integer(INTERP, value)
-        );
-    }
-
-/*
-
-=item C<void bitwise_and_int(INTVAL value, PMC *dest)>
-
-Calculates the bitwise C<AND> of the integer and C<*value> and returns
-the result in C<*dest>.
-
-=cut
-
-*/
-
-    void bitwise_and_int (INTVAL value, PMC* dest) {
-        VTABLE_set_integer_native(INTERP, dest,
-            PMC_int_val(SELF) & value
-        );
-    }
-
-/*
-
-=item C<void bitwise_not(PMC *dest)>
-
-Calculates the bitwise C<NOT> of the integer and returns the result in
-C<*dest>.
-
-=cut
-
-*/
-
-    void bitwise_not (PMC* dest) {
-        VTABLE_set_integer_native(INTERP, dest, ~PMC_int_val(SELF));
-    }
-
-/*
-
-=item C<void bitwise_or(PMC *value, PMC *dest)>
-
-Calculates the bitwise C<OR> of the integer and C<*value> and returns
-the result in C<*dest>.
-
-=cut
-
-*/
-
-    void bitwise_or (PMC* value, PMC* dest) {
-        VTABLE_set_integer_native(INTERP, dest,
-            PMC_int_val(SELF) |
-            VTABLE_get_integer(INTERP, value)
-        );
-    }
-
-/*
-
-=item C<void bitwise_or_int(INTVAL value, PMC *dest)>
-
-Calculates the bitwise C<OR> of the integer and C<value> and returns
-the result in C<*dest>.
-
-=cut
-
-*/
-
-    void bitwise_or_int (INTVAL value, PMC* dest) {
-        VTABLE_set_integer_native(INTERP, dest,
-            PMC_int_val(SELF) | value
-        );
-    }
-
-/*
-
-=item C<void bitwise_shl(PMC *value, PMC *dest)>
-
-Calculates the bitwise shift left (C<<<<<>>>) of the integer by
-C<*value> and returns the result in C<*dest>.
-
-=cut
-
-*/
-
-    void bitwise_shl (PMC* value, PMC* dest) {
-        VTABLE_set_integer_native(INTERP, dest,
-            PMC_int_val(SELF) <<
-            VTABLE_get_integer(INTERP, value)
-        );
-    }
-
-/*
-
-=item C<void bitwise_shl_int(INTVAL value, PMC *dest)>
-
-Calculates the bitwise shift left (C<<<<<>>>) of the integer by
-C<value> and returns the result in C<*dest>.
-
-=cut
-
-*/
-
-    void bitwise_shl_int (INTVAL value, PMC* dest) {
-        VTABLE_set_integer_native(INTERP, dest,
-            PMC_int_val(SELF) << value
-        );
-    }
-
-/*
-
-=item C<void bitwise_shr(PMC *value, PMC *dest)>
-
-Calculates the bitwise shift right (C<<<>>>>>) of the integer by
-C<*value> and returns the result in C<*dest>.
-
-=cut
-
-*/
-
-    void bitwise_shr (PMC* value, PMC* dest) {
-        VTABLE_set_integer_native(INTERP, dest,
-            PMC_int_val(SELF) >>
-            VTABLE_get_integer(INTERP, value)
-        );
-    }
-
-/*
-
-=item C<void bitwise_shr_int(INTVAL value, PMC *dest)>
-
-Calculates the bitwise shift right (C<<<>>>>>) of the integer by
-C<value> and returns the result in C<*dest>.
-
-=cut
-
-*/
-
-    void bitwise_shr_int (INTVAL value, PMC* dest) {
-        VTABLE_set_integer_native(INTERP, dest,
-            PMC_int_val(SELF) >> value
-        );
-    }
-
-/*
-
-=item C<void bitwise_xor(PMC *value, PMC *dest)>
-
-Calculates the bitwise C<XOR> of the integer and C<*value> and returns
-the result in C<*dest>.
-
-=cut
-
-*/
-
-    void bitwise_xor (PMC* value, PMC* dest) {
-        VTABLE_set_integer_native(INTERP, dest,
-            PMC_int_val(SELF) ^
-            VTABLE_get_integer(INTERP, value)
-        );
-    }
-
-/*
-
-=item C<void bitwise_xor_int(INTVAL value, PMC *dest)>
-
-Calculates the bitwise C<XOR> of the integer and C<value> and returns
-the result in C<*dest>.
-
-=cut
-
-*/
-
-    void bitwise_xor_int (INTVAL value, PMC* dest) {
-        VTABLE_set_integer_native(INTERP, dest,
-            PMC_int_val(SELF) ^ value
-        );
-    }
-
-/*
-
 =item C<INTVAL cmp(PMC *value)>
 
 Returns the result of comparing the integer with C<*value>.

Modified: trunk/imcc/parser_util.c
==============================================================================
--- trunk/imcc/parser_util.c    (original)
+++ trunk/imcc/parser_util.c    Thu Apr 21 06:22:51 2005
@@ -387,6 +387,26 @@
     if (strcmp(name, "pow") == 0)
         return MMD_POW;
 
+    if (strcmp(name, "bor") == 0)
+        return MMD_BOR;
+    if (strcmp(name, "band") == 0)
+        return MMD_BAND;
+    if (strcmp(name, "bxor") == 0)
+        return MMD_BXOR;
+    if (strcmp(name, "bors") == 0)
+        return MMD_SOR;
+    if (strcmp(name, "bands") == 0)
+        return MMD_SAND;
+    if (strcmp(name, "bxors") == 0)
+        return MMD_SXOR;
+
+    if (strcmp(name, "shl") == 0)
+        return MMD_BSL;
+    if (strcmp(name, "shr") == 0)
+        return MMD_BSR;
+    if (strcmp(name, "lsr") == 0)
+        return MMD_LSR;
+
     /* now try n_<op> */
     if (name[0] == 'n' && name[1] == '_')
         return is_infix(name + 2, n, r);

Modified: trunk/ops/bit.ops
==============================================================================
--- trunk/ops/bit.ops   (original)
+++ trunk/ops/bit.ops   Thu Apr 21 06:22:51 2005
@@ -353,12 +353,21 @@
 }
 
 ########################################
+
 =item B<lsr>(inout INT, in INT)
 
-Logically shift $1 right by $2.
+=item B<lsr>(in PMC, in INT)
+
+=item B<lsr>(in PMC, in PMC)
+
+Shift $1 logically shifted right by $2 bits.
 
 =item B<lsr>(out INT, in INT, in INT)
 
+=item B<lsr>(out PMC, in PMC, in INT)
+
+=item B<lsr>(out PMC, in PMC, in PMC)
+
 Set $1 to the value of $2 logically shifted right by $3 bits.
 
 =cut

Modified: trunk/t/pmc/mmd.t
==============================================================================
--- trunk/t/pmc/mmd.t   (original)
+++ trunk/t/pmc/mmd.t   Thu Apr 21 06:22:51 2005
@@ -295,7 +295,9 @@
     print "ok\n"
     set I10, P5
     bxor I11, I10, I5
-    set P6, I11
+    new P5, .Integer
+    set P5, I11
+    set I3, 1
     returncc
 CODE
 ok

Modified: trunk/vtable.tbl
==============================================================================
--- trunk/vtable.tbl    (original)
+++ trunk/vtable.tbl    Thu Apr 21 06:22:51 2005
@@ -209,33 +209,63 @@
 void neg(PMC* dest)
 
 [BITWISE]
-void bitwise_or(PMC* value, PMC* dest)       MMD_BOR
-void bitwise_or_int(INTVAL value, PMC* dest) MMD_BOR_INT
+PMC* bitwise_or(PMC* value, PMC* dest)          MMD_BOR
+PMC* bitwise_or_int(INTVAL value, PMC* dest)    MMD_BOR_INT
 
-void bitwise_and(PMC* value, PMC* dest)         MMD_BAND
-void bitwise_and_int(INTVAL value, PMC* dest)   MMD_BAND_INT
+void i_bitwise_or(PMC* value)                   MMD_I_BOR
+void i_bitwise_or_int(INTVAL value)             MMD_I_BOR_INT
 
-void bitwise_xor(PMC* value, PMC* dest)        MMD_BXOR
-void bitwise_xor_int(INTVAL value, PMC* dest)  MMD_BXOR_INT
+PMC* bitwise_and(PMC* value, PMC* dest)         MMD_BAND
+PMC* bitwise_and_int(INTVAL value, PMC* dest)   MMD_BAND_INT
 
-void bitwise_ors(PMC* value, PMC* dest)         MMD_SOR
-void bitwise_ors_str(STRING* value, PMC* dest)  MMD_SOR_STR
+void i_bitwise_and(PMC* value)                  MMD_I_BAND
+void i_bitwise_and_int(INTVAL value)            MMD_I_BAND_INT
 
-void bitwise_ands(PMC* value, PMC* dest)        MMD_SAND
-void bitwise_ands_str(STRING* value, PMC* dest) MMD_SAND_STR
+PMC* bitwise_xor(PMC* value, PMC* dest)         MMD_BXOR
+PMC* bitwise_xor_int(INTVAL value, PMC* dest)   MMD_BXOR_INT
 
-void bitwise_xors(PMC* value, PMC* dest)        MMD_SXOR
-void bitwise_xors_str(STRING* value, PMC* dest) MMD_SXOR_STR
+void i_bitwise_xor(PMC* value)                  MMD_I_BXOR
+void i_bitwise_xor_int(INTVAL value)            MMD_I_BXOR_INT
+
+PMC* bitwise_ors(PMC* value, PMC* dest)         MMD_SOR
+PMC* bitwise_ors_str(STRING* value, PMC* dest)  MMD_SOR_STR
+
+void i_bitwise_ors(PMC* value)                  MMD_I_SOR
+void i_bitwise_ors_str(STRING* value)           MMD_I_SOR_STR
+
+PMC* bitwise_ands(PMC* value, PMC* dest)        MMD_SAND
+PMC* bitwise_ands_str(STRING* value, PMC* dest) MMD_SAND_STR
+
+void i_bitwise_ands(PMC* value)                 MMD_I_SAND
+void i_bitwise_ands_str(STRING* value)          MMD_I_SAND_STR
+
+PMC* bitwise_xors(PMC* value, PMC* dest)        MMD_SXOR
+PMC* bitwise_xors_str(STRING* value, PMC* dest) MMD_SXOR_STR
+
+void i_bitwise_xors(PMC* value)                 MMD_I_SXOR
+void i_bitwise_xors_str(STRING* value)          MMD_I_SXOR_STR
 
 void bitwise_not(PMC* dest)
 
 void bitwise_nots(PMC* dest)
 
-void bitwise_shl(PMC* value, PMC* dest)        MMD_BSL
-void bitwise_shl_int(INTVAL value, PMC* dest)  MMD_BSL_INT
+PMC* bitwise_shl(PMC* value, PMC* dest)         MMD_BSL
+PMC* bitwise_shl_int(INTVAL value, PMC* dest)   MMD_BSL_INT
+
+void i_bitwise_shl(PMC* value)                  MMD_I_BSL
+void i_bitwise_shl_int(INTVAL value)            MMD_I_BSL_INT
+
+PMC* bitwise_shr(PMC* value, PMC* dest)         MMD_BSR
+PMC* bitwise_shr_int(INTVAL value, PMC* dest)   MMD_BSR_INT
+
+void i_bitwise_shr(PMC* value)                  MMD_I_BSR
+void i_bitwise_shr_int(INTVAL value)            MMD_I_BSR_INT
+
+PMC* bitwise_lsr(PMC* value, PMC* dest)         MMD_LSR
+PMC* bitwise_lsr_int(INTVAL value, PMC* dest)   MMD_LSR_INT
 
-void bitwise_shr(PMC* value, PMC* dest)        MMD_BSR
-void bitwise_shr_int(INTVAL value, PMC* dest)  MMD_BSR_INT
+void i_bitwise_lsr(PMC* value)                  MMD_I_LSR
+void i_bitwise_lsr_int(INTVAL value)            MMD_I_LSR_INT
 
 [CMP]
 INTVAL is_equal(PMC* value)                  MMD_EQ

Reply via email to