[svn:parrot] r49012 - in trunk: docs docs/pdds src src/ops src/pmc

luben at svn.parrot.org luben at svn.parrot.org
Wed Sep 15 05:33:20 UTC 2010


Author: luben
Date: Wed Sep 15 05:33:20 2010
New Revision: 49012
URL: https://trac.parrot.org/parrot/changeset/49012

Log:
Ripped out deprecated logical VTABLES

Parrot nead realclean and all depending code should be rebuild.

Modified:
   trunk/docs/embed.pod
   trunk/docs/pdds/pdd17_pmc.pod
   trunk/docs/vtables.pod
   trunk/src/ops/cmp.ops
   trunk/src/ops/core_ops.c
   trunk/src/pmc/boolean.pmc
   trunk/src/pmc/default.pmc
   trunk/src/pmc/scalar.pmc
   trunk/src/pmc/undef.pmc
   trunk/src/vtable.tbl

Modified: trunk/docs/embed.pod
==============================================================================
--- trunk/docs/embed.pod	Wed Sep 15 03:00:51 2010	(r49011)
+++ trunk/docs/embed.pod	Wed Sep 15 05:33:20 2010	(r49012)
@@ -1141,8 +1141,6 @@
 
 =item C<Parrot_PMC_i_floor_divide_int>
 
-=item C<Parrot_PMC_i_logical_not>
-
 =item C<Parrot_PMC_i_modulus>
 
 =item C<Parrot_PMC_i_modulus_float>
@@ -1199,14 +1197,6 @@
 
 =item C<Parrot_PMC_i_subtract_int>
 
-=item C<Parrot_PMC_logical_and>
-
-=item C<Parrot_PMC_logical_not>
-
-=item C<Parrot_PMC_logical_or>
-
-=item C<Parrot_PMC_logical_xor>
-
 =item C<Parrot_PMC_mark>
 
 =item C<Parrot_PMC_modulus>

Modified: trunk/docs/pdds/pdd17_pmc.pod
==============================================================================
--- trunk/docs/pdds/pdd17_pmc.pod	Wed Sep 15 03:00:51 2010	(r49011)
+++ trunk/docs/pdds/pdd17_pmc.pod	Wed Sep 15 05:33:20 2010	(r49012)
@@ -1327,40 +1327,6 @@
 greater). The C<_num> version performs a numeric comparison, while the
 C<_string> version performs a string comparison.
 
-=item logical_or
-
-  PMC* logical_or(INTERP, PMC *self, PMC *value, PMC *dest)
-
-Performs a logical OR, returning I<self> if it is true, and I<value>
-otherwise.
-
-=item logical_and
-
-  PMC* logical_and(INTERP, PMC *self, PMC *value, PMC *dest)
-
-Performs a logical AND, returning a true value if both I<self> and
-I<value> are true, and a false value otherwise. (Currently implemented
-as: If I<self> is false, return it, since the entire expression is
-false. If I<self> is true, return value, since the truth or falsehood of
-I<value> will determine the truth or falsehood of the whole expression.)
-
-=item logical_xor
-
-  PMC* logical_xor(INTERP, PMC *self, PMC *value, PMC *dest)
-
-Performs a logical XOR, returning I<self> if it is true and I<value> is
-false, returning I<value> if it is true and I<self> is false, and
-returning a false value (PMC of the same type as I<self>, with the
-boolean value 0) if both are true or neither are true.
-
-=item logical_not
-
-  PMC* logical_not(INTERP, PMC *self, PMC *dest)
-  void i_logical_not(INTERP, PMC *self)
-
-Returns the logical negation of I<self>. The C<i_> variant performs an
-inplace negation, modifying the value of I<self>.
-
 =back
 
 =head4 String Vtable Functions

Modified: trunk/docs/vtables.pod
==============================================================================
--- trunk/docs/vtables.pod	Wed Sep 15 03:00:51 2010	(r49011)
+++ trunk/docs/vtables.pod	Wed Sep 15 05:33:20 2010	(r49012)
@@ -280,17 +280,6 @@
 result in C<dest>. (Probably by calling its C<set_string> method) This is a
 string multimethod.
 
-=item C<logical_or>
-
-=item C<logical_and>
-
-Perform the given short-circuiting logical operations between your boolean
-value and the value passed in, storing the result in C<dest>.
-
-=item C<logical_not>
-
-Set yourself to be a logical negation of the value passed in.
-
 =item C<repeat>
 
 Repeat your string representation C<value> times and store the result in

