Hi,
the attached patch adds a "isnull str, label" OP that is
similar to "isnull pmc, label"
jens
Index: ops/string.ops
===================================================================
RCS file: /cvs/public/parrot/ops/string.ops,v
retrieving revision 1.18
diff -u -w -r1.18 string.ops
--- ops/string.ops 26 Mar 2004 18:14:19 -0000 1.18
+++ ops/string.ops 1 Apr 2004 11:12:50 -0000
@@ -696,6 +696,19 @@
goto NEXT();
}
+=item B<isnull>(in STR, labelconst INT)
+
+Branch to $2 if $1 is a NULL string.
+
+=cut
+
+op isnull(in STR, labelconst INT) :base_core {
+ if ($1 == NULL) {
+ goto OFFSET($2);
+ }
+ goto NEXT();
+}
+
=back
=head1 COPYRIGHT
Index: ops/ops.num
===================================================================
RCS file: /cvs/public/parrot/ops/ops.num,v
retrieving revision 1.32
diff -u -w -r1.32 ops.num
--- ops/ops.num 26 Mar 2004 07:14:46 -0000 1.32
+++ ops/ops.num 1 Apr 2004 11:12:51 -0000
@@ -1442,3 +1442,5 @@
mmdvtfind_p_ic_i_ic 1415
mmdvtfind_p_i_ic_ic 1416
mmdvtfind_p_ic_ic_ic 1417
+isnull_s_ic 1418
+isnull_sc_ic 1419
Index: t/op/string.t
===================================================================
RCS file: /cvs/public/parrot/t/op/string.t,v
retrieving revision 1.69
diff -u -w -r1.69 string.t
--- t/op/string.t 27 Mar 2004 08:00:02 -0000 1.69
+++ t/op/string.t 1 Apr 2004 11:12:53 -0000
@@ -16,7 +16,7 @@
=cut
-use Parrot::Test tests => 130;
+use Parrot::Test tests => 131;
use Test::More;
output_is( <<'CODE', <<OUTPUT, "set_s_s|sc" );
@@ -2397,6 +2397,21 @@
ok 2
ok 3
ok 4
+OUTPUT
+
+output_is( <<'CODE', <<OUTPUT, "isnull_sc_ic");
+ set S0, "foo"
+ isnull S0, ERROR
+ print "ok 1\n"
+ null S0
+ isnull S0, OK
+ERROR: print "error\n"
+ end
+OK: print "ok 2\n"
+ end
+CODE
+ok 1
+ok 2
OUTPUT
1;