diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/CastListNode.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/CastListNode.java index 2ea4c2b07e10e2b1091fda964087e9e2ba77f6cc..9a868b06d2ba24581bfec447e8c02de0076bfddc 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/CastListNode.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/CastListNode.java @@ -166,4 +166,8 @@ public abstract class CastListNode extends CastBaseNode { public static CastListNode createForRFFI(boolean preserveNames, boolean preserveDimensions, boolean preserveAttributes) { return CastListNodeGen.create(preserveNames, preserveDimensions, preserveAttributes, true); } + + protected boolean isForeignObject(TruffleObject to) { + return RRuntime.isForeignObject(to); + } } diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/PrecedenceNode.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/PrecedenceNode.java index 1d8a29e9d0177c5ed84f70955de8b0cf4fa606e6..52c861931e2d24a3b67b5c957da3e29cda2bd900 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/PrecedenceNode.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/PrecedenceNode.java @@ -153,11 +153,6 @@ public abstract class PrecedenceNode extends RBaseNode { return LIST_PRECEDENCE; } - @Specialization - protected int doRInteroptFloat(RInterop b, boolean recursive) { - return NO_PRECEDENCE; - } - @Specialization(guards = "recursive") protected int doListRecursive(RList val, boolean recursive, @Cached("createRecursive()") PrecedenceNode precedenceNode) { @@ -227,4 +222,8 @@ public abstract class PrecedenceNode extends RBaseNode { @Cached("createRecursive()") PrecedenceNode precedenceNode) { return precedenceNode.executeInteger(args.getArgument(0), recursive); } + + protected boolean isForeignObject(TruffleObject to) { + return RRuntime.isForeignObject(to); + } } 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 23d2b3fefd7c2bfffbf65118820ea631da1b5eb9..002c9113b1087ee2dd9752a84e016b7bf823e8f5 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 @@ -130568,6 +130568,38 @@ attr(,"is.truffle.object") #if (length(grep("FastR", R.Version()$version.string)) != 1) { "true127a32767214748364792233720368547758071.7976931348623157E3083.4028235E38testString" } else { tc <- .fastr.java.class('com.oracle.truffle.r.test.library.fastr.TestJavaInterop$TestClass'); t <- .fastr.interop.new(tc); t$allTypesStaticMethod(TRUE,127,"a",32767,2147483647,9223372036854775807,1.7976931348623157E308,3.4028235E38,"testString") } [1] "true127a32767214748364792233720368547758071.7976931348623157E3083.4028235E38testString" +##com.oracle.truffle.r.test.library.fastr.TestJavaInterop.testCombine# +#if (length(grep("FastR", R.Version()$version.string)) != 1) { 'interopt.byte' } else { class(c(.fastr.interop.toByte(123))) } +[1] "interopt.byte" + +##com.oracle.truffle.r.test.library.fastr.TestJavaInterop.testCombine# +#if (length(grep("FastR", R.Version()$version.string)) != 1) { 'list' } else { class(c(.fastr.interop.toByte(123), .fastr.interop.toByte(234))) } +[1] "list" + +##com.oracle.truffle.r.test.library.fastr.TestJavaInterop.testCombine# +#if (length(grep("FastR", R.Version()$version.string)) != 1) { 'list' } else { class(c(.fastr.interop.toByte(123), 1)) } +[1] "list" + +##com.oracle.truffle.r.test.library.fastr.TestJavaInterop.testCombine# +#if (length(grep("FastR", R.Version()$version.string)) != 1) { 'list' } else { class(c(1, .fastr.interop.toByte(123))) } +[1] "list" + +##com.oracle.truffle.r.test.library.fastr.TestJavaInterop.testCombine# +#if (length(grep("FastR", R.Version()$version.string)) != 1) { 'list' } else { tc <- .fastr.java.class('com.oracle.truffle.r.test.library.fastr.TestJavaInterop$TestClass'); t <- .fastr.interop.new(tc); class(c(1, t)) } +[1] "list" + +##com.oracle.truffle.r.test.library.fastr.TestJavaInterop.testCombine# +#if (length(grep("FastR", R.Version()$version.string)) != 1) { 'list' } else { tc <- .fastr.java.class('com.oracle.truffle.r.test.library.fastr.TestJavaInterop$TestClass'); t <- .fastr.interop.new(tc); class(c(t, 1)) } +[1] "list" + +##com.oracle.truffle.r.test.library.fastr.TestJavaInterop.testCombine# +#if (length(grep("FastR", R.Version()$version.string)) != 1) { 'list' } else { tc <- .fastr.java.class('com.oracle.truffle.r.test.library.fastr.TestJavaInterop$TestClass'); t <- .fastr.interop.new(tc); t1 <- .fastr.interop.new(tc); class(c(t, t1)) } +[1] "list" + +##com.oracle.truffle.r.test.library.fastr.TestJavaInterop.testCombine# +#if (length(grep("FastR", R.Version()$version.string)) != 1) { 'truffle.object' } else { tc <- .fastr.java.class('com.oracle.truffle.r.test.library.fastr.TestJavaInterop$TestClass'); t <- .fastr.interop.new(tc); class(c(t)) } +[1] "truffle.object" + ##com.oracle.truffle.r.test.library.fastr.TestJavaInterop.testFields# #if (length(grep("FastR", R.Version()$version.string)) != 1) { "a string" } else { tc <- .fastr.java.class('com.oracle.truffle.r.test.library.fastr.TestJavaInterop$TestClass'); t <- .fastr.interop.new(tc); t$fieldStaticStringObject } [1] "a string" diff --git a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/library/fastr/TestJavaInterop.java b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/library/fastr/TestJavaInterop.java index 22d14b31b44934768f4dcc9d5283193f23c15c02..2a7bbe8986b96edd567cfa875e09d144e1235771 100644 --- a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/library/fastr/TestJavaInterop.java +++ b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/library/fastr/TestJavaInterop.java @@ -126,6 +126,19 @@ public class TestJavaInterop extends TestBase { assertEvalFastR("tc <- .fastr.java.class('" + TestNullClass.class.getName() + "'); t <- .fastr.interop.new(tc, NULL); class(t)", "'" + RType.TruffleObject.getName() + "'"); } + @Test + public void testCombine() { + assertEvalFastR("class(c(.fastr.interop.toByte(123)))", "'interopt.byte'"); + assertEvalFastR("class(c(.fastr.interop.toByte(123), .fastr.interop.toByte(234)))", "'list'"); + assertEvalFastR("class(c(.fastr.interop.toByte(123), 1))", "'list'"); + assertEvalFastR("class(c(1, .fastr.interop.toByte(123)))", "'list'"); + + assertEvalFastR("tc <- .fastr.java.class('" + TEST_CLASS + "'); t <- .fastr.interop.new(tc); class(c(t))", "'truffle.object'"); + assertEvalFastR("tc <- .fastr.java.class('" + TEST_CLASS + "'); t <- .fastr.interop.new(tc); t1 <- .fastr.interop.new(tc); class(c(t, t1))", "'list'"); + assertEvalFastR("tc <- .fastr.java.class('" + TEST_CLASS + "'); t <- .fastr.interop.new(tc); class(c(1, t))", "'list'"); + assertEvalFastR("tc <- .fastr.java.class('" + TEST_CLASS + "'); t <- .fastr.interop.new(tc); class(c(t, 1))", "'list'"); + } + @Test public void testFields() throws IllegalArgumentException, IllegalAccessException { TestClass t = new TestClass();