[svn:parrot] r39629 - in trunk: src/ops t/op

NotFound at svn.parrot.org NotFound at svn.parrot.org
Wed Jun 17 15:25:11 UTC 2009


Author: NotFound
Date: Wed Jun 17 15:25:11 2009
New Revision: 39629
URL: https://trac.parrot.org/parrot/changeset/39629

Log:
[core] add 'isnull string' opcode

Modified:
   trunk/src/ops/cmp.ops
   trunk/src/ops/ops.num
   trunk/t/op/cmp-nonbranch.t

Modified: trunk/src/ops/cmp.ops
==============================================================================
--- trunk/src/ops/cmp.ops	Wed Jun 17 14:39:27 2009	(r39628)
+++ trunk/src/ops/cmp.ops	Wed Jun 17 15:25:11 2009	(r39629)
@@ -704,6 +704,10 @@
 
 Sets $1 to 1 if the object is null, 0 otherwise.
 
+=item B<isnull>(out INT, in STR)
+
+Sets $1 to 1 if the string is null, 0 otherwise.
+
 =cut
 
 inline op issame(out INT, invar PMC, invar PMC) {
@@ -740,6 +744,10 @@
     $1 = PMC_IS_NULL($2);
 }
 
+inline op isnull(out INT, in STR) {
+    $1 = STRING_IS_NULL($2);
+}
+
 =item B<isgt>(out INT, in INT, in INT)
 
 =item B<isgt>(out INT, in NUM, in NUM)

Modified: trunk/src/ops/ops.num
==============================================================================
--- trunk/src/ops/ops.num	Wed Jun 17 14:39:27 2009	(r39628)
+++ trunk/src/ops/ops.num	Wed Jun 17 15:25:11 2009	(r39629)
@@ -1278,3 +1278,5 @@
 find_name_p_sc                 1254
 find_sub_not_null_p_s          1255
 find_sub_not_null_p_sc         1256
+isnull_i_s                     1257
+isnull_i_sc                    1258

Modified: trunk/t/op/cmp-nonbranch.t
==============================================================================
--- trunk/t/op/cmp-nonbranch.t	Wed Jun 17 14:39:27 2009	(r39628)
+++ trunk/t/op/cmp-nonbranch.t	Wed Jun 17 15:25:11 2009	(r39629)
@@ -17,7 +17,7 @@
 =cut
 
 
-.const int TESTS = 90
+.const int TESTS = 93
 
 .macro EXP()
   exp_nok:
@@ -53,7 +53,8 @@
     'isntsame'()
     'istrue'()
     'isfalse'()
-    'isnull'()
+    'isnull_pmc'()
+    'isnull_string'()
     'isgt'()
     'isge'()
     'isle'()
@@ -159,9 +160,9 @@
 .end
 
 
-.sub 'isnull'
+.sub 'isnull_pmc'
     .local int exp, res
-    .SET_DESC('isnull')
+    .SET_DESC('isnull pmc')
 
   init:
     $S0 = 'FUBAR'
@@ -189,6 +190,18 @@
 .end
 
 
+.sub 'isnull_string'
+    .local int res
+    null $S0
+    res = isnull $S0
+    is(res, 1, 'isnull string null')
+    $S0 = 'something'
+    res = isnull $S0
+    is(res, 0, 'isnull string non null')
+    res = isnull 'H'
+    is(res, 0, 'isnull string constant')
+.end
+
 .sub 'isgt'
     .local string exp, res
 


More information about the parrot-commits mailing list