Modified: trunk/src/ops/cmp.ops
==============================================================================
--- trunk/src/ops/cmp.ops	Wed Sep 15 03:00:51 2010	(r49011)
+++ trunk/src/ops/cmp.ops	Wed Sep 15 05:33:20 2010	(r49012)
@@ -928,7 +928,7 @@
 }
 
 inline op and(invar PMC, invar PMC, invar PMC) :base_core {
-    $1 = VTABLE_logical_and(interp, $2, $3, $1);
+    $1 = VTABLE_get_bool(interp, $2) ? $3 : $2;
 }
 
 ########################################
@@ -954,11 +954,12 @@
 }
 
 inline op not(invar PMC) :base_core {
-    VTABLE_i_logical_not(interp, $1);
+    VTABLE_set_bool(interp, $1, !VTABLE_get_bool(interp, $1));
 }
 
 inline op not(out PMC, invar PMC) :base_core {
-    $1 = VTABLE_logical_not(interp, $2, $1);
+    $1 = Parrot_pmc_new(interp, VTABLE_type(interp, $2));
+    VTABLE_set_bool(interp, $1, (!VTABLE_get_bool(interp, $2)));
 }
 
 ########################################
@@ -976,7 +977,7 @@
 }
 
 inline op or(invar PMC, invar PMC, invar PMC) :base_core {
-    $1 = VTABLE_logical_or(interp, $2, $3, $1);
+    $1 = VTABLE_get_bool(interp, $2) ? $2 : $3;
 }
 
 ########################################
@@ -995,7 +996,17 @@
 }
 
 inline op xor(invar PMC, invar PMC, invar PMC) :base_core {
-    $1 = VTABLE_logical_xor(interp, $2, $3, $1);
+    const INTVAL a = VTABLE_get_bool(interp, $2);
+    const INTVAL b = VTABLE_get_bool(interp, $3);
+    if (a && ! b)
+        $1 = $2;
+    else
+        if (b && ! a)
+            $1 = $3 ;
+        else{
+            $1 = Parrot_pmc_new(interp, VTABLE_type(interp, $2));
+            VTABLE_set_bool(interp, $1, 0);
+        }
 }
 
 =back

Modified: trunk/src/ops/core_ops.c
==============================================================================
--- trunk/src/ops/core_ops.c	Wed Sep 15 03:00:51 2010	(r49011)
+++ trunk/src/ops/core_ops.c	Wed Sep 15 05:33:20 2010	(r49012)
@@ -18211,7 +18211,7 @@
 opcode_t *
 Parrot_and_p_p_p(opcode_t *cur_opcode, PARROT_INTERP)  {
     const Parrot_Context * const CUR_CTX = Parrot_pcc_get_context_struct(interp, interp->ctx);
-    PREG(1) = VTABLE_logical_and(interp, PREG(2), PREG(3), PREG(1));
+    PREG(1) = VTABLE_get_bool(interp, PREG(2)) ? PREG(3) : PREG(2);
 
 return (opcode_t *)cur_opcode + 4;}
 
@@ -18232,14 +18232,15 @@
 opcode_t *
 Parrot_not_p(opcode_t *cur_opcode, PARROT_INTERP)  {
     const Parrot_Context * const CUR_CTX = Parrot_pcc_get_context_struct(interp, interp->ctx);
-    VTABLE_i_logical_not(interp, PREG(1));
+    VTABLE_set_bool(interp, PREG(1), !VTABLE_get_bool(interp, PREG(1)));
 
 return (opcode_t *)cur_opcode + 2;}
 
 opcode_t *
 Parrot_not_p_p(opcode_t *cur_opcode, PARROT_INTERP)  {
     const Parrot_Context * const CUR_CTX = Parrot_pcc_get_context_struct(interp, interp->ctx);
-    PREG(1) = VTABLE_logical_not(interp, PREG(2), PREG(1));
+    PREG(1) = Parrot_pmc_new(interp, VTABLE_type(interp, PREG(2)));
+    VTABLE_set_bool(interp, PREG(1), (!VTABLE_get_bool(interp, PREG(2))));
 
 return (opcode_t *)cur_opcode + 3;}
 
