diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/AnyNA.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/AnyNA.java index 6a9b1e8f907831b7e9dda078125f62727709a886..57c48da529aacc0ff7572c242cf1506658bf41fb 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/AnyNA.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/AnyNA.java @@ -54,20 +54,6 @@ public abstract class AnyNA extends RBuiltinNode { private final NACheck naCheck = NACheck.create(); - private final boolean recursionAllowed; - - protected AnyNA(boolean recursionAllowed) { - this.recursionAllowed = recursionAllowed; - } - - protected AnyNA() { - this(true); - } - - protected boolean isRecursionAllowed() { - return recursionAllowed; - } - public abstract byte execute(VirtualFrame frame, Object value, boolean recursive); @Override @@ -161,13 +147,13 @@ public abstract class AnyNA extends RBuiltinNode { return doScalar(false); } - protected AnyNA createRecursive(boolean recursive) { - return AnyNANodeGen.create(recursive); + protected AnyNA createRecursive() { + return AnyNANodeGen.create(); } - @Specialization(guards = "isRecursionAllowed()") + @Specialization(guards = "recursive") protected byte isNA(VirtualFrame frame, RList list, boolean recursive, - @Cached("createRecursive(recursive)") AnyNA recursiveNode, + @Cached("createRecursive()") AnyNA recursiveNode, @Cached("createClassProfile()") ValueProfile elementProfile, @Cached("create()") RLengthNode length) { @@ -183,7 +169,7 @@ public abstract class AnyNA extends RBuiltinNode { return RRuntime.LOGICAL_FALSE; } - @Specialization(guards = "!isRecursionAllowed()") + @Specialization(guards = "!recursive") @SuppressWarnings("unused") protected byte isNA(VirtualFrame frame, RList list, boolean recursive) { return RRuntime.LOGICAL_FALSE; diff --git a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/ExpectedTestOutput.test b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/ExpectedTestOutput.test index 334667a09750ed2dd53d1e11e952edf071e8f1b6..9dc7b910fba07909695e2b172deb13727417ada8 100644 --- a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/ExpectedTestOutput.test +++ b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/ExpectedTestOutput.test @@ -2721,6 +2721,34 @@ In anyDuplicated.default(c(1L, 2L, 1L, 1L, 3L, 2L), incomparables = "cat") : #anyNA(list(list(c(NA)),c(1)), recursive=c(FALSE,TRUE)) [1] FALSE +##com.oracle.truffle.r.test.builtins.TestBuiltin_anyNA.testanyNA3# +#anyNA(c(1, 2, 3)) +[1] FALSE + +##com.oracle.truffle.r.test.builtins.TestBuiltin_anyNA.testanyNA3# +#anyNA(c(1, NA, 3)) +[1] TRUE + +##com.oracle.truffle.r.test.builtins.TestBuiltin_anyNA.testanyNA3# +#anyNA(c(1, NA, 3), recursive = TRUE) +[1] TRUE + +##com.oracle.truffle.r.test.builtins.TestBuiltin_anyNA.testanyNA3# +#anyNA(list(a = c(1, 2, 3), b = 'a')) +[1] FALSE + +##com.oracle.truffle.r.test.builtins.TestBuiltin_anyNA.testanyNA3# +#anyNA(list(a = c(1, 2, 3), b = 'a'), recursive = TRUE) +[1] FALSE + +##com.oracle.truffle.r.test.builtins.TestBuiltin_anyNA.testanyNA3# +#anyNA(list(a = c(1, NA, 3), b = 'a')) +[1] FALSE + +##com.oracle.truffle.r.test.builtins.TestBuiltin_anyNA.testanyNA3# +#anyNA(list(a = c(1, NA, 3), b = 'a'), recursive = TRUE) +[1] TRUE + ##com.oracle.truffle.r.test.builtins.TestBuiltin_aperm.testAperm# #{ a = array(1:24,c(2,3,4)); b = aperm(a); c(dim(b)[1],dim(b)[2],dim(b)[3]) } [1] 4 3 2 diff --git a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/builtins/TestBuiltin_anyNA.java b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/builtins/TestBuiltin_anyNA.java index cea95545ce24d229ee5943fa53220345c2d9141b..4b36de5ed4b3ff0531c106d3a2e6413b7d2274db 100644 --- a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/builtins/TestBuiltin_anyNA.java +++ b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/builtins/TestBuiltin_anyNA.java @@ -31,4 +31,15 @@ public class TestBuiltin_anyNA extends TestBase { assertEval("anyNA(list(list(4,5,NA), 3), recursive=TRUE)"); } + @Test + public void testanyNA3() { + assertEval("anyNA(c(1, 2, 3))"); + assertEval("anyNA(c(1, NA, 3))"); + assertEval("anyNA(c(1, NA, 3), recursive = TRUE)"); + assertEval("anyNA(list(a = c(1, 2, 3), b = 'a'))"); + assertEval("anyNA(list(a = c(1, NA, 3), b = 'a'))"); + assertEval("anyNA(list(a = c(1, 2, 3), b = 'a'), recursive = TRUE)"); + assertEval("anyNA(list(a = c(1, NA, 3), b = 'a'), recursive = TRUE)"); + } + }