Here's some much-needed cmp ops.
Luke
Index: core.ops
===================================================================
RCS file: /cvs/public/parrot/core.ops,v
retrieving revision 1.274
diff -u -r1.274 core.ops
--- core.ops 30 May 2003 01:06:23 -0000 1.274
+++ core.ops 8 Jun 2003 03:26:14 -0000
@@ -688,6 +688,43 @@
=cut
+########################################
+
+=item B<cmp>(out INT, in INT, in INT)
+
+=item B<cmp>(out INT, in NUM, in NUM)
+
+=item B<cmp>(out INT, in STR, in STR)
+
+=item B<cmp>(out INT, in PMC, in PMC)
+
+Sets $1 to -1 if $2 < $3, +1 if $2 > $3, and 0 otherwise.
+
+=cut
+
+inline op cmp(out INT, in INT, in INT) {
+ $1 = $2 < $3 ? -1 :
+ $2 > $3 ? +1 :
+ 0;
+ goto NEXT();
+}
+
+inline op cmp(out INT, in NUM, in INT) {
+ $1 = $2 < $3 ? -1 :
+ $2 > $3 ? +1 :
+ 0;
+ goto NEXT();
+}
+
+inline op cmp(out INT, in STR, in STR) {
+ $1 = string_compare(interpreter, $2, $3);
+ goto NEXT();
+}
+
+inline op cmp(out INT, in PMC, in PMC) {
+ $1 = VTABLE_cmp(interpreter, $2, $3);
+ goto NEXT();
+}
########################################