@@ -18267,7 +18268,7 @@
 opcode_t *
 Parrot_or_p_p_p(opcode_t *cur_opcode, PARROT_INTERP)  {
     const Parrot_Context * const CUR_CTX = Parrot_pcc_get_context_struct(interp, interp->ctx);
-    PREG(1) = VTABLE_logical_or(interp, PREG(2), PREG(3), PREG(1));
+    PREG(1) = VTABLE_get_bool(interp, PREG(2)) ? PREG(2) : PREG(3);
 
 return (opcode_t *)cur_opcode + 4;}
 
@@ -18295,7 +18296,17 @@
 opcode_t *
 Parrot_xor_p_p_p(opcode_t *cur_opcode, PARROT_INTERP)  {
     const Parrot_Context * const CUR_CTX = Parrot_pcc_get_context_struct(interp, interp->ctx);
-    PREG(1) = VTABLE_logical_xor(interp, PREG(2), PREG(3), PREG(1));
+    const INTVAL a = VTABLE_get_bool(interp, PREG(2));
+    const INTVAL b = VTABLE_get_bool(interp, PREG(3));
+    if (a && ! b)
+        PREG(1) = PREG(2);
+    else
+        if (b && ! a)
+            PREG(1) = PREG(3) ;
+        else{
+            PREG(1) = Parrot_pmc_new(interp, VTABLE_type(interp, PREG(2)));
+            VTABLE_set_bool(interp, PREG(1), 0);
+        }
 
 return (opcode_t *)cur_opcode + 4;}
 

Modified: trunk/src/pmc/boolean.pmc
==============================================================================
--- trunk/src/pmc/boolean.pmc	Wed Sep 15 03:00:51 2010	(r49011)
+++ trunk/src/pmc/boolean.pmc	Wed Sep 15 05:33:20 2010	(r49012)
@@ -163,12 +163,6 @@
         SELF.set_bool(Parrot_str_boolean(INTERP, value));
     }
 
