# New Ticket Created by Christoph Otto # Please include the string: [perl #59782] # in the subject line of all future correspondence about this issue. # <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=59782 >
In response to a question about comparison operators in Pipp*, Allison suggested that I add a variant cmp VTABLE function which returns a PMC instead of an INTVAL. This patch adds such a function, named pmc_cmp. It's named pmc_cmp rather than cmp_pmc to try to avoid confusion with the other cmp_* functions, since the type name in this function name refers to the return type rather than the argument type. The patch should be simple enough to be obviously correct and doesn't cause any new test failures. Comments would be appreciated. * http://irclog.perlgeek.de/parrotsketch/2008-10-07#i_609226
Index: src/vtable.tbl =================================================================== --- src/vtable.tbl (revision 31855) +++ src/vtable.tbl (working copy) @@ -273,6 +273,7 @@ INTVAL cmp(PMC* value) INTVAL cmp_num(PMC* value) INTVAL cmp_string(PMC* value) +PMC* pmc_cmp(PMC* value) PMC* logical_or(PMC* value, PMC* dest) Index: src/pmc/default.pmc =================================================================== --- src/pmc/default.pmc (revision 31855) +++ src/pmc/default.pmc (working copy) @@ -2488,6 +2488,29 @@ /* +=item C<PMC *pmc_cmp(PMC *value)> + +Default fallback. Performs a multiple dispatch call for 'pmc_cmp'. + +=cut + +*/ + + VTABLE PMC *pmc_cmp(PMC *value) { + PMC *retval; + + /* Don't multidispatch if you've got two pointers to the same PMC. They + * are equal. */ + if (SELF == value) + return 0; + + Parrot_mmd_multi_dispatch_from_c_args(interp, + "pmc_cmp", "PP->P", SELF, value, &retval); + + return retval; + } +/* + =item C<PMC *logical_or(PMC *value, PMC *dest)> Default fallback. Performs a multiple dispatch call for 'logical_or'. Index: tools/dev/vtablize.pl =================================================================== --- tools/dev/vtablize.pl (revision 31855) +++ tools/dev/vtablize.pl (working copy) @@ -220,6 +220,7 @@ s/^(\s*)(INTVAL\s+cmp\(PMC\s+\*\w*\)\s+{)/$1VTABLE $2/; s/^(\s*)(INTVAL\s+cmp_num\(PMC\s+\*\w*\)\s+{)/$1VTABLE $2/; s/^(\s*)(INTVAL\s+cmp_string\(PMC\s+\*\w*\)\s+{)/$1VTABLE $2/; +s/^(\s*)(INTVAL\s+pmc_cmp\(PMC\s+\*\w*\)\s+{)/$1VTABLE $2/; s/^(\s*)(PMC\s+\*logical_or\(PMC\s+\*\w*,\s+PMC\s+\*\w*\)\s+{)/$1VTABLE $2/; s/^(\s*)(PMC\s+\*logical_xor\(PMC\s+\*\w*,\s+PMC\s+\*\w*\)\s+{)/$2VTABLE $2/; s/^(\s*)(PMC\s+\*logical_and\(PMC\s+\*\w*,\s+PMC\s+\*\w*\)\s+{)/$1VTABLE $2/;