diff --git a/com.oracle.truffle.r.engine/src/com/oracle/truffle/r/engine/interop/ListMR.java b/com.oracle.truffle.r.engine/src/com/oracle/truffle/r/engine/interop/ListMR.java index 8423b27c8ba30c714d015eb667d5e52e9449c84b..a92ef70a060f35018a545feefca0a9bc001eadba 100644 --- a/com.oracle.truffle.r.engine/src/com/oracle/truffle/r/engine/interop/ListMR.java +++ b/com.oracle.truffle.r.engine/src/com/oracle/truffle/r/engine/interop/ListMR.java @@ -45,12 +45,12 @@ import com.oracle.truffle.r.nodes.access.vector.ReplaceVectorNode; import com.oracle.truffle.r.nodes.attributes.SpecialAttributesFunctions.GetNamesAttributeNode; import com.oracle.truffle.r.nodes.control.RLengthNode; import com.oracle.truffle.r.runtime.data.NativeDataAccess; +import com.oracle.truffle.r.runtime.data.RDataFactory; import com.oracle.truffle.r.runtime.data.RExpression; import com.oracle.truffle.r.runtime.data.RFunction; import com.oracle.truffle.r.runtime.data.RList; import com.oracle.truffle.r.runtime.data.RLogical; import com.oracle.truffle.r.runtime.data.RMissing; -import com.oracle.truffle.r.runtime.data.RNull; import com.oracle.truffle.r.runtime.data.RPairList; import com.oracle.truffle.r.runtime.data.RStringVector; import com.oracle.truffle.r.runtime.data.RTruffleObject; @@ -533,6 +533,6 @@ public class ListMR { private static Object listKeys(TruffleObject receiver, GetNamesAttributeNode getNamesNode) { RStringVector names = getNamesNode.getNames(receiver); - return names != null ? names : RNull.instance; + return names != null ? names : RDataFactory.createEmptyStringVector(); } } diff --git a/com.oracle.truffle.r.engine/src/com/oracle/truffle/r/engine/interop/RAbstractVectorAccessFactory.java b/com.oracle.truffle.r.engine/src/com/oracle/truffle/r/engine/interop/RAbstractVectorAccessFactory.java index 0ac20c8270a386863346dc8d85ee4bf2930bd124..1295fc5a51a022819b673d3684cd6778d86c44ce 100644 --- a/com.oracle.truffle.r.engine/src/com/oracle/truffle/r/engine/interop/RAbstractVectorAccessFactory.java +++ b/com.oracle.truffle.r.engine/src/com/oracle/truffle/r/engine/interop/RAbstractVectorAccessFactory.java @@ -32,7 +32,7 @@ import com.oracle.truffle.api.dsl.Fallback; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.interop.ForeignAccess; -import com.oracle.truffle.api.interop.ForeignAccess.Factory26; +import com.oracle.truffle.api.interop.ForeignAccess.StandardFactory; import com.oracle.truffle.api.interop.KeyInfo; import com.oracle.truffle.api.interop.Message; import com.oracle.truffle.api.interop.TruffleObject; @@ -71,7 +71,7 @@ abstract class InteropRootNode extends RootNode { } } -public final class RAbstractVectorAccessFactory implements Factory26 { +public final class RAbstractVectorAccessFactory implements StandardFactory { abstract static class VectorReadImplNode extends InteropRootNode { @@ -245,6 +245,16 @@ public final class RAbstractVectorAccessFactory implements Factory26 { }); } + @Override + public CallTarget accessIsInstantiable() { + return Truffle.getRuntime().createCallTarget(new InteropRootNode() { + @Override + public Object execute(VirtualFrame frame) { + return false; + } + }); + } + @Override public CallTarget accessIsBoxed() { return Truffle.getRuntime().createCallTarget(new InteropRootNode() { @@ -266,6 +276,16 @@ public final class RAbstractVectorAccessFactory implements Factory26 { }); } + @Override + public CallTarget accessHasKeys() { + return Truffle.getRuntime().createCallTarget(new InteropRootNode() { + @Override + public Object execute(VirtualFrame frame) { + return false; + } + }); + } + @Override public CallTarget accessGetSize() { return Truffle.getRuntime().createCallTarget(new InteropRootNode() { diff --git a/com.oracle.truffle.r.engine/src/com/oracle/truffle/r/engine/interop/RComplexMR.java b/com.oracle.truffle.r.engine/src/com/oracle/truffle/r/engine/interop/RComplexMR.java new file mode 100644 index 0000000000000000000000000000000000000000..c8b3889e564223d91c035a134e1df998af049421 --- /dev/null +++ b/com.oracle.truffle.r.engine/src/com/oracle/truffle/r/engine/interop/RComplexMR.java @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.truffle.r.engine.interop; + +import com.oracle.truffle.api.interop.CanResolve; +import com.oracle.truffle.api.interop.MessageResolution; +import com.oracle.truffle.api.interop.Resolve; +import com.oracle.truffle.api.interop.TruffleObject; +import com.oracle.truffle.api.nodes.Node; +import com.oracle.truffle.r.runtime.data.RComplex; + +@MessageResolution(receiverType = RComplex.class) +public class RComplexMR { + + @Resolve(message = "IS_BOXED") + public abstract static class RComplexIsBoxedNode extends Node { + protected Object access(@SuppressWarnings("unused") RComplex receiver) { + return false; + } + } + + @Resolve(message = "HAS_SIZE") + public abstract static class RComplexHasSizeNode extends Node { + protected Object access(@SuppressWarnings("unused") RComplex receiver) { + return false; + } + } + + @Resolve(message = "KEY_INFO") + public abstract static class RComplexKeyInfoNode extends Node { + protected Object access(@SuppressWarnings("unused") RComplex receiver, @SuppressWarnings("unused") Object identifier) { + return 0; + } + } + + @CanResolve + public abstract static class RComplexCheck extends Node { + + protected static boolean test(TruffleObject receiver) { + return receiver instanceof RComplex; + } + } +} diff --git a/com.oracle.truffle.r.engine/src/com/oracle/truffle/r/engine/interop/RDoubleMR.java b/com.oracle.truffle.r.engine/src/com/oracle/truffle/r/engine/interop/RDoubleMR.java index 06c424cc1f2b1fb4badd4c012be9d491fd8dbe01..e9edcffe324ce8b73b163522cf25c7c14a0e8c49 100644 --- a/com.oracle.truffle.r.engine/src/com/oracle/truffle/r/engine/interop/RDoubleMR.java +++ b/com.oracle.truffle.r.engine/src/com/oracle/truffle/r/engine/interop/RDoubleMR.java @@ -47,7 +47,7 @@ public class RDoubleMR { @Resolve(message = "KEY_INFO") public abstract static class RDoubleKeyInfoNode extends Node { - protected Object access(@SuppressWarnings("unused") TruffleObject receiver, @SuppressWarnings("unused") Object identifier) { + protected Object access(@SuppressWarnings("unused") RDouble receiver, @SuppressWarnings("unused") Object identifier) { return 0; } } diff --git a/com.oracle.truffle.r.engine/src/com/oracle/truffle/r/engine/interop/RForeignAccessFactoryImpl.java b/com.oracle.truffle.r.engine/src/com/oracle/truffle/r/engine/interop/RForeignAccessFactoryImpl.java index 7df762b0be5048cb03dbdde884295d98e72b0b55..c2f1364f754fa8794a43cbe4f902798c859530af 100644 --- a/com.oracle.truffle.r.engine/src/com/oracle/truffle/r/engine/interop/RForeignAccessFactoryImpl.java +++ b/com.oracle.truffle.r.engine/src/com/oracle/truffle/r/engine/interop/RForeignAccessFactoryImpl.java @@ -31,6 +31,7 @@ import com.oracle.truffle.r.runtime.conn.RConnection; import com.oracle.truffle.r.runtime.context.RContext; import com.oracle.truffle.r.runtime.context.RForeignAccessFactory; import com.oracle.truffle.r.runtime.data.RArgsValuesAndNames; +import com.oracle.truffle.r.runtime.data.RComplex; import com.oracle.truffle.r.runtime.data.RDouble; import com.oracle.truffle.r.runtime.data.REmpty; import com.oracle.truffle.r.runtime.data.RExpression; @@ -44,6 +45,7 @@ import com.oracle.truffle.r.runtime.data.RMissing; import com.oracle.truffle.r.runtime.data.RNull; import com.oracle.truffle.r.runtime.data.RPairList; import com.oracle.truffle.r.runtime.data.RPromise; +import com.oracle.truffle.r.runtime.data.RRaw; import com.oracle.truffle.r.runtime.data.RS4Object; import com.oracle.truffle.r.runtime.data.RSymbol; import com.oracle.truffle.r.runtime.data.RTruffleObject; @@ -92,6 +94,10 @@ public final class RForeignAccessFactoryImpl implements RForeignAccessFactory { return RIntegerMRForeign.ACCESS; } else if (obj instanceof RDouble) { return RDoubleMRForeign.ACCESS; + } else if (obj instanceof RComplex) { + return RComplexMRForeign.ACCESS; + } else if (obj instanceof RRaw) { + return RRawMRForeign.ACCESS; } else if (obj instanceof RConnection) { return RConnectionMRForeign.ACCESS; } else if (obj instanceof RContext) { diff --git a/com.oracle.truffle.r.engine/src/com/oracle/truffle/r/engine/interop/RIntegerMR.java b/com.oracle.truffle.r.engine/src/com/oracle/truffle/r/engine/interop/RIntegerMR.java index 923a8cd7b3954a100b060bb421f1138d038c230f..878082dad85cee941eb35e29354c77fb3785e636 100644 --- a/com.oracle.truffle.r.engine/src/com/oracle/truffle/r/engine/interop/RIntegerMR.java +++ b/com.oracle.truffle.r.engine/src/com/oracle/truffle/r/engine/interop/RIntegerMR.java @@ -40,7 +40,7 @@ public class RIntegerMR { @Resolve(message = "KEY_INFO") public abstract static class RIntegerKeyInfoNode extends Node { - protected Object access(@SuppressWarnings("unused") TruffleObject receiver, @SuppressWarnings("unused") Object identifier) { + protected Object access(@SuppressWarnings("unused") RInteger receiver, @SuppressWarnings("unused") Object identifier) { return 0; } } diff --git a/com.oracle.truffle.r.engine/src/com/oracle/truffle/r/engine/interop/RRawMR.java b/com.oracle.truffle.r.engine/src/com/oracle/truffle/r/engine/interop/RRawMR.java new file mode 100644 index 0000000000000000000000000000000000000000..80a7ab5992104117de1ac253f165b2f5c9e2e79c --- /dev/null +++ b/com.oracle.truffle.r.engine/src/com/oracle/truffle/r/engine/interop/RRawMR.java @@ -0,0 +1,70 @@ +/* + * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.truffle.r.engine.interop; + +import com.oracle.truffle.api.interop.CanResolve; +import com.oracle.truffle.api.interop.MessageResolution; +import com.oracle.truffle.api.interop.Resolve; +import com.oracle.truffle.api.interop.TruffleObject; +import com.oracle.truffle.api.nodes.Node; +import com.oracle.truffle.r.runtime.data.RRaw; + +@MessageResolution(receiverType = RRaw.class) +public class RRawMR { + + @Resolve(message = "IS_BOXED") + public abstract static class RRawIsBoxedNode extends Node { + protected Object access(@SuppressWarnings("unused") RRaw receiver) { + return true; + } + } + + @Resolve(message = "UNBOX") + public abstract static class RRawUnboxNode extends Node { + protected Object access(@SuppressWarnings("unused") RRaw receiver) { + return receiver.getValue(); + } + } + + @Resolve(message = "HAS_SIZE") + public abstract static class RRawHasSizeNode extends Node { + protected Object access(@SuppressWarnings("unused") RRaw receiver) { + return false; + } + } + + @Resolve(message = "KEY_INFO") + public abstract static class RRawKeyInfoNode extends Node { + protected Object access(@SuppressWarnings("unused") RRaw receiver, @SuppressWarnings("unused") Object identifier) { + return 0; + } + } + + @CanResolve + public abstract static class RComplexCheck extends Node { + + protected static boolean test(TruffleObject receiver) { + return receiver instanceof RRaw; + } + } +} diff --git a/com.oracle.truffle.r.ffi.impl/src/com/oracle/truffle/r/ffi/impl/upcalls/AbstractDowncallForeign.java b/com.oracle.truffle.r.ffi.impl/src/com/oracle/truffle/r/ffi/impl/upcalls/AbstractDowncallForeign.java index dcb23038b56cc7afc6ea9a8f5b14103efcbdcd2c..ad716f2641164799ce5d1c64633187ab1b853bb7 100644 --- a/com.oracle.truffle.r.ffi.impl/src/com/oracle/truffle/r/ffi/impl/upcalls/AbstractDowncallForeign.java +++ b/com.oracle.truffle.r.ffi.impl/src/com/oracle/truffle/r/ffi/impl/upcalls/AbstractDowncallForeign.java @@ -25,11 +25,11 @@ package com.oracle.truffle.r.ffi.impl.upcalls; import com.oracle.truffle.api.CallTarget; import com.oracle.truffle.api.Truffle; import com.oracle.truffle.api.interop.ForeignAccess.Factory; -import com.oracle.truffle.api.interop.ForeignAccess.Factory26; +import com.oracle.truffle.api.interop.ForeignAccess.StandardFactory; import com.oracle.truffle.api.interop.Message; import com.oracle.truffle.api.nodes.RootNode; -public abstract class AbstractDowncallForeign implements Factory26, Factory { +public abstract class AbstractDowncallForeign implements StandardFactory, Factory { @Override public CallTarget accessIsNull() { return Truffle.getRuntime().createCallTarget(RootNode.createConstantNode(false)); diff --git a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/engine/interop/AbstractMRTest.java b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/engine/interop/AbstractMRTest.java index c44cfb173ad9a76f1d0dcf4434f580da03e22822..d3060412fb3488fd7936308f9df4915d800cbe7f 100644 --- a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/engine/interop/AbstractMRTest.java +++ b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/engine/interop/AbstractMRTest.java @@ -22,7 +22,7 @@ */ package com.oracle.truffle.r.test.engine.interop; -import static org.junit.Assert.assertEquals; +import com.oracle.truffle.api.interop.ArityException; import static org.junit.Assert.assertTrue; import java.util.HashSet; @@ -37,8 +37,14 @@ import com.oracle.truffle.api.interop.ForeignAccess; import com.oracle.truffle.api.interop.InteropException; import com.oracle.truffle.api.interop.Message; import com.oracle.truffle.api.interop.TruffleObject; +import com.oracle.truffle.api.interop.UnknownIdentifierException; import com.oracle.truffle.api.interop.UnsupportedMessageException; +import com.oracle.truffle.api.interop.UnsupportedTypeException; import com.oracle.truffle.api.vm.PolyglotEngine; +import com.oracle.truffle.r.ffi.impl.interop.NativePointer; +import com.oracle.truffle.r.runtime.data.RNull; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; public abstract class AbstractMRTest { @@ -67,40 +73,29 @@ public abstract class AbstractMRTest { */ protected abstract TruffleObject createEmptyTruffleObject() throws Exception; - protected String[] getKeys() { - return null; + /** + * + * @param obj + * @return array of keys or <code>null</code> if KEYS message not supported + */ + protected String[] getKeys(TruffleObject obj) { + throw new UnsupportedOperationException("override if HAS_KEYS returns true"); } protected boolean isNull(@SuppressWarnings("unused") TruffleObject obj) { return false; } - protected boolean isExecutable(@SuppressWarnings("unused") TruffleObject obj) { - return false; - } - - protected boolean isPointer(@SuppressWarnings("unused") TruffleObject obj) { - return true; - } - - protected boolean isBoxed(@SuppressWarnings("unused") TruffleObject obj) { - return false; - } - - protected boolean hasSize(@SuppressWarnings("unused") TruffleObject obj) { - return false; - } - protected boolean testToNative(@SuppressWarnings("unused") TruffleObject obj) { return true; } protected int getSize(@SuppressWarnings("unused") TruffleObject obj) { - throw new UnsupportedOperationException("override if hasSize returns true"); + throw new UnsupportedOperationException("override if HAS_SIZE returns true"); } protected Object getUnboxed(@SuppressWarnings("unused") TruffleObject obj) { - throw new UnsupportedOperationException("override if isBoxed returns true"); + throw new UnsupportedOperationException("override if IS_BOXED returns true"); } @Test @@ -111,16 +106,44 @@ public abstract class AbstractMRTest { } @Test - public void testIsExecutable() throws Exception { + public void testExecutable() throws Exception { for (TruffleObject obj : createTruffleObjects()) { - assertEquals(isExecutable(obj), ForeignAccess.sendIsExecutable(Message.IS_EXECUTABLE.createNode(), obj)); + try { + // TODO if the need appears, also provide for args for execute + ForeignAccess.sendExecute(Message.createExecute(0).createNode(), obj); + assertEquals(obj.getClass().getSimpleName() + " " + obj + " IS_EXECUTABLE", true, ForeignAccess.sendIsExecutable(Message.IS_EXECUTABLE.createNode(), obj)); + } catch (UnsupportedTypeException | ArityException e) { + throw e; + } catch (UnsupportedMessageException e) { + assertEquals(obj.getClass().getSimpleName() + " " + obj + " IS_EXECUTABLE", false, ForeignAccess.sendIsExecutable(Message.IS_EXECUTABLE.createNode(), obj)); + } } } @Test - public void testIsPointer() throws Exception { + public void testInstantiable() throws Exception { for (TruffleObject obj : createTruffleObjects()) { - assertEquals(obj.getClass().getSimpleName(), isPointer(obj), ForeignAccess.sendIsPointer(Message.IS_POINTER.createNode(), obj)); + try { + // TODO if the need appears, also provide for args for new + ForeignAccess.sendNew(Message.createNew(0).createNode(), obj); + assertEquals(obj.getClass().getSimpleName() + " " + obj + " IS_INSTANTIABLE", true, ForeignAccess.sendIsInstantiable(Message.IS_INSTANTIABLE.createNode(), obj)); + } catch (UnsupportedTypeException | ArityException e) { + throw e; + } catch (UnsupportedMessageException e) { + assertEquals(obj.getClass().getSimpleName() + " " + obj + " IS_INSTANTIABLE", false, ForeignAccess.sendIsInstantiable(Message.IS_INSTANTIABLE.createNode(), obj)); + } + } + } + + @Test + public void testAsNativePointer() throws Exception { + for (TruffleObject obj : createTruffleObjects()) { + try { + assertNotNull(obj.getClass().getSimpleName(), ForeignAccess.sendToNative(Message.AS_POINTER.createNode(), obj)); + assertEquals(obj.getClass().getSimpleName() + " " + obj + " IS_POINTER", true, ForeignAccess.sendIsPointer(Message.IS_POINTER.createNode(), obj)); + } catch (UnsupportedMessageException e) { + assertEquals(obj.getClass().getSimpleName() + " " + obj + " IS_POINTER", false, ForeignAccess.sendIsPointer(Message.IS_POINTER.createNode(), obj)); + } } } @@ -131,8 +154,12 @@ public abstract class AbstractMRTest { continue; } try { - assertTrue(obj.getClass().getSimpleName(), ForeignAccess.sendToNative(Message.TO_NATIVE.createNode(), obj) == obj); - } catch (UnsupportedMessageException unsupportedMessageException) { + if (obj == RNull.instance) { + assertTrue(obj.getClass().getSimpleName(), ForeignAccess.sendToNative(Message.TO_NATIVE.createNode(), obj) == NativePointer.NULL_NATIVEPOINTER); + } else { + assertTrue(obj.getClass().getSimpleName(), ForeignAccess.sendToNative(Message.TO_NATIVE.createNode(), obj) == obj); + } + } catch (UnsupportedMessageException e) { } } } @@ -140,38 +167,62 @@ public abstract class AbstractMRTest { @Test public void testSize() throws Exception { for (TruffleObject obj : createTruffleObjects()) { - boolean hasSize = ForeignAccess.sendHasSize(Message.HAS_SIZE.createNode(), obj); - assertEquals("" + obj.getClass() + " " + obj, hasSize(obj), hasSize); - if (hasSize) { - assertEquals(getSize(obj), ForeignAccess.sendGetSize(Message.GET_SIZE.createNode(), obj)); - } else { - assertInteropException(() -> ForeignAccess.sendGetSize(Message.GET_SIZE.createNode(), obj), UnsupportedMessageException.class); - } + testSize(obj); + } + TruffleObject empty = createEmptyTruffleObject(); + if (empty != null) { + testSize(empty); + } + } + + private void testSize(TruffleObject obj) { + try { + Object size = ForeignAccess.sendGetSize(Message.GET_SIZE.createNode(), obj); + assertEquals(getSize(obj), size); + assertEquals(obj.getClass().getSimpleName() + " " + obj + " HAS_SIZE", true, ForeignAccess.sendHasSize(Message.HAS_SIZE.createNode(), obj)); + } catch (UnsupportedMessageException e) { + assertEquals(obj.getClass().getSimpleName() + " " + obj + " HAS_SIZE", false, ForeignAccess.sendHasSize(Message.HAS_SIZE.createNode(), obj)); } } @Test public void testBoxed() throws Exception { for (TruffleObject obj : createTruffleObjects()) { - boolean isBoxed = ForeignAccess.sendIsBoxed(Message.IS_BOXED.createNode(), obj); - assertEquals(isBoxed(obj), isBoxed); - if (isBoxed) { - assertEquals(getUnboxed(obj), ForeignAccess.sendUnbox(Message.UNBOX.createNode(), obj)); - } else { - assertInteropException(() -> ForeignAccess.sendUnbox(Message.UNBOX.createNode(), obj), UnsupportedMessageException.class); - } + testUnboxed(obj); + } + TruffleObject empty = createEmptyTruffleObject(); + if (empty != null) { + testUnboxed(empty); + } + } + + private void testUnboxed(TruffleObject obj) { + try { + Object unboxed = ForeignAccess.sendUnbox(Message.UNBOX.createNode(), obj); + assertEquals(getUnboxed(obj), unboxed); + assertEquals(obj.getClass().getSimpleName() + " " + obj + " IS_BOXED", true, ForeignAccess.sendIsBoxed(Message.IS_BOXED.createNode(), obj)); + } catch (UnsupportedMessageException e) { + assertEquals(obj.getClass().getSimpleName() + " " + obj + " IS_BOXED", false, ForeignAccess.sendIsBoxed(Message.IS_BOXED.createNode(), obj)); } } @Test public void testKeys() throws Exception { - String[] keys = getKeys(); - if (keys == null) { - return; - } for (TruffleObject obj : createTruffleObjects()) { + testKeys(obj); + } + TruffleObject empty = createEmptyTruffleObject(); + if (empty != null) { + testKeys(empty); + } + } + + private void testKeys(TruffleObject obj) throws UnknownIdentifierException, UnsupportedMessageException { + try { TruffleObject keysObj = ForeignAccess.sendKeys(Message.KEYS.createNode(), obj); + int size = (int) ForeignAccess.sendGetSize(Message.GET_SIZE.createNode(), keysObj); + String[] keys = getKeys(obj); assertEquals(keys.length, size); Set<Object> set = new HashSet<>(); @@ -181,31 +232,9 @@ public abstract class AbstractMRTest { for (String key : keys) { assertTrue(set.contains(key)); } - } - } - - @Test - public void testEmpty() throws Exception { - - TruffleObject obj = createEmptyTruffleObject(); - if (obj != null) { - if (hasSize(obj)) { - int size = (int) ForeignAccess.sendGetSize(Message.GET_SIZE.createNode(), obj); - assertEquals(0, size); - } - - TruffleObject keys = null; - try { - keys = ForeignAccess.sendKeys(Message.KEYS.createNode(), obj); - } catch (UnsupportedMessageException ex) { - } - if (keys != null) { - boolean keysHasSize = ForeignAccess.sendHasSize(Message.HAS_SIZE.createNode(), keys); - if (keysHasSize) { - int keysSize = (int) ForeignAccess.sendGetSize(Message.GET_SIZE.createNode(), keys); - assertEquals(0, keysSize); - } - } + assertEquals(obj.getClass().getSimpleName() + " " + obj + " HAS_KEYS", true, ForeignAccess.sendHasKeys(Message.HAS_KEYS.createNode(), obj)); + } catch (UnsupportedMessageException e) { + assertEquals(obj.getClass().getSimpleName() + " " + obj + " HAS_KEYS", false, ForeignAccess.sendHasKeys(Message.HAS_KEYS.createNode(), obj)); } } diff --git a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/engine/interop/ActiveBindingMRTest.java b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/engine/interop/ActiveBindingMRTest.java index fbeaa5c52e829089c11176913001d80cf5465384..67876824be7055c2dbdb90e86f4c6fd95148662d 100644 --- a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/engine/interop/ActiveBindingMRTest.java +++ b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/engine/interop/ActiveBindingMRTest.java @@ -28,12 +28,14 @@ import com.oracle.truffle.api.vm.PolyglotEngine; import com.oracle.truffle.r.runtime.RType; import com.oracle.truffle.r.runtime.data.RFunction; import com.oracle.truffle.r.runtime.env.frame.ActiveBinding; +import org.junit.Test; public class ActiveBindingMRTest extends AbstractMRTest { + @Test @Override - protected boolean isBoxed(TruffleObject obj) { - return true; + public void testIsNull() throws Exception { + super.testIsNull(); // force inherited tests from AbstractMRTest } @Override diff --git a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/engine/interop/ListMRTest.java b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/engine/interop/ListMRTest.java index 2105850c641c044dc97d6b264dc5808f2aa54772..4830226aa9939392d3286e8b2cf2c18affa1f64f 100644 --- a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/engine/interop/ListMRTest.java +++ b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/engine/interop/ListMRTest.java @@ -159,8 +159,11 @@ public class ListMRTest extends AbstractMRTest { } @Override - protected String[] getKeys() { - return new String[]{"i", "d", "b", "fn", "n", ""}; + protected String[] getKeys(TruffleObject obj) { + if (((RAbstractContainer) obj).getLength() > 0) { + return new String[]{"i", "d", "b", "fn", "n", ""}; + } + return new String[]{}; } @Override @@ -174,11 +177,6 @@ public class ListMRTest extends AbstractMRTest { return create("list", ""); } - @Override - protected boolean hasSize(TruffleObject arg0) { - return true; - } - @Override protected int getSize(TruffleObject obj) { return obj instanceof RList ? ((RList) obj).getLength() : ((RPairList) obj).getLength(); diff --git a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/engine/interop/RArgsValuesAndNamesMRTest.java b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/engine/interop/RArgsValuesAndNamesMRTest.java index 25e3ce0587e89f50085131b797e42aa94f99992f..7c81adcfafdda40bcb94ce911414375c343f9df9 100644 --- a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/engine/interop/RArgsValuesAndNamesMRTest.java +++ b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/engine/interop/RArgsValuesAndNamesMRTest.java @@ -140,8 +140,12 @@ public class RArgsValuesAndNamesMRTest extends AbstractMRTest { } @Override - protected String[] getKeys() { - return names; + protected String[] getKeys(TruffleObject obj) { + if (obj == RArgsValuesAndNames.EMPTY) { + return new String[]{}; + } else { + return names; + } } @Override @@ -149,11 +153,6 @@ public class RArgsValuesAndNamesMRTest extends AbstractMRTest { return RArgsValuesAndNames.EMPTY; } - @Override - protected boolean hasSize(TruffleObject obj) { - return true; - } - @Override protected int getSize(TruffleObject obj) { return ((RArgsValuesAndNames) obj).getLength(); diff --git a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/engine/interop/RComplexMRTest.java b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/engine/interop/RComplexMRTest.java new file mode 100644 index 0000000000000000000000000000000000000000..6b7b133f8a895d8deac06dd8c2a875d418ff57f3 --- /dev/null +++ b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/engine/interop/RComplexMRTest.java @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.truffle.r.test.engine.interop; + +import com.oracle.truffle.api.interop.TruffleObject; +import com.oracle.truffle.r.runtime.data.RComplex; +import org.junit.Test; + +public class RComplexMRTest extends AbstractMRTest { + + @Override + protected TruffleObject[] createTruffleObjects() throws Exception { + return new TruffleObject[]{RComplex.valueOf(1, 1)}; + } + + @Test + @Override + public void testIsNull() throws Exception { + super.testIsNull(); // force inherited tests from AbstractMRTest + } + + @Override + protected TruffleObject createEmptyTruffleObject() throws Exception { + return null; + } +} diff --git a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/engine/interop/RDoubleMRTest.java b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/engine/interop/RDoubleMRTest.java index 887f384fbb2b4b1c578934ca3717de357a6bf08f..9972f65126775f151e5fc1a9d600debb77fc4761 100644 --- a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/engine/interop/RDoubleMRTest.java +++ b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/engine/interop/RDoubleMRTest.java @@ -24,17 +24,19 @@ package com.oracle.truffle.r.test.engine.interop; import com.oracle.truffle.api.interop.TruffleObject; import com.oracle.truffle.r.runtime.data.RDouble; +import org.junit.Test; public class RDoubleMRTest extends AbstractMRTest { + @Test @Override - protected TruffleObject[] createTruffleObjects() throws Exception { - return new TruffleObject[]{RDouble.valueOf(1.1)}; + public void testIsNull() throws Exception { + super.testIsNull(); // force inherited tests from AbstractMRTest } @Override - protected boolean isBoxed(TruffleObject obj) { - return true; + protected TruffleObject[] createTruffleObjects() throws Exception { + return new TruffleObject[]{RDouble.valueOf(1.1)}; } @Override diff --git a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/engine/interop/REmptyMRTest.java b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/engine/interop/REmptyMRTest.java index 1ec6184661511c474fd2d3944a65e3e2254971c3..63cf4298fc3bfbd1029e1d829f61b839119f0f9b 100644 --- a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/engine/interop/REmptyMRTest.java +++ b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/engine/interop/REmptyMRTest.java @@ -24,9 +24,16 @@ package com.oracle.truffle.r.test.engine.interop; import com.oracle.truffle.api.interop.TruffleObject; import com.oracle.truffle.r.runtime.data.REmpty; +import org.junit.Test; public class REmptyMRTest extends AbstractMRTest { + @Test + @Override + public void testIsNull() throws Exception { + super.testIsNull(); // force inherited tests from AbstractMRTest + } + @Override protected TruffleObject[] createTruffleObjects() throws Exception { return new TruffleObject[]{REmpty.instance}; diff --git a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/engine/interop/REnvironmentMRTest.java b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/engine/interop/REnvironmentMRTest.java index 60ef430454923816291d01c501fe5e5bfed195d8..f84dd63dec2e8211d21b86bb0a2817729b9472fb 100644 --- a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/engine/interop/REnvironmentMRTest.java +++ b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/engine/interop/REnvironmentMRTest.java @@ -36,6 +36,7 @@ import com.oracle.truffle.api.interop.UnknownIdentifierException; import com.oracle.truffle.api.interop.UnsupportedMessageException; import com.oracle.truffle.api.interop.java.JavaInterop; import com.oracle.truffle.api.source.Source; +import com.oracle.truffle.r.runtime.data.RDataFactory; import com.oracle.truffle.r.runtime.env.REnvironment; public class REnvironmentMRTest extends AbstractMRTest { @@ -138,13 +139,16 @@ public class REnvironmentMRTest extends AbstractMRTest { } @Override - protected String[] getKeys() { - return new String[]{"s", "i", "d", "b", "fn", "n", "l"}; + protected String[] getKeys(TruffleObject obj) { + if (((REnvironment) obj).getName().equals("R_EmptyEnv")) { + return new String[]{}; + } else { + return new String[]{"s", "i", "d", "b", "fn", "n", "l"}; + } } @Override protected TruffleObject createEmptyTruffleObject() throws Exception { - Source src = Source.newBuilder("new.env()").mimeType("text/x-r").name("test.R").build(); - return engine.eval(src).as(REnvironment.class); + return REnvironment.emptyEnv(); } } diff --git a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/engine/interop/RFunctionMRTest.java b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/engine/interop/RFunctionMRTest.java index 1397ae9de207297a1faf9def422db37185be7b54..86b260ec4b60f5b99cbf1eb37b57114c21aee416 100644 --- a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/engine/interop/RFunctionMRTest.java +++ b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/engine/interop/RFunctionMRTest.java @@ -78,11 +78,6 @@ public class RFunctionMRTest extends AbstractMRTest { return result.as(RFunction.class); } - @Override - protected boolean isExecutable(TruffleObject obj) { - return true; - } - @Override protected TruffleObject createEmptyTruffleObject() throws Exception { return null; diff --git a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/engine/interop/RIntegerMRTest.java b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/engine/interop/RIntegerMRTest.java index b44b1e1505ac661845551f16366558ff23957003..f4792987d064d3f9b796fa83d1834a842946e4d6 100644 --- a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/engine/interop/RIntegerMRTest.java +++ b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/engine/interop/RIntegerMRTest.java @@ -24,17 +24,19 @@ package com.oracle.truffle.r.test.engine.interop; import com.oracle.truffle.api.interop.TruffleObject; import com.oracle.truffle.r.runtime.data.RInteger; +import org.junit.Test; public class RIntegerMRTest extends AbstractMRTest { + @Test @Override - protected TruffleObject[] createTruffleObjects() throws Exception { - return new TruffleObject[]{RInteger.valueOf(123)}; + public void testIsNull() throws Exception { + super.testIsNull(); // force inherited tests from AbstractMRTest } @Override - protected boolean isBoxed(TruffleObject obj) { - return true; + protected TruffleObject[] createTruffleObjects() throws Exception { + return new TruffleObject[]{RInteger.valueOf(123)}; } @Override diff --git a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/engine/interop/RInteropScalarMRTest.java b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/engine/interop/RInteropScalarMRTest.java index 7f4d397cc389a4befc9e5744089326c739c8644b..745c81dee1913eb598ee2d1bd6261407b129254b 100644 --- a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/engine/interop/RInteropScalarMRTest.java +++ b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/engine/interop/RInteropScalarMRTest.java @@ -62,16 +62,6 @@ public class RInteropScalarMRTest extends AbstractMRTest { RInteropScalar.RInteropShort.valueOf(Short.MAX_VALUE)}; } - @Override - protected boolean isBoxed(TruffleObject arg0) { - return true; - } - - @Override - protected boolean isPointer(TruffleObject obj) { - return false; - } - @Override protected Object getUnboxed(TruffleObject obj) { RInteropScalar is = (RInteropScalar) obj; diff --git a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/engine/interop/RLanguageMRTest.java b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/engine/interop/RLanguageMRTest.java index df5d8d6aca9215edb9f4697f71ebd74e37fd753c..592989add2aafc6ece1add6385f496f2ac00f7ae 100644 --- a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/engine/interop/RLanguageMRTest.java +++ b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/engine/interop/RLanguageMRTest.java @@ -105,11 +105,6 @@ public class RLanguageMRTest extends AbstractMRTest { return null; } - @Override - protected boolean hasSize(TruffleObject obj) { - return true; - } - @Override protected int getSize(TruffleObject obj) { return ((RLanguage) obj).getLength(); diff --git a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/engine/interop/RMissingMRTest.java b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/engine/interop/RMissingMRTest.java index c0a39b78a89784dc48f690c0547d928f831a693f..f5ecb1204c078dc8ccd13028a73dabebf1fd1ec5 100644 --- a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/engine/interop/RMissingMRTest.java +++ b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/engine/interop/RMissingMRTest.java @@ -24,9 +24,16 @@ package com.oracle.truffle.r.test.engine.interop; import com.oracle.truffle.api.interop.TruffleObject; import com.oracle.truffle.r.runtime.data.RMissing; +import org.junit.Test; public class RMissingMRTest extends AbstractMRTest { + @Test + @Override + public void testIsNull() throws Exception { + super.testIsNull(); // force inherited tests from AbstractMRTest + } + @Override protected TruffleObject[] createTruffleObjects() throws Exception { return new TruffleObject[]{RMissing.instance}; diff --git a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/engine/interop/RNullMRTest.java b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/engine/interop/RNullMRTest.java index c9c943090466aa6330051dcad113c8b61c947d45..c48f4f9d079b6b0c35c005e9c7c65fbfb947188d 100644 --- a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/engine/interop/RNullMRTest.java +++ b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/engine/interop/RNullMRTest.java @@ -25,9 +25,16 @@ package com.oracle.truffle.r.test.engine.interop; import com.oracle.truffle.api.interop.TruffleObject; import com.oracle.truffle.r.runtime.data.RNull; +import org.junit.Test; public class RNullMRTest extends AbstractMRTest { + @Test + @Override + public void testIsNull() throws Exception { + super.testIsNull(); // force inherited tests from AbstractMRTest + } + @Override protected TruffleObject[] createTruffleObjects() throws Exception { return new TruffleObject[]{RNull.instance}; diff --git a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/engine/interop/RRawMRTest.java b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/engine/interop/RRawMRTest.java new file mode 100644 index 0000000000000000000000000000000000000000..2bb50e4d34a13fba741088dd979c2f473573d225 --- /dev/null +++ b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/engine/interop/RRawMRTest.java @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.truffle.r.test.engine.interop; + +import com.oracle.truffle.api.interop.TruffleObject; +import com.oracle.truffle.r.runtime.data.RRaw; +import org.junit.Test; + +public class RRawMRTest extends AbstractMRTest { + + @Override + protected TruffleObject[] createTruffleObjects() throws Exception { + return new TruffleObject[]{RRaw.valueOf((byte) 1)}; + } + + @Test + @Override + public void testIsNull() throws Exception { + super.testIsNull(); // force inherited tests from AbstractMRTest + } + + @Override + protected Object getUnboxed(TruffleObject obj) { + return ((RRaw) obj).getValue(); + } + + @Override + protected TruffleObject createEmptyTruffleObject() throws Exception { + return null; + } +} diff --git a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/engine/interop/RS4ObjectMRTest.java b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/engine/interop/RS4ObjectMRTest.java index 70b314fae9714478492a7001768a2f1b9224b3f1..858f2687b92cd9ea4b17300951cbe52599720041 100644 --- a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/engine/interop/RS4ObjectMRTest.java +++ b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/engine/interop/RS4ObjectMRTest.java @@ -125,7 +125,7 @@ public class RS4ObjectMRTest extends AbstractMRTest { } @Override - protected String[] getKeys() { + protected String[] getKeys(TruffleObject obj) { return new String[]{"s", "d", "i", "b", "fn", "class"}; } diff --git a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/engine/interop/RUboundValueMRTest.java b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/engine/interop/RUboundValueMRTest.java index baa61ec385903879fc2583e334d6a9e19c63eeeb..a8cbc0c0ddcfb223333554105a35988594414910 100644 --- a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/engine/interop/RUboundValueMRTest.java +++ b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/engine/interop/RUboundValueMRTest.java @@ -24,9 +24,16 @@ package com.oracle.truffle.r.test.engine.interop; import com.oracle.truffle.api.interop.TruffleObject; import com.oracle.truffle.r.runtime.data.RUnboundValue; +import org.junit.Test; public class RUboundValueMRTest extends AbstractMRTest { + @Test + @Override + public void testIsNull() throws Exception { + super.testIsNull(); // force inherited tests from AbstractMRTest + } + @Override protected TruffleObject[] createTruffleObjects() throws Exception { return new TruffleObject[]{RUnboundValue.instance}; diff --git a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/engine/interop/VectorMRTest.java b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/engine/interop/VectorMRTest.java index bf7b4926955fd311f382f063bc3d9a1500c0ec2c..67c3f0c75676ad68e80352b938929d8ee61d4cda 100644 --- a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/engine/interop/VectorMRTest.java +++ b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/engine/interop/VectorMRTest.java @@ -38,7 +38,6 @@ import com.oracle.truffle.api.interop.java.JavaInterop; import com.oracle.truffle.api.source.Source; import com.oracle.truffle.r.runtime.data.RDataFactory; import com.oracle.truffle.r.runtime.data.RObject; -import com.oracle.truffle.r.runtime.data.RVector; import com.oracle.truffle.r.runtime.data.model.RAbstractIntVector; import com.oracle.truffle.r.runtime.data.model.RAbstractStringVector; import com.oracle.truffle.r.runtime.data.model.RAbstractVector; @@ -108,32 +107,17 @@ public class VectorMRTest extends AbstractMRTest { return obj instanceof RObject; } - @Override - protected boolean isBoxed(TruffleObject obj) { - return ((RAbstractVector) obj).getLength() == 1; - } - @Override protected Object getUnboxed(TruffleObject obj) { assertTrue(((RAbstractVector) obj).getLength() == 1); return ((RAbstractVector) obj).getDataAtAsObject(0); } - @Override - protected boolean hasSize(TruffleObject obj) { - return true; - } - @Override protected int getSize(TruffleObject obj) { return ((RAbstractVector) obj).getLength(); } - @Override - protected boolean isPointer(TruffleObject obj) { - return obj instanceof RVector<?>; - } - private static TruffleObject create(String createTxt) throws Exception { Source src = Source.newBuilder(createTxt).mimeType("text/x-r").name("test.R").build(); return engine.eval(src).as(RAbstractVector.class); diff --git a/mx.fastr/suite.py b/mx.fastr/suite.py index fcbca55fbfcc07c1d1f1cf40cacabd6aa716f272..85809ddcf3603a74017662251b5fee53dd4c7587 100644 --- a/mx.fastr/suite.py +++ b/mx.fastr/suite.py @@ -29,7 +29,7 @@ suite = { { "name" : "truffle", "subdir" : True, - "version" : "d1bb9076f1fa6af71c60be140f980794596a75b4", + "version" : "e3ce4c4abc668fd637e64a467a8d5b999c2fbdae", "urls" : [ {"url" : "https://github.com/graalvm/graal", "kind" : "git"}, {"url" : "https://curio.ssw.jku.at/nexus/content/repositories/snapshots", "kind" : "binary"},