-    /* No POD documentation, since the reader should see Scalar. */
-
-    VTABLE void i_logical_not() {
-        flip_boolean_FLAG(SELF);
-    }
-
 /*
 
 =item C<void freeze(PMC *info)>

Modified: trunk/src/pmc/default.pmc
==============================================================================
--- trunk/src/pmc/default.pmc	Wed Sep 15 03:00:51 2010	(r49011)
+++ trunk/src/pmc/default.pmc	Wed Sep 15 05:33:20 2010	(r49012)
@@ -1855,56 +1855,6 @@
 
         return retval;
     }
-/*
-
-=item C<PMC *logical_or(PMC *value, PMC *dest)>
-
-Default fallback. Performs a multiple dispatch call for 'logical_or'.
-
-=cut
-
-*/
-
-    VTABLE PMC *logical_or(PMC *value, PMC *dest) {
-        PMC *result = PMCNULL;
-        Parrot_mmd_multi_dispatch_from_c_args(INTERP,
-                "logical_or", "PPP->P", SELF, value, dest, &result);
-        return result;
-    }
-
-/*
-
-=item C<PMC *logical_and(PMC *value, PMC *dest)>
-
-Default fallback. Performs a multiple dispatch call for 'logical_and'.
-
-=cut
-
-*/
-
-    VTABLE PMC *logical_and(PMC *value, PMC *dest) {
-        PMC *result = PMCNULL;
-        Parrot_mmd_multi_dispatch_from_c_args(INTERP,
-                "logical_and", "PPP->P", SELF, value, dest, &result);
-        return result;
-    }
-
-/*
-
-=item C<PMC *logical_xor(PMC *value, PMC *dest)>
-
-Default fallback. Performs a multiple dispatch call for 'logical_xor'.
-
-=cut
-
-*/
-
-    VTABLE PMC *logical_xor(PMC *value, PMC *dest) {
-        PMC *result = PMCNULL;
-        Parrot_mmd_multi_dispatch_from_c_args(INTERP,
-                "logical_xor", "PPP->P", SELF, value, dest, &result);
-        return result;
-    }
 
 /*
 

Modified: trunk/src/pmc/scalar.pmc
==============================================================================
--- trunk/src/pmc/scalar.pmc	Wed Sep 15 03:00:51 2010	(r49011)
+++ trunk/src/pmc/scalar.pmc	Wed Sep 15 05:33:20 2010	(r49012)
@@ -807,98 +807,6 @@
 
 /*
 
-=back
-
-=head2 Logical Methods
-
-=over 4
-
-=item C<PMC *logical_or(PMC *value, PMC *dest)>
-
-Returns the result of the logical C<OR> of C<SELF> and C<value>, i.e. returns
-C<SELF> it is true or C<value>: C<dest> is alway ignored.
-
-=cut
-
-*/
-
-    VTABLE PMC *logical_or(PMC *value, PMC *dest) {
-        if (SELF.get_bool())
-            return SELF;
-
-        return value;
-    }
-
-/*
-
-=item C< PMC *logical_and(PMC *value, PMC *dest)>
-
-Returns the result of the logical C<AND> of C<SELF> and C<value>, i.e.
-returns C<value> if C<SELF> is true else C<SELF>. C<dest> is always ignored.
-
-=cut
-
-*/
-
-    VTABLE PMC *logical_and(PMC *value, PMC *dest) {
-        if (SELF.get_bool())
-            return value;
-
-        return SELF;
-    }
-
-/*
-
-=item C<PMC *logical_xor(PMC *value, PMC *dest)>
-
-Returns the result of the logical C<XOR> of C<SELF> and C<*value>.
-
-=cut
-
-*/
-
-    VTABLE PMC *logical_xor(PMC *value, PMC *dest) {
-        const INTVAL my_bool    = SELF.get_bool();
-        const INTVAL value_bool = VTABLE_get_bool(INTERP, value);
-
-        if (my_bool && ! value_bool)
-            return SELF;
-        else if (value_bool && ! my_bool)
-            return value;
-
-        dest = Parrot_pmc_new(INTERP, VTABLE_type(INTERP, SELF));
-        VTABLE_set_bool(INTERP, dest, 0);
-        return dest;
-    }
-
-/*
-
-=item C<PMC *logical_not(PMC *dest)>
-
-=item C<void i_logical_not()>
-
-Returns in C<*dest> the result of the logical negation of the scalar and
-C<*value>.
-
-=cut
-
-*/
-
-    VTABLE PMC *logical_not(PMC *dest) {
-        const INTVAL a = ! SELF.get_bool();
-
-        dest = Parrot_pmc_new(INTERP, VTABLE_type(INTERP, SELF));
-
-        VTABLE_set_bool(INTERP, dest, a);
-        return dest;
-    }
-
-    VTABLE void i_logical_not() {
-        VTABLE_set_bool(INTERP, SELF, ! SELF.get_bool());
-    }
-
-/*
-
 =item C<INTVAL defined()>
 
 Always returns true.

Modified: trunk/src/pmc/undef.pmc
==============================================================================
--- trunk/src/pmc/undef.pmc	Wed Sep 15 03:00:51 2010	(r49011)
+++ trunk/src/pmc/undef.pmc	Wed Sep 15 05:33:20 2010	(r49012)
@@ -212,22 +212,6 @@
 
 /*
 
-=item C<INTVAL logical_not()>
-
-Returns 1.
-
-=cut
-
-*/
-
-    VTABLE PMC *logical_not(PMC *dest) {
-        dest = Parrot_pmc_new(INTERP, VTABLE_type(INTERP, SELF));
-        VTABLE_set_bool(INTERP, dest, 1);
-        return dest;
-    }
-
-/*
-
 =item C<void share()>
 
 Unknown. (TODO)

Modified: trunk/src/vtable.tbl
==============================================================================
--- trunk/src/vtable.tbl	Wed Sep 15 03:00:51 2010	(r49011)
+++ trunk/src/vtable.tbl	Wed Sep 15 05:33:20 2010	(r49012)
@@ -192,16 +192,6 @@
 INTVAL cmp_string(PMC* value)
 PMC* cmp_pmc(PMC* value)
 
-PMC* logical_or(PMC* value, PMC* dest)
-
-PMC* logical_and(PMC* value, PMC* dest)
-
-PMC* logical_xor(PMC* value, PMC* dest)
-
-PMC* logical_not(PMC* dest)
-void i_logical_not() :write
-
-
 [STRING]
 PMC* concatenate(PMC* value, PMC* dest)
 PMC* concatenate_str(STRING* value, PMC* dest)


More information about the parrot-commits mailing list