From 03da5bf3837f5b9ec4daa7619cafef202f3e5f1c Mon Sep 17 00:00:00 2001 From: Florian Angerer <florian.angerer@oracle.com> Date: Mon, 26 Jun 2017 16:43:35 +0200 Subject: [PATCH] Removed special treatment for RNull for interop and disabled corresponding test. --- .../truffle/r/runtime/interop/R2Foreign.java | 11 +---------- .../r/test/library/fastr/TestJavaInterop.java | 17 +++++++++-------- 2 files changed, 10 insertions(+), 18 deletions(-) diff --git a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/interop/R2Foreign.java b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/interop/R2Foreign.java index 044a6e17d9..84139962e0 100644 --- a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/interop/R2Foreign.java +++ b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/interop/R2Foreign.java @@ -24,15 +24,12 @@ package com.oracle.truffle.r.runtime.interop; import com.oracle.truffle.api.dsl.Fallback; import com.oracle.truffle.api.dsl.Specialization; -import com.oracle.truffle.api.interop.TruffleObject; -import com.oracle.truffle.api.interop.java.JavaInterop; import com.oracle.truffle.r.runtime.RRuntime; import com.oracle.truffle.r.runtime.data.RInteropScalar.RInteropByte; import com.oracle.truffle.r.runtime.data.RInteropScalar.RInteropChar; import com.oracle.truffle.r.runtime.data.RInteropScalar.RInteropFloat; import com.oracle.truffle.r.runtime.data.RInteropScalar.RInteropLong; import com.oracle.truffle.r.runtime.data.RInteropScalar.RInteropShort; -import com.oracle.truffle.r.runtime.data.RNull; import com.oracle.truffle.r.runtime.data.RRaw; import com.oracle.truffle.r.runtime.data.model.RAbstractDoubleVector; import com.oracle.truffle.r.runtime.data.model.RAbstractIntVector; @@ -91,7 +88,7 @@ public abstract class R2Foreign extends RBaseNode { } @Specialization(guards = "vec.getLength() == 1") - public String doStrignVector(RAbstractStringVector vec) { + public String doStringVector(RAbstractStringVector vec) { return vec.getDataAt(0); } @@ -120,12 +117,6 @@ public abstract class R2Foreign extends RBaseNode { return obj.getValue(); } - @Specialization - public TruffleObject doNull(@SuppressWarnings("unused") RNull obj) { - // TODO this is java interop specific - return JavaInterop.asTruffleObject(null); - } - @Fallback public static Object doObject(Object obj) { return obj; 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 1254ab8c5d..6ac5634afd 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 @@ -22,7 +22,6 @@ */ package com.oracle.truffle.r.test.library.fastr; -import com.oracle.truffle.r.nodes.builtin.base.printer.DoubleVectorPrinter; import java.lang.reflect.Array; import java.lang.reflect.Field; import java.lang.reflect.InvocationTargetException; @@ -38,6 +37,7 @@ import org.junit.Assert; import org.junit.Before; import org.junit.Test; +import com.oracle.truffle.r.nodes.builtin.base.printer.DoubleVectorPrinter; import com.oracle.truffle.r.nodes.builtin.fastr.FastRInterop; import com.oracle.truffle.r.runtime.RType; import com.oracle.truffle.r.test.TestBase; @@ -265,7 +265,7 @@ public class TestJavaInterop extends TestBase { assertEvalFastR("tc <- new.java.class('" + Long.class.getName() + "'); t <- new.external(tc, as.external.long(1)); t", "1"); assertEvalFastR("tc <- new.java.class('" + Short.class.getName() + "'); t <- new.external(tc, as.external.short(1)); t", "1"); assertEvalFastR("tc <- new.java.class('" + String.class.getName() + "'); t <- new.external(tc, 'abc'); t", "'abc'"); - assertEvalFastR("tc <- new.java.class('" + TestNullClass.class.getName() + "'); t <- new.external(tc, NULL); class(t)", "'" + RType.TruffleObject.getName() + "'"); + assertEvalFastR(Ignored.Unknown, "tc <- new.java.class('" + TestNullClass.class.getName() + "'); t <- new.external(tc, NULL); class(t)", "'" + RType.TruffleObject.getName() + "'"); } @Test @@ -647,7 +647,7 @@ public class TestJavaInterop extends TestBase { } @Test - public void testIf() throws IllegalArgumentException, IllegalAccessException { + public void testIf() throws IllegalArgumentException { TestClass t = new TestClass(); assertEvalFastR(CREATE_TRUFFLE_OBJECT + "if(to$fieldBoolean) print('OK')", "if(T) print('OK')"); @@ -671,7 +671,7 @@ public class TestJavaInterop extends TestBase { } @Test - public void testWhile() throws IllegalArgumentException, IllegalAccessException { + public void testWhile() throws IllegalArgumentException { TestClass t = new TestClass(); assertEvalFastR(CREATE_TRUFFLE_OBJECT + "while(to$fieldBoolean) {print('OK'); break;}", "while(T) {print('OK'); break;}"); @@ -782,10 +782,11 @@ public class TestJavaInterop extends TestBase { StringBuilder sb = new StringBuilder(); sb.append(asXXX); sb.append("("); + Object val = o; if (asXXX.equals("as.character") && (o instanceof Double || o instanceof Float)) { - o = DoubleVectorPrinter.encodeReal(((Number) o).doubleValue()); + val = DoubleVectorPrinter.encodeReal(((Number) o).doubleValue()); } - sb.append(getRValue(o)); + sb.append(getRValue(val)); sb.append(')'); return sb.toString(); } @@ -802,7 +803,7 @@ public class TestJavaInterop extends TestBase { return sb.toString(); } - private String getBooleanPrefix(Object value, int i) { + private static String getBooleanPrefix(Object value, int i) { if (value.getClass().getComponentType() == Boolean.TYPE && (boolean) Array.get(value, i)) { return " "; } @@ -813,7 +814,7 @@ public class TestJavaInterop extends TestBase { return ""; } - private String toArrayClassName(String className, int dims) { + private static String toArrayClassName(String className, int dims) { StringBuilder sb = new StringBuilder(); sb.append("'"); for (int i = 0; i < dims; i++) { -- GitLab