diff --git a/com.oracle.truffle.r.native/fficall/src/common/coerce_fastr.c b/com.oracle.truffle.r.native/fficall/src/common/coerce_fastr.c index 2e0b2fe4c58d3d1fc3eb9390f065138dd297030a..764b8be1bb08953dca725303fa8dacf3312c34ff 100644 --- a/com.oracle.truffle.r.native/fficall/src/common/coerce_fastr.c +++ b/com.oracle.truffle.r.native/fficall/src/common/coerce_fastr.c @@ -308,120 +308,3 @@ static SEXP coercePairList(SEXP v, SEXPTYPE type) return rval; } -SEXP Rf_coerceVector(SEXP v, SEXPTYPE type) -{ - SEXP op, vp, ans = R_NilValue; /* -Wall */ - int i,n; - - if (TYPEOF(v) == type) - return v; - /* code to allow classes to extend ENVSXP, SYMSXP, etc */ - if(IS_S4_OBJECT(v) && TYPEOF(v) == S4SXP) { - SEXP vv = R_getS4DataSlot(v, ANYSXP); - if(vv == R_NilValue) - error(_("no method for coercing this S4 class to a vector")); - else if(TYPEOF(vv) == type) - return vv; - v = vv; - } - - switch (TYPEOF(v)) { -#ifdef NOTYET - case NILSXP: - ans = coerceNull(v, type); - break; -#endif - case SYMSXP: - ans = coerceSymbol(v, type); - break; - case NILSXP: - case LISTSXP: - ans = coercePairList(v, type); - break; - case LANGSXP: - if (type != STRSXP) { - ans = coercePairList(v, type); - break; - } - - /* This is mostly copied from coercePairList, but we need to - * special-case the first element so as not to get operators - * put in backticks. */ - n = length(v); - PROTECT(ans = allocVector(type, n)); - if (n == 0) break; /* Can this actually happen? */ - i = 0; - op = CAR(v); - /* The case of practical relevance is "lhs ~ rhs", which - * people tend to split using as.character(), modify, and - * paste() back together. However, we might as well - * special-case all symbolic operators here. */ - if (TYPEOF(op) == SYMSXP) { - SET_STRING_ELT(ans, i, PRINTNAME(op)); - i++; - v = CDR(v); - } - - /* The distinction between strings and other elements was - * here "always", but is really dubious since it makes x <- a - * and x <- "a" come out identical. Won't fix just now. */ - for (vp = v; vp != R_NilValue; vp = CDR(vp), i++) { - if (isString(CAR(vp)) && length(CAR(vp)) == 1) - SET_STRING_ELT(ans, i, STRING_ELT(CAR(vp), 0)); - else - SET_STRING_ELT(ans, i, STRING_ELT(deparse1line(CAR(vp), 0), 0)); - } - UNPROTECT(1); - break; - case VECSXP: - case EXPRSXP: - ans = coerceVectorList(v, type); - break; - case ENVSXP: - error(_("environments cannot be coerced to other types")); - break; - case LGLSXP: - case INTSXP: - case REALSXP: - case CPLXSXP: - case STRSXP: - case RAWSXP: - -#define COERCE_ERROR_STRING "cannot coerce type '%s' to vector of type '%s'" - -#define COERCE_ERROR \ - error(_(COERCE_ERROR_STRING), type2char(TYPEOF(v)), type2char(type)) - - switch (type) { - case SYMSXP: - ans = coerceToSymbol(v); break; - case LGLSXP: - ans = coerceToLogical(v); break; - case INTSXP: - ans = coerceToInteger(v); break; - case REALSXP: - ans = coerceToReal(v); break; - case CPLXSXP: - ans = coerceToComplex(v); break; - case RAWSXP: - ans = coerceToRaw(v); break; - case STRSXP: - ans = coerceToString(v); break; - case EXPRSXP: - ans = coerceToExpression(v); break; - case VECSXP: - ans = coerceToVectorList(v); break; - case LISTSXP: - ans = coerceToPairList(v); break; - default: - COERCE_ERROR; - } - break; - default: - COERCE_ERROR; - } - return ans; -} -#undef COERCE_ERROR - - diff --git a/com.oracle.truffle.r.native/fficall/src/jni/Rinternals.c b/com.oracle.truffle.r.native/fficall/src/jni/Rinternals.c index 7091886c83b2484cf70ea5cdeb3b899383dce97d..affaab5f727fbad00ec93247b196107031d0d2f7 100644 --- a/com.oracle.truffle.r.native/fficall/src/jni/Rinternals.c +++ b/com.oracle.truffle.r.native/fficall/src/jni/Rinternals.c @@ -92,6 +92,7 @@ static jmethodID LENGTH_MethodID; static jmethodID Rf_asIntegerMethodID; static jmethodID Rf_asRealMethodID; static jmethodID Rf_asCharMethodID; +static jmethodID Rf_coerceVectorMethodID; static jmethodID Rf_mkCharLenCEMethodID; static jmethodID Rf_asLogicalMethodID; static jmethodID Rf_PairToVectorListMethodID; @@ -203,6 +204,7 @@ void init_internals(JNIEnv *env) { Rf_asRealMethodID = checkGetMethodID(env, UpCallsRFFIClass, "Rf_asReal", "(Ljava/lang/Object;)D", 0); Rf_asCharMethodID = checkGetMethodID(env, UpCallsRFFIClass, "Rf_asChar", "(Ljava/lang/Object;)Ljava/lang/Object;", 0); Rf_mkCharLenCEMethodID = checkGetMethodID(env, UpCallsRFFIClass, "Rf_mkCharLenCE", "(Ljava/lang/Object;II)Ljava/lang/Object;", 0); + Rf_coerceVectorMethodID = checkGetMethodID(env, UpCallsRFFIClass, "Rf_coerceVector", "(Ljava/lang/Object;I)Ljava/lang/Object;", 0); Rf_asLogicalMethodID = checkGetMethodID(env, UpCallsRFFIClass, "Rf_asLogical", "(Ljava/lang/Object;)I", 0); Rf_PairToVectorListMethodID = checkGetMethodID(env, UpCallsRFFIClass, "Rf_PairToVectorList", "(Ljava/lang/Object;)Ljava/lang/Object;", 0); NAMED_MethodID = checkGetMethodID(env, UpCallsRFFIClass, "NAMED", "(Ljava/lang/Object;)I", 0); @@ -1230,6 +1232,13 @@ SEXP Rf_asChar(SEXP x){ return checkRef(thisenv, result); } +SEXP Rf_coerceVector(SEXP x, SEXPTYPE mode){ + TRACE(TARGp, x); + JNIEnv *thisenv = getEnv(); + SEXP result = (*thisenv)->CallObjectMethod(thisenv, UpCallsRFFIObject, Rf_coerceVectorMethodID, x, mode); + return checkRef(thisenv, result); +} + SEXP Rf_PairToVectorList(SEXP x){ TRACE(TARGp, x); JNIEnv *thisenv = getEnv(); diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/ffi/CoerceVectorNode.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/ffi/CoerceVectorNode.java new file mode 100644 index 0000000000000000000000000000000000000000..b7eb9d97d31188cc0fc7981ed94022e038561645 --- /dev/null +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/ffi/CoerceVectorNode.java @@ -0,0 +1,168 @@ +/* + * 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.nodes.ffi; + +import static com.oracle.truffle.r.nodes.ffi.RFFIUtils.unimplemented; + +import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; +import com.oracle.truffle.api.dsl.Cached; +import com.oracle.truffle.api.dsl.Fallback; +import com.oracle.truffle.api.dsl.Specialization; +import com.oracle.truffle.r.nodes.unary.CastComplexNode; +import com.oracle.truffle.r.nodes.unary.CastDoubleNode; +import com.oracle.truffle.r.nodes.unary.CastExpressionNode; +import com.oracle.truffle.r.nodes.unary.CastIntegerNode; +import com.oracle.truffle.r.nodes.unary.CastListNode; +import com.oracle.truffle.r.nodes.unary.CastLogicalNode; +import com.oracle.truffle.r.nodes.unary.CastNode; +import com.oracle.truffle.r.nodes.unary.CastRawNode; +import com.oracle.truffle.r.nodes.unary.CastStringNode; +import com.oracle.truffle.r.nodes.unary.CastSymbolNode; +import com.oracle.truffle.r.runtime.RError; +import com.oracle.truffle.r.runtime.RError.Message; +import com.oracle.truffle.r.runtime.RRuntime; +import com.oracle.truffle.r.runtime.data.RList; +import com.oracle.truffle.r.runtime.data.RTypedValue; +import com.oracle.truffle.r.runtime.gnur.SEXPTYPE; + +/** + * Implements Rf_coerceVector. + */ +public abstract class CoerceVectorNode extends FFIUpCallNode.Arg2 { + + public static CoerceVectorNode create() { + return CoerceVectorNodeGen.create(); + } + + @Specialization(guards = "value.isS4()") + Object doS4Object(RTypedValue value, int mode) { + throw RError.nyi(RError.NO_CALLER, "Rf_coerceVector for S4 objects."); + } + + // Note: caches should cover all valid possibilities + @Specialization(guards = {"!isS4Object(value)", "isNotList(value)", "isValidMode(mode)", "cachedMode == mode"}, limit = "99") + Object doCached(Object value, int mode, + @Cached("mode") int cachedMode, + @Cached("createCastNode(cachedMode)") CastNode castNode) { + return castNode.execute(value); + } + + // Lists are coerced with only preserved names unlike other types + @Specialization(guards = {"!isS4Object(value)", "isValidMode(mode)", "cachedMode == mode"}, limit = "99") + Object doCached(RList value, int mode, + @Cached("mode") int cachedMode, + @Cached("createCastNodeForList(cachedMode)") CastNode castNode) { + return castNode.execute(value); + } + + @Fallback + @TruffleBoundary + Object doFallback(Object value, Object mode) { + String type = value != null ? value.getClass().getSimpleName() : "null"; + throw unimplemented(String.format("Rf_coerceVector unimplemented for type %s or mode %s.", type, mode)); + } + + static boolean isS4Object(Object obj) { + return obj instanceof RTypedValue && ((RTypedValue) obj).isS4(); + } + + static boolean isNotList(Object obj) { + return !(obj instanceof RList); + } + + static boolean isValidMode(int mode) { + return mode >= SEXPTYPE.NILSXP.code && mode <= SEXPTYPE.RAWSXP.code; + } + + static CastNode createCastNode(int mode) { + return createCastNode(mode, false); + } + + static CastNode createCastNodeForList(int mode) { + return createCastNode(mode, true); + } + + private static CastNode createCastNode(int mode, boolean forList) { + SEXPTYPE type = SEXPTYPE.mapInt(mode); + boolean preserveDims = !forList; + boolean preserveAttrs = !forList; + switch (type) { + case SYMSXP: + return CastSymbolNode.createForRFFI(false, false, false); + case NILSXP: + return new CastNullNode(); + case LISTSXP: + throw unimplemented("Rf_coerceVector called with unimplemented for PairLists."); + case LANGSXP: + throw unimplemented("Rf_coerceVector called with unimplemented for RLanguage."); + case ENVSXP: + return new EnvironmentCast(); + case VECSXP: + return CastListNode.createForRFFI(true, forList, forList); + case EXPRSXP: + return CastExpressionNode.createForRFFI(false, false, false); + case INTSXP: + return CastIntegerNode.createForRFFI(true, preserveDims, preserveAttrs); + case REALSXP: + return CastDoubleNode.createForRFFI(true, preserveDims, preserveAttrs); + case LGLSXP: + return CastLogicalNode.createForRFFI(true, preserveDims, preserveAttrs); + case STRSXP: + return CastStringNode.createForRFFI(true, preserveDims, preserveAttrs); + case CPLXSXP: + return CastComplexNode.createForRFFI(true, preserveDims, preserveAttrs); + case RAWSXP: + return CastRawNode.createForRFFI(true, preserveDims, preserveAttrs); + default: + throw unimplemented(String.format("Rf_coerceVector called with unimplemented mode %d (type %s).", mode, type)); + } + } + + private static final class CastNullNode extends CastNode { + @Override + @TruffleBoundary + public Object execute(@SuppressWarnings("unused") Object value) { + if (value instanceof RList) { + throw RError.error(RError.NO_CALLER, Message.UNIMPLEMENTED_TYPE_IN_FUNCTION, "list", "coerceVectorList"); + } else { + throw RError.error(RError.NO_CALLER, Message.CANNOT_COERCE, getTypeName(value), "NULL"); + } + } + + private static String getTypeName(Object val) { + Object value = RRuntime.asAbstractVector(val); + if (value == null) { + return "null"; + } + return value instanceof RTypedValue ? ((RTypedValue) value).getRType().getName() : value.getClass().getSimpleName(); + } + } + + private static final class EnvironmentCast extends CastNode { + @Override + @TruffleBoundary + public Object execute(Object value) { + throw RError.error(RError.NO_CALLER, Message.ENVIRONMENTS_COERCE); + } + } +} diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/ffi/FFIUpCallRootNode.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/ffi/FFIUpCallRootNode.java index 6cd1f9fe0e8c635adc38406c9c9cdcd95d5a8572..e7d26f933bccbd58fc565b82df14d3dd87b84c0d 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/ffi/FFIUpCallRootNode.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/ffi/FFIUpCallRootNode.java @@ -84,6 +84,7 @@ public final class FFIUpCallRootNode extends RootNode { FFIUpCallRootNode.add(RFFIUpCallMethod.Rf_asLogical, AsLogicalNodeGen::create); FFIUpCallRootNode.add(RFFIUpCallMethod.Rf_asInteger, AsIntegerNodeGen::create); FFIUpCallRootNode.add(RFFIUpCallMethod.Rf_asChar, AsCharNodeGen::create); + FFIUpCallRootNode.add(RFFIUpCallMethod.Rf_coerceVector, CoerceVectorNode::create); FFIUpCallRootNode.add(RFFIUpCallMethod.CAR, CARNodeGen::create); FFIUpCallRootNode.add(RFFIUpCallMethod.CDR, CDRNodeGen::create); FFIUpCallRootNode.add(RFFIUpCallMethod.CADR, CADRNodeGen::create); diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/ffi/JavaUpCallsRFFIImpl.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/ffi/JavaUpCallsRFFIImpl.java index 03d4150564f5ef3ae2dc0cba1789216d2f4a935a..a12d923fd9d1eac96a6a53f5fe799a458d3abb74 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/ffi/JavaUpCallsRFFIImpl.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/ffi/JavaUpCallsRFFIImpl.java @@ -156,6 +156,11 @@ public abstract class JavaUpCallsRFFIImpl implements UpCallsRFFI { return FFIUpCallRootNode.getCallTarget(RFFIUpCallMethod.Rf_asChar).call(x); } + @Override + public Object Rf_coerceVector(Object x, int mode) { + return FFIUpCallRootNode.getCallTarget(RFFIUpCallMethod.Rf_coerceVector).call(x, mode); + } + @Override public Object Rf_mkCharLenCE(Object bytes, int len, int encoding) { // TODO: handle encoding properly diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/ffi/RFFIUpCallMethod.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/ffi/RFFIUpCallMethod.java index dd28c59af3fe2185653105acfd503bfaf164d9c2..a998220115fb7fa4aec65f56d40e8c6087f704ce 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/ffi/RFFIUpCallMethod.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/ffi/RFFIUpCallMethod.java @@ -104,6 +104,7 @@ public enum RFFIUpCallMethod { Rf_asLogical("(object) : sint32"), Rf_asReal("(object) : double"), Rf_classgets("(object, object) : object"), + Rf_coerceVector("(object, sint32) : object"), Rf_cons("(object, object) : object"), Rf_copyListMatrix("(object, object, sint32) : void"), Rf_copyMatrix("(object, object, sint32) : void"), diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/ffi/TracingUpCallsRFFIImpl.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/ffi/TracingUpCallsRFFIImpl.java index 31a6a88c7c7cfa52f87e69596fe31cb14e6ed07c..fd78becb64849ad60a065a0da30db451b4d4ad15 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/ffi/TracingUpCallsRFFIImpl.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/ffi/TracingUpCallsRFFIImpl.java @@ -87,6 +87,12 @@ final class TracingUpCallsRFFIImpl implements UpCallsRFFI { return delegate.Rf_asChar(x); } + @Override + public Object Rf_coerceVector(Object x, int mode) { + RFFIUtils.traceUpCall("Rf_coerceVector", x, mode); + return delegate.Rf_coerceVector(x, mode); + } + @Override public Object Rf_mkCharLenCE(Object bytes, int len, int encoding) { RFFIUtils.traceUpCall("Rf_mkCharLenCE", bytes); diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/CastBaseNode.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/CastBaseNode.java index 1f77dc7c613660b33bcffd08b683c933095c681c..f136727e66301ca5e52345e87ad452d418b737a3 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/CastBaseNode.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/CastBaseNode.java @@ -34,10 +34,12 @@ import com.oracle.truffle.r.nodes.attributes.SpecialAttributesFunctions.GetNames import com.oracle.truffle.r.nodes.attributes.SpecialAttributesFunctions.SetDimNamesAttributeNode; import com.oracle.truffle.r.runtime.NullProfile; import com.oracle.truffle.r.runtime.RError; +import com.oracle.truffle.r.runtime.RError.Message; import com.oracle.truffle.r.runtime.RInternalError; import com.oracle.truffle.r.runtime.RRuntime; import com.oracle.truffle.r.runtime.RType; import com.oracle.truffle.r.runtime.data.RList; +import com.oracle.truffle.r.runtime.data.RNull; import com.oracle.truffle.r.runtime.data.RStringVector; import com.oracle.truffle.r.runtime.data.RTypedValue; import com.oracle.truffle.r.runtime.data.RVector; @@ -62,21 +64,37 @@ public abstract class CastBaseNode extends CastNode { protected final RBaseNode messageCallObj; + /** + * GnuR provides several, sometimes incompatible, ways to coerce given value to given type. This + * flag tells the cast node that it should behave in a way compatible with functions exposed by + * the native interface. + */ + private final boolean forRFFI; + protected CastBaseNode(boolean preserveNames, boolean preserveDimensions, boolean preserveAttributes, RBaseNode messageCallObj) { + this(preserveNames, preserveDimensions, preserveAttributes, false, messageCallObj); + } + + protected CastBaseNode(boolean preserveNames, boolean preserveDimensions, boolean preserveAttributes) { + this(preserveNames, preserveDimensions, preserveAttributes, false, null); + } + + protected CastBaseNode(boolean preserveNames, boolean preserveDimensions, boolean preserveAttributes, boolean forRFFI) { + this(preserveNames, preserveDimensions, preserveAttributes, forRFFI, null); + } + + protected CastBaseNode(boolean preserveNames, boolean preserveDimensions, boolean preserveAttributes, boolean forRFFI, RBaseNode messageCallObj) { this.preserveNames = preserveNames; this.preserveDimensions = preserveDimensions; this.preserveAttributes = preserveAttributes; + this.forRFFI = forRFFI; if (preserveDimensions) { getDimNamesNode = GetDimNamesAttributeNode.create(); } this.messageCallObj = messageCallObj == null ? this : messageCallObj; } - protected CastBaseNode(boolean preserveNames, boolean preserveDimensions, boolean preserveAttributes) { - this(preserveNames, preserveDimensions, preserveAttributes, null); - } - - public boolean preserveNames() { + public final boolean preserveNames() { return preserveNames; } @@ -84,7 +102,7 @@ public abstract class CastBaseNode extends CastNode { return preserveDimensions; } - public boolean preserveAttributes() { + public final boolean preserveAttributes() { return preserveAttributes; } @@ -132,6 +150,10 @@ public abstract class CastBaseNode extends CastNode { @TruffleBoundary protected Object doOther(Object value) { Object mappedValue = RRuntime.asAbstractVector(value); + return forRFFI ? doOtherRFFI(mappedValue) : doOtherDefault(mappedValue); + } + + protected Object doOtherDefault(Object mappedValue) { if (mappedValue instanceof REnvironment) { throw RError.error(RError.SHOW_CALLER, RError.Message.ENVIRONMENTS_COERCE); } else if (mappedValue instanceof RTypedValue) { @@ -142,4 +164,13 @@ public abstract class CastBaseNode extends CastNode { throw RInternalError.shouldNotReachHere("unexpected value of type " + (mappedValue == null ? "null" : mappedValue.getClass())); } } + + protected Object doOtherRFFI(Object mappedValue) { + if (mappedValue instanceof RTypedValue) { + RError.warning(RError.SHOW_CALLER2, Message.CANNOT_COERCE_RFFI, ((RTypedValue) mappedValue).getRType().getName(), getTargetType().getName()); + } else if (mappedValue instanceof TruffleObject) { + throw RError.error(RError.SHOW_CALLER2, RError.Message.CANNOT_COERCE, "truffleobject", getTargetType().getName()); + } + return RNull.instance; + } } diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/CastComplexNode.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/CastComplexNode.java index ac4c7257d26522de101146488e754c19913f92b2..3d8fb9edf3cb50b7c240b346f6b6ecd014af103c 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/CastComplexNode.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/CastComplexNode.java @@ -68,7 +68,11 @@ public abstract class CastComplexNode extends CastBaseNode { } protected CastComplexNode(boolean preserveNames, boolean preserveDimensions, boolean preserveAttributes) { - super(preserveNames, preserveDimensions, preserveAttributes); + this(preserveNames, preserveDimensions, preserveAttributes, false); + } + + protected CastComplexNode(boolean preserveNames, boolean preserveDimensions, boolean preserveAttributes, boolean forRFFI) { + super(preserveNames, preserveDimensions, preserveAttributes, forRFFI); } @Child private CastComplexNode recursiveCastComplex; @@ -253,7 +257,7 @@ public abstract class CastComplexNode extends CastBaseNode { } } } - RComplexVector ret = RDataFactory.createComplexVector(result, !seenNA); + RComplexVector ret = RDataFactory.createComplexVector(result, !seenNA, getPreservedDimensions(list), getPreservedNames(list)); if (preserveAttributes()) { ret.copyRegAttributesFrom(list); } @@ -264,6 +268,10 @@ public abstract class CastComplexNode extends CastBaseNode { return CastComplexNodeGen.create(true, true, true); } + public static CastComplexNode createForRFFI(boolean preserveNames, boolean preserveDimensions, boolean preserveAttributes) { + return CastComplexNodeGen.create(preserveNames, preserveDimensions, preserveAttributes, true); + } + public static CastComplexNode createNonPreserving() { return CastComplexNodeGen.create(false, false, false); } diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/CastDoubleBaseNode.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/CastDoubleBaseNode.java index eee5c3293436bdff45e3c16553e2514390029638..6e1b66b74024f6c999d8c11e844bd43ffdb56519 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/CastDoubleBaseNode.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/CastDoubleBaseNode.java @@ -48,7 +48,11 @@ public abstract class CastDoubleBaseNode extends CastBaseNode { } protected CastDoubleBaseNode(boolean preserveNames, boolean preserveDimensions, boolean preserveAttributes) { - this(preserveNames, preserveDimensions, preserveAttributes, null); + this(preserveNames, preserveDimensions, preserveAttributes, false); + } + + protected CastDoubleBaseNode(boolean preserveNames, boolean preserveDimensions, boolean preserveAttributes, boolean forRFFI) { + super(preserveNames, preserveDimensions, preserveAttributes, forRFFI); } @Override diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/CastDoubleNode.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/CastDoubleNode.java index 3b98bd3901d57968edc1e6e58e68b6d60ad8f9e5..d937c07eef513dd28ae555162996c52622b1a445 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/CastDoubleNode.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/CastDoubleNode.java @@ -48,7 +48,11 @@ import com.oracle.truffle.r.runtime.nodes.RBaseNode; public abstract class CastDoubleNode extends CastDoubleBaseNode { protected CastDoubleNode(boolean preserveNames, boolean preserveDimensions, boolean preserveAttributes) { - super(preserveNames, preserveDimensions, preserveAttributes); + this(preserveNames, preserveDimensions, preserveAttributes, false); + } + + protected CastDoubleNode(boolean preserveNames, boolean preserveDimensions, boolean preserveAttributes, boolean forRFFI) { + super(preserveNames, preserveDimensions, preserveAttributes, forRFFI); } protected CastDoubleNode(boolean preserveNames, boolean preserveDimensions, boolean preserveAttributes, RBaseNode messageCallerObj) { @@ -211,6 +215,10 @@ public abstract class CastDoubleNode extends CastDoubleBaseNode { return CastDoubleNodeGen.create(true, true, true); } + public static CastDoubleNode createForRFFI(boolean preserveNames, boolean preserveDimensions, boolean preserveAttributes) { + return CastDoubleNodeGen.create(preserveNames, preserveDimensions, preserveAttributes, true); + } + public static CastDoubleNode createNonPreserving() { return CastDoubleNodeGen.create(false, false, false); } diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/CastExpressionNode.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/CastExpressionNode.java index 1178f3762ee7743577fe611918c14242c8f9592d..a5a4c01397428aa1bb6bb6e64d196c5e6f001906 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/CastExpressionNode.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/CastExpressionNode.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 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 @@ -40,7 +40,11 @@ public abstract class CastExpressionNode extends CastBaseNode { public abstract Object executeExpression(Object o); protected CastExpressionNode(boolean preserveNames, boolean preserveDimensions, boolean preserveAttributes) { - super(preserveNames, preserveDimensions, preserveAttributes); + this(preserveNames, preserveDimensions, preserveAttributes, false); + } + + protected CastExpressionNode(boolean preserveNames, boolean preserveDimensions, boolean preserveAttributes, boolean forRFFI) { + super(preserveNames, preserveDimensions, preserveAttributes, forRFFI); } @Override @@ -104,6 +108,11 @@ public abstract class CastExpressionNode extends CastBaseNode { return RDataFactory.createExpression(new Object[]{obj}); } + public static CastExpressionNode createForRFFI(boolean preserveNames, boolean preserveDimensions, boolean preserveAttributes) { + // RFFI coercion to list unlike others does not preserve names it seems + return CastExpressionNodeGen.create(false, false, false, true); + } + public static CastExpressionNode createNonPreserving() { return CastExpressionNodeGen.create(false, false, false); } diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/CastIntegerBaseNode.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/CastIntegerBaseNode.java index 14766f8e64420a3718be737713643cef99cd92e6..5a26f6d19895e8c6f35c4d243008cbc6b69d98e9 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/CastIntegerBaseNode.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/CastIntegerBaseNode.java @@ -45,7 +45,11 @@ public abstract class CastIntegerBaseNode extends CastBaseNode { @Child private CastIntegerNode recursiveCastInteger; protected CastIntegerBaseNode(boolean preserveNames, boolean preserveDimensions, boolean preserveAttributes) { - super(preserveNames, preserveDimensions, preserveAttributes); + this(preserveNames, preserveDimensions, preserveAttributes, false); + } + + protected CastIntegerBaseNode(boolean preserveNames, boolean preserveDimensions, boolean preserveAttributes, boolean forRFFI) { + super(preserveNames, preserveDimensions, preserveAttributes, forRFFI); } protected CastIntegerBaseNode(boolean preserveNames, boolean preserveDimensions, boolean preserveAttributes, RBaseNode messageCallObj) { diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/CastIntegerNode.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/CastIntegerNode.java index 796d7b556930f9690c2a5d9bc429ff7893c50836..b0310c602bddc67547b37ceca490cbd62324916d 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/CastIntegerNode.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/CastIntegerNode.java @@ -50,7 +50,11 @@ public abstract class CastIntegerNode extends CastIntegerBaseNode { private final NAProfile naProfile = NAProfile.create(); protected CastIntegerNode(boolean preserveNames, boolean preserveDimensions, boolean preserveAttributes) { - super(preserveNames, preserveDimensions, preserveAttributes); + this(preserveNames, preserveDimensions, preserveAttributes, false); + } + + protected CastIntegerNode(boolean preserveNames, boolean preserveDimensions, boolean preserveAttributes, boolean forRFFI) { + super(preserveNames, preserveDimensions, preserveAttributes, forRFFI); } protected CastIntegerNode(boolean preserveNames, boolean preserveDimensions, boolean preserveAttributes, RBaseNode messageCallObj) { @@ -229,6 +233,10 @@ public abstract class CastIntegerNode extends CastIntegerBaseNode { return CastIntegerNodeGen.create(true, true, true, null); } + public static CastIntegerNode createForRFFI(boolean preserveNames, boolean preserveDimensions, boolean preserveAttributes) { + return CastIntegerNodeGen.create(preserveNames, preserveDimensions, preserveAttributes, true); + } + public static CastIntegerNode createNonPreserving() { return CastIntegerNodeGen.create(false, false, false, null); } 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 606b54d966886466339e13999070d035d9622b8c..1fc21b1956a3090baa9154e67dd895db82e8752f 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 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 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 @@ -52,7 +52,11 @@ public abstract class CastListNode extends CastBaseNode { public abstract RList executeList(Object o); protected CastListNode(boolean preserveNames, boolean preserveDimensions, boolean preserveAttributes) { - super(preserveNames, preserveDimensions, preserveAttributes); + this(preserveNames, preserveDimensions, preserveAttributes, false); + } + + protected CastListNode(boolean preserveNames, boolean preserveDimensions, boolean preserveAttributes, boolean forRFFI) { + super(preserveNames, preserveDimensions, preserveAttributes, forRFFI); } @Override @@ -143,4 +147,8 @@ public abstract class CastListNode extends CastBaseNode { public static CastListNode create() { return CastListNodeGen.create(true, true, true); } + + public static CastListNode createForRFFI(boolean preserveNames, boolean preserveDimensions, boolean preserveAttributes) { + return CastListNodeGen.create(preserveNames, preserveDimensions, preserveAttributes, true); + } } diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/CastLogicalBaseNode.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/CastLogicalBaseNode.java index d9883e2f08ea84986d3ad1116e6d93ed5f289a3f..94f484b2fcb70f5c38f0cf120146a5e8d0db7066 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/CastLogicalBaseNode.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/CastLogicalBaseNode.java @@ -35,7 +35,11 @@ public abstract class CastLogicalBaseNode extends CastBaseNode { protected final NACheck naCheck = NACheck.create(); protected CastLogicalBaseNode(boolean preserveNames, boolean preserveDimensions, boolean preserveAttributes) { - super(preserveNames, preserveDimensions, preserveAttributes); + this(preserveNames, preserveDimensions, preserveAttributes, false); + } + + protected CastLogicalBaseNode(boolean preserveNames, boolean preserveDimensions, boolean preserveAttributes, boolean forRFFI) { + super(preserveNames, preserveDimensions, preserveAttributes, forRFFI); } protected CastLogicalBaseNode(boolean preserveNames, boolean preserveDimensions, boolean preserveAttributes, RBaseNode messageCallObj) { diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/CastLogicalNode.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/CastLogicalNode.java index 7cd9f32a97fedbf623c582a520fdd697f49ff6bb..6f15ddd3fc0adfaf0925225098145b3806ab1b5b 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/CastLogicalNode.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/CastLogicalNode.java @@ -56,7 +56,11 @@ public abstract class CastLogicalNode extends CastLogicalBaseNode { } protected CastLogicalNode(boolean preserveNames, boolean preserveDimensions, boolean preserveAttributes) { - super(preserveNames, preserveDimensions, preserveAttributes); + this(preserveNames, preserveDimensions, preserveAttributes, false); + } + + protected CastLogicalNode(boolean preserveNames, boolean preserveDimensions, boolean preserveAttributes, boolean forRFFI) { + super(preserveNames, preserveDimensions, preserveAttributes, forRFFI); } protected Object castLogicalRecursive(Object o) { @@ -176,7 +180,7 @@ public abstract class CastLogicalNode extends CastLogicalBaseNode { } } } - RLogicalVector ret = RDataFactory.createLogicalVector(result, !seenNA); + RLogicalVector ret = RDataFactory.createLogicalVector(result, !seenNA, getPreservedDimensions(list), getPreservedNames(list)); if (preserveAttributes()) { ret.copyRegAttributesFrom(list); } @@ -197,6 +201,10 @@ public abstract class CastLogicalNode extends CastLogicalBaseNode { return CastLogicalNodeGen.create(true, true, true); } + public static CastLogicalNode createForRFFI(boolean preserveNames, boolean preserveDimensions, boolean preserveAttributes) { + return CastLogicalNodeGen.create(preserveNames, preserveDimensions, preserveAttributes, true); + } + public static CastLogicalNode createNonPreserving() { return CastLogicalNodeGen.create(false, false, false); } diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/CastRawNode.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/CastRawNode.java index 5ef5ca20530477fdd9cb099ffc0bf2b58f33e485..9471d88d7a054c98afd9c2a79edc12bb6cc5b4b3 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/CastRawNode.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/CastRawNode.java @@ -51,7 +51,11 @@ public abstract class CastRawNode extends CastBaseNode { private final BranchProfile warningBranch = BranchProfile.create(); protected CastRawNode(boolean preserveNames, boolean preserveDimensions, boolean preserveAttributes) { - super(preserveNames, preserveDimensions, preserveAttributes); + this(preserveNames, preserveDimensions, preserveAttributes, false); + } + + protected CastRawNode(boolean preserveNames, boolean preserveDimensions, boolean preserveAttributes, boolean forRFFI) { + super(preserveNames, preserveDimensions, preserveAttributes, forRFFI); } @Child private CastRawNode recursiveCastRaw; @@ -143,6 +147,7 @@ public abstract class CastRawNode extends CastBaseNode { if (intRawValue != intValue) { warningBranch.enter(); RError.warning(this, RError.Message.OUT_OF_RANGE); + return RRaw.valueOf((byte) 0); } return RRaw.valueOf((byte) intRawValue); } @@ -223,7 +228,7 @@ public abstract class CastRawNode extends CastBaseNode { if (intValue != intRawValue) { warningBranch.enter(); outOfRangeWarning = true; - intRawValue = 0; + intValue = 0; } } bdata[i] = (byte) intValue; @@ -294,13 +299,21 @@ public abstract class CastRawNode extends CastBaseNode { @Specialization protected RRawVector doList(RAbstractListVector value) { int length = value.getLength(); - RRawVector result = RDataFactory.createRawVector(length); + byte[] data = new byte[length]; for (int i = 0; i < length; i++) { - result.updateDataAt(i, (RRaw) castRawRecursive(value.getDataAt(i))); + data[i] = ((RRaw) castRawRecursive(value.getDataAt(i))).getValue(); + } + RRawVector result = RDataFactory.createRawVector(data, getPreservedDimensions(value), getPreservedNames(value)); + if (preserveAttributes()) { + result.copyRegAttributesFrom(value); } return result; } + public static CastRawNode createForRFFI(boolean preserveNames, boolean preserveDimensions, boolean preserveAttributes) { + return CastRawNodeGen.create(preserveNames, preserveDimensions, preserveAttributes, true); + } + public static CastRawNode createNonPreserving() { return CastRawNodeGen.create(false, false, false); } diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/CastStringBaseNode.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/CastStringBaseNode.java index e5d9f51ef3fab718a57ff9e386fefb80704bdec6..8d3a0456e360fb32c4cb5eb2be2bc1a3a4a8bbea 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/CastStringBaseNode.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/CastStringBaseNode.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 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 @@ -34,7 +34,11 @@ public abstract class CastStringBaseNode extends CastBaseNode { @Child private ToStringNode toString = ToStringNodeGen.create(); protected CastStringBaseNode(boolean preserveNames, boolean preserveDimensions, boolean preserveAttributes) { - super(preserveNames, preserveDimensions, preserveAttributes); + this(preserveNames, preserveDimensions, preserveAttributes, false); + } + + protected CastStringBaseNode(boolean preserveNames, boolean preserveDimensions, boolean preserveAttributes, boolean forRFFI) { + super(preserveNames, preserveDimensions, preserveAttributes, forRFFI); } @Override diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/CastStringNode.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/CastStringNode.java index 2bdf51e02a89fd602aa48fa584edbf64fcb68f59..a59b45866a9f896aba4c630d879592f5af370bc3 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/CastStringNode.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/CastStringNode.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 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 @@ -35,7 +35,11 @@ import com.oracle.truffle.r.runtime.data.model.RAbstractContainer; public abstract class CastStringNode extends CastStringBaseNode { protected CastStringNode(boolean preserveNames, boolean preserveDimensions, boolean preserveAttributes) { - super(preserveNames, preserveDimensions, preserveAttributes); + this(preserveNames, preserveDimensions, preserveAttributes, false); + } + + protected CastStringNode(boolean preserveNames, boolean preserveDimensions, boolean preserveAttributes, boolean forRFFI) { + super(preserveNames, preserveDimensions, preserveAttributes, forRFFI); } public abstract Object executeString(int o); @@ -85,6 +89,10 @@ public abstract class CastStringNode extends CastStringBaseNode { return CastStringNodeGen.create(true, true, true); } + public static CastStringNode createForRFFI(boolean preserveNames, boolean preserveDimensions, boolean preserveAttributes) { + return CastStringNodeGen.create(preserveNames, preserveDimensions, preserveAttributes, true); + } + public static CastStringNode createNonPreserving() { return CastStringNodeGen.create(false, false, false); } diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/CastSymbolNode.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/CastSymbolNode.java index 58cd32ecd1419a22a1b37836b1c71025602e487f..31b0fea74e35ffce8cef8529677f9387887efbae 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/CastSymbolNode.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/CastSymbolNode.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 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 @@ -25,21 +25,28 @@ package com.oracle.truffle.r.nodes.unary; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.r.runtime.RError; +import com.oracle.truffle.r.runtime.RError.Message; import com.oracle.truffle.r.runtime.RType; import com.oracle.truffle.r.runtime.data.RDataFactory; import com.oracle.truffle.r.runtime.data.RDoubleVector; import com.oracle.truffle.r.runtime.data.RIntVector; +import com.oracle.truffle.r.runtime.data.RList; import com.oracle.truffle.r.runtime.data.RLogicalVector; import com.oracle.truffle.r.runtime.data.RNull; import com.oracle.truffle.r.runtime.data.RStringVector; import com.oracle.truffle.r.runtime.data.RSymbol; +import com.oracle.truffle.r.runtime.data.model.RAbstractVector; public abstract class CastSymbolNode extends CastBaseNode { @Child private ToStringNode toString = ToStringNodeGen.create(); protected CastSymbolNode(boolean preserveNames, boolean preserveDimensions, boolean preserveAttributes) { - super(preserveNames, preserveDimensions, preserveAttributes); + this(preserveNames, preserveDimensions, preserveAttributes, false); + } + + protected CastSymbolNode(boolean preserveNames, boolean preserveDimensions, boolean preserveAttributes, boolean forRFFI) { + super(preserveNames, preserveDimensions, preserveAttributes, forRFFI); } @Override @@ -85,32 +92,55 @@ public abstract class CastSymbolNode extends CastBaseNode { return RDataFactory.createSymbolInterned(value); } - @Specialization + @Specialization(guards = "value.getLength() > 0") protected RSymbol doStringVector(RStringVector value) { // Only element 0 interpreted return doString(value.getDataAt(0)); } - @Specialization + @Specialization(guards = "value.getLength() > 0") protected RSymbol doIntegerVector(RIntVector value) { return doInteger(value.getDataAt(0)); } - @Specialization + @Specialization(guards = "value.getLength() > 0") protected RSymbol doDoubleVector(RDoubleVector value) { return doDouble(value.getDataAt(0)); } - @Specialization + @Specialization(guards = "value.getLength() > 0") protected RSymbol doLogicalVector(RLogicalVector value) { return doLogical(value.getDataAt(0)); } + @Specialization(guards = "vector.getLength() == 0") + @TruffleBoundary + protected RSymbol doEmptyVector(RAbstractVector vector) { + if (vector instanceof RList) { + throw RError.error(this, RError.Message.INVALID_TYPE_LENGTH, "symbol", 0); + } else { + throw RError.error(this, Message.INVALID_DATA_OF_TYPE_TOO_SHORT, vector.getRType().getName(), 0); + } + } + @TruffleBoundary private static RSymbol asSymbol(String s) { return RDataFactory.createSymbolInterned(s); } + @Override + protected Object doOtherRFFI(Object mappedValue) { + if (mappedValue instanceof RList) { + // to be compatible with GnuR + throw RError.error(RError.NO_CALLER, Message.INVALID_TYPE_LENGTH, "symbol", ((RList) mappedValue).getLength()); + } + return super.doOtherRFFI(mappedValue); + } + + public static CastSymbolNode createForRFFI(boolean preserveNames, boolean preserveDimensions, boolean preserveAttributes) { + return CastSymbolNodeGen.create(preserveNames, preserveDimensions, preserveAttributes, true); + } + public static CastSymbolNode createNonPreserving() { return CastSymbolNodeGen.create(false, false, false); } diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/CastToAttributableNode.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/CastToAttributableNode.java index 92608cf7e342cce9085cf9b329b841ccb42fd2e3..790a649b001709dd8904deb6888618f7d3e492fe 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/CastToAttributableNode.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/CastToAttributableNode.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 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 @@ -38,7 +38,11 @@ public abstract class CastToAttributableNode extends CastBaseNode { public abstract Object executeObject(Object value); protected CastToAttributableNode(boolean preserveNames, boolean preserveDimensions, boolean preserveAttributes) { - super(preserveNames, preserveDimensions, preserveAttributes); + this(preserveNames, preserveDimensions, preserveAttributes, false); + } + + protected CastToAttributableNode(boolean preserveNames, boolean preserveDimensions, boolean preserveAttributes, boolean forRFFI) { + super(preserveNames, preserveDimensions, preserveAttributes, forRFFI); } @Override diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/CastToContainerNode.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/CastToContainerNode.java index 6446fb5726c4ac08915478f269ab4f1d5c101378..383e4adb83981d2687459d79f18864669741aa4e 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/CastToContainerNode.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/CastToContainerNode.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 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 @@ -36,7 +36,11 @@ public abstract class CastToContainerNode extends CastBaseNode { public abstract Object executeObject(Object value); protected CastToContainerNode(boolean preserveNames, boolean preserveDimensions, boolean preserveAttributes) { - super(preserveNames, preserveDimensions, preserveAttributes); + this(preserveNames, preserveDimensions, preserveAttributes, false); + } + + protected CastToContainerNode(boolean preserveNames, boolean preserveDimensions, boolean preserveAttributes, boolean forRFFI) { + super(preserveNames, preserveDimensions, preserveAttributes, forRFFI); } @Override diff --git a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/RError.java b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/RError.java index 58bc36b5d7dca83785af1de7a2e8441c12996c05..da3597e88002595c1b56624f8bdbc740d118adca 100644 --- a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/RError.java +++ b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/RError.java @@ -236,6 +236,7 @@ public final class RError extends RuntimeException { */ GENERIC("%s"), TOO_SHORT("'%s' is too short"), + INVALID_DATA_OF_TYPE_TOO_SHORT("invalid data of mode '%s' (too short)"), VECTOR_SIZE_TOO_LARGE("vector size specified is too large"), ARG_RECYCYLED("an argument will be fractionally recycled"), LENGTH_GT_1("the condition has length > 1 and only the first element will be used"), @@ -454,6 +455,7 @@ public final class RError extends RuntimeException { INVALID_SUBSCRIPT_TYPE("invalid subscript type '%s'"), ARGUMENT_NOT_VECTOR("argument %d is not a vector"), CANNOT_COERCE("cannot coerce type '%s' to vector of type '%s'"), + CANNOT_COERCE_RFFI("(%s) object cannot be coerced to type '%s'"), ARGUMENT_ONLY_FIRST("argument '%s' has length > 1 and only the first element will be used"), ARGUMENT_ONLY_FIRST_1("only the first element of '%s' argument used"), ARGUMENT_WRONG_LENGTH("wrong length for argument"), @@ -741,7 +743,6 @@ public final class RError extends RuntimeException { QUIT_INVALID_STATUS("invalid 'status', 0 assumed"), QUIT_INVALID_RUNLAST("invalid 'runLast', FALSE assumed"), ENVIRONMENTS_COERCE("environments cannot be coerced to other types"), - CLOSURE_COERCE("cannot coerce type 'closure' to vector of type 'integer'"), ROWSUM_NAMES_NOT_CHAR("row names are not character"), ROWSUM_NON_NUMERIC("non-numeric matrix in rowsum(): this should not happen"), ARGUMENTS_REQUIRED_COUNT("%d arguments to '%s' which requires %d"), diff --git a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/data/RVector.java b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/data/RVector.java index e40efafa8eb52cfaef95ee52765ad52b2f30401d..e5e7d62026859376ee80d452416cc5d7a00c15be 100644 --- a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/data/RVector.java +++ b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/data/RVector.java @@ -22,6 +22,8 @@ */ package com.oracle.truffle.r.runtime.data; +import static com.oracle.truffle.r.runtime.RError.NO_CALLER; + import java.util.function.Function; import com.oracle.truffle.api.CompilerAsserts; @@ -472,7 +474,7 @@ public abstract class RVector<ArrayT> extends RSharingAttributeStorage implement @Override public final void setDimensions(int[] newDimensions) { - setDimensions(newDimensions, null); + setDimensions(newDimensions, NO_CALLER); } private void setDimensions(int[] newDimensions, RBaseNode invokingNode) { diff --git a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/ffi/StdUpCallsRFFI.java b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/ffi/StdUpCallsRFFI.java index e8b7a6294030c9e16d23c90328684fbe490c7686..3d96124a1cae1cfce8e8af31608e92dd60bbc9a6 100644 --- a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/ffi/StdUpCallsRFFI.java +++ b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/ffi/StdUpCallsRFFI.java @@ -63,6 +63,8 @@ public interface StdUpCallsRFFI { Object Rf_asChar(Object x); + Object Rf_coerceVector(Object x, int mode); + Object Rf_mkCharLenCE(@RFFICstring Object bytes, int len, int encoding); Object Rf_cons(Object car, Object cdr); diff --git a/com.oracle.truffle.r.test.native/packages/testrffi/testrffi/R/testrffi.R b/com.oracle.truffle.r.test.native/packages/testrffi/testrffi/R/testrffi.R index d482babaaccb3273a41e04bbd89879c250c25ad2..93443593a81e7a51e33ea5635caad97d4aff06e2 100644 --- a/com.oracle.truffle.r.test.native/packages/testrffi/testrffi/R/testrffi.R +++ b/com.oracle.truffle.r.test.native/packages/testrffi/testrffi/R/testrffi.R @@ -153,3 +153,6 @@ rffi.LENGTH <- function(x) { .Call("test_LENGTH", x) } +rffi.coerceVector <- function(x, mode) { + .Call("test_coerceVector", x, mode) +} diff --git a/com.oracle.truffle.r.test.native/packages/testrffi/testrffi/src/init.c b/com.oracle.truffle.r.test.native/packages/testrffi/testrffi/src/init.c index 8ac5196404c7c117a757160d193864554b728259..cf78dd91c91aba55acf21084125944ee749566bd 100644 --- a/com.oracle.truffle.r.test.native/packages/testrffi/testrffi/src/init.c +++ b/com.oracle.truffle.r.test.native/packages/testrffi/testrffi/src/init.c @@ -33,39 +33,40 @@ static const R_CMethodDef CEntries[] = { #define CALLDEF(name, n) {#name, (DL_FUNC) &name, n} static const R_CallMethodDef CallEntries[] = { - CALLDEF(addInt, 2), - CALLDEF(addDouble, 2), - CALLDEF(populateIntVector, 1), - CALLDEF(populateLogicalVector, 1), - CALLDEF(createExternalPtr, 3), - CALLDEF(getExternalPtrAddr, 1), - CALLDEF(invoke_TYPEOF, 1), - CALLDEF(invoke_error, 1), - CALLDEF(dot_external_access_args, 1), - CALLDEF(invoke_isString, 1), - CALLDEF(invoke12, 12), - CALLDEF(interactive, 0), - CALLDEF(tryEval, 2), - CALLDEF(rHomeDir, 0), - CALLDEF(nestedCall1, 2), - CALLDEF(nestedCall2, 1), - CALLDEF(r_home, 0), - CALLDEF(mkStringFromChar, 0), - CALLDEF(mkStringFromBytes, 0), - CALLDEF(null, 0), - CALLDEF(iterate_iarray, 1), - CALLDEF(iterate_iptr, 1), - CALLDEF(preserve_object, 0), - CALLDEF(release_object, 1), - CALLDEF(findvar, 2), - CALLDEF(test_asReal, 1), - CALLDEF(test_asChar, 1), - CALLDEF(test_asInteger, 1), - CALLDEF(test_asLogical, 1), - CALLDEF(test_CAR, 1), - CALLDEF(test_CDR, 1), - CALLDEF(test_LENGTH, 1), - {NULL, NULL, 0} + CALLDEF(addInt, 2), + CALLDEF(addDouble, 2), + CALLDEF(populateIntVector, 1), + CALLDEF(populateLogicalVector, 1), + CALLDEF(createExternalPtr, 3), + CALLDEF(getExternalPtrAddr, 1), + CALLDEF(invoke_TYPEOF, 1), + CALLDEF(invoke_error, 1), + CALLDEF(dot_external_access_args, 1), + CALLDEF(invoke_isString, 1), + CALLDEF(invoke12, 12), + CALLDEF(interactive, 0), + CALLDEF(tryEval, 2), + CALLDEF(rHomeDir, 0), + CALLDEF(nestedCall1, 2), + CALLDEF(nestedCall2, 1), + CALLDEF(r_home, 0), + CALLDEF(mkStringFromChar, 0), + CALLDEF(mkStringFromBytes, 0), + CALLDEF(null, 0), + CALLDEF(iterate_iarray, 1), + CALLDEF(iterate_iptr, 1), + CALLDEF(preserve_object, 0), + CALLDEF(release_object, 1), + CALLDEF(findvar, 2), + CALLDEF(test_asReal, 1), + CALLDEF(test_asChar, 1), + CALLDEF(test_asInteger, 1), + CALLDEF(test_asLogical, 1), + CALLDEF(test_CAR, 1), + CALLDEF(test_CDR, 1), + CALLDEF(test_LENGTH, 1), + CALLDEF(test_coerceVector, 2), + {NULL, NULL, 0} }; void diff --git a/com.oracle.truffle.r.test.native/packages/testrffi/testrffi/src/testrffi.c b/com.oracle.truffle.r.test.native/packages/testrffi/testrffi/src/testrffi.c index e15a466e947a7acb2f3ce0dfd7515e354afee256..364653bd0d88d9e00c2bf5d8f42d489068749663 100644 --- a/com.oracle.truffle.r.test.native/packages/testrffi/testrffi/src/testrffi.c +++ b/com.oracle.truffle.r.test.native/packages/testrffi/testrffi/src/testrffi.c @@ -317,3 +317,9 @@ SEXP test_CDR(SEXP x) { SEXP test_LENGTH(SEXP x) { return ScalarInteger(LENGTH(x)); } + +SEXP test_coerceVector(SEXP x, SEXP mode) { + int intMode = INTEGER_VALUE(mode); + return Rf_coerceVector(x, intMode); +} + diff --git a/com.oracle.truffle.r.test.native/packages/testrffi/testrffi/src/testrffi.h b/com.oracle.truffle.r.test.native/packages/testrffi/testrffi/src/testrffi.h index 040107cedf1d35e934248ce635cd3f95d11e355c..1787b056454851783af719ead163b9b21f1aab60 100644 --- a/com.oracle.truffle.r.test.native/packages/testrffi/testrffi/src/testrffi.h +++ b/com.oracle.truffle.r.test.native/packages/testrffi/testrffi/src/testrffi.h @@ -86,3 +86,5 @@ extern SEXP test_CDR(SEXP x); extern SEXP test_LENGTH(SEXP x); +extern SEXP test_coerceVector(SEXP x, SEXP mode); + 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 a3561e1ed91a693aa25ce508c92a7f4fb8704cc3..366264daa34980cb3909e3aed54f68207321fb9f 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 @@ -6970,6 +6970,12 @@ Warning messages: 1: NAs introduced by coercion 2: out-of-range values treated as 0 in coercion to raw +##com.oracle.truffle.r.test.builtins.TestBuiltin_asraw.testAsRaw#Output.IgnoreWarningContext# +#{ as.raw('10000001') } +[1] 00 +Warning message: +out-of-range values treated as 0 in coercion to raw + ##com.oracle.truffle.r.test.builtins.TestBuiltin_asraw.testAsRaw#Output.IgnoreWarningContext# #{ as.raw(-1) } [1] 00 @@ -7010,6 +7016,12 @@ out-of-range values treated as 0 in coercion to raw #{ as.raw(NULL) } raw(0) +##com.oracle.truffle.r.test.builtins.TestBuiltin_asraw.testAsRaw#Output.IgnoreWarningContext# +#{ as.raw(c('10000001', '42')) } +[1] 00 2a +Warning message: +out-of-range values treated as 0 in coercion to raw + ##com.oracle.truffle.r.test.builtins.TestBuiltin_asraw.testAsRaw#Output.IgnoreWarningContext# #{ as.raw(c(1+3i, -2-1i, NA)) } [1] 01 00 00 @@ -139455,6 +139467,795 @@ Error in .Call("null", PACKAGE = "foo") : #{ library("testrffi", lib.loc = "tmptest/com.oracle.truffle.r.test.rpackages"); a <- c(1L,2L,3L); x <- rffi.iterate_iarray(a); detach("package:testrffi", unload=T); x } [1] 1 2 3 +##com.oracle.truffle.r.test.rffi.TestRFFIPackageCoercions.testCoerceVector#Output.MayIgnoreWarningContext#Output.MayIgnoreErrorContext# +#{ library('testrffi', lib.loc = 'tmptest/com.oracle.truffle.r.test.rpackages'); x <- rffi.coerceVector(1L, 0); detach('package:testrffi', unload=T); x } +Error in rffi.coerceVector(1L, 0) : + cannot coerce type 'integer' to vector of type 'NULL' + +##com.oracle.truffle.r.test.rffi.TestRFFIPackageCoercions.testCoerceVector#Output.MayIgnoreWarningContext#Output.MayIgnoreErrorContext# +#{ library('testrffi', lib.loc = 'tmptest/com.oracle.truffle.r.test.rpackages'); x <- rffi.coerceVector(1L, 1); detach('package:testrffi', unload=T); x } +`1` + +##com.oracle.truffle.r.test.rffi.TestRFFIPackageCoercions.testCoerceVector#Output.MayIgnoreWarningContext#Output.MayIgnoreErrorContext# +#{ library('testrffi', lib.loc = 'tmptest/com.oracle.truffle.r.test.rpackages'); x <- rffi.coerceVector(1L, 10); detach('package:testrffi', unload=T); x } +[1] TRUE + +##com.oracle.truffle.r.test.rffi.TestRFFIPackageCoercions.testCoerceVector#Output.MayIgnoreWarningContext#Output.MayIgnoreErrorContext# +#{ library('testrffi', lib.loc = 'tmptest/com.oracle.truffle.r.test.rpackages'); x <- rffi.coerceVector(1L, 13); detach('package:testrffi', unload=T); x } +[1] 1 + +##com.oracle.truffle.r.test.rffi.TestRFFIPackageCoercions.testCoerceVector#Output.MayIgnoreWarningContext#Output.MayIgnoreErrorContext# +#{ library('testrffi', lib.loc = 'tmptest/com.oracle.truffle.r.test.rpackages'); x <- rffi.coerceVector(1L, 14); detach('package:testrffi', unload=T); x } +[1] 1 + +##com.oracle.truffle.r.test.rffi.TestRFFIPackageCoercions.testCoerceVector#Output.MayIgnoreWarningContext#Output.MayIgnoreErrorContext# +#{ library('testrffi', lib.loc = 'tmptest/com.oracle.truffle.r.test.rpackages'); x <- rffi.coerceVector(1L, 15); detach('package:testrffi', unload=T); x } +[1] 1+0i + +##com.oracle.truffle.r.test.rffi.TestRFFIPackageCoercions.testCoerceVector#Output.MayIgnoreWarningContext#Output.MayIgnoreErrorContext# +#{ library('testrffi', lib.loc = 'tmptest/com.oracle.truffle.r.test.rpackages'); x <- rffi.coerceVector(1L, 16); detach('package:testrffi', unload=T); x } +[1] "1" + +##com.oracle.truffle.r.test.rffi.TestRFFIPackageCoercions.testCoerceVector#Output.MayIgnoreWarningContext#Output.MayIgnoreErrorContext# +#{ library('testrffi', lib.loc = 'tmptest/com.oracle.truffle.r.test.rpackages'); x <- rffi.coerceVector(1L, 19); detach('package:testrffi', unload=T); x } +[[1]] +[1] 1 + + +##com.oracle.truffle.r.test.rffi.TestRFFIPackageCoercions.testCoerceVector#Output.MayIgnoreWarningContext#Output.MayIgnoreErrorContext# +#{ library('testrffi', lib.loc = 'tmptest/com.oracle.truffle.r.test.rpackages'); x <- rffi.coerceVector(1L, 24); detach('package:testrffi', unload=T); x } +[1] 01 + +##com.oracle.truffle.r.test.rffi.TestRFFIPackageCoercions.testCoerceVector#Output.MayIgnoreWarningContext#Output.MayIgnoreErrorContext# +#{ library('testrffi', lib.loc = 'tmptest/com.oracle.truffle.r.test.rpackages'); x <- rffi.coerceVector(2, 0); detach('package:testrffi', unload=T); x } +Error in rffi.coerceVector(2, 0) : + cannot coerce type 'double' to vector of type 'NULL' + +##com.oracle.truffle.r.test.rffi.TestRFFIPackageCoercions.testCoerceVector#Output.MayIgnoreWarningContext#Output.MayIgnoreErrorContext# +#{ library('testrffi', lib.loc = 'tmptest/com.oracle.truffle.r.test.rpackages'); x <- rffi.coerceVector(2, 1); detach('package:testrffi', unload=T); x } +`2` + +##com.oracle.truffle.r.test.rffi.TestRFFIPackageCoercions.testCoerceVector#Output.MayIgnoreWarningContext#Output.MayIgnoreErrorContext# +#{ library('testrffi', lib.loc = 'tmptest/com.oracle.truffle.r.test.rpackages'); x <- rffi.coerceVector(2, 10); detach('package:testrffi', unload=T); x } +[1] TRUE + +##com.oracle.truffle.r.test.rffi.TestRFFIPackageCoercions.testCoerceVector#Output.MayIgnoreWarningContext#Output.MayIgnoreErrorContext# +#{ library('testrffi', lib.loc = 'tmptest/com.oracle.truffle.r.test.rpackages'); x <- rffi.coerceVector(2, 13); detach('package:testrffi', unload=T); x } +[1] 2 + +##com.oracle.truffle.r.test.rffi.TestRFFIPackageCoercions.testCoerceVector#Output.MayIgnoreWarningContext#Output.MayIgnoreErrorContext# +#{ library('testrffi', lib.loc = 'tmptest/com.oracle.truffle.r.test.rpackages'); x <- rffi.coerceVector(2, 14); detach('package:testrffi', unload=T); x } +[1] 2 + +##com.oracle.truffle.r.test.rffi.TestRFFIPackageCoercions.testCoerceVector#Output.MayIgnoreWarningContext#Output.MayIgnoreErrorContext# +#{ library('testrffi', lib.loc = 'tmptest/com.oracle.truffle.r.test.rpackages'); x <- rffi.coerceVector(2, 15); detach('package:testrffi', unload=T); x } +[1] 2+0i + +##com.oracle.truffle.r.test.rffi.TestRFFIPackageCoercions.testCoerceVector#Output.MayIgnoreWarningContext#Output.MayIgnoreErrorContext# +#{ library('testrffi', lib.loc = 'tmptest/com.oracle.truffle.r.test.rpackages'); x <- rffi.coerceVector(2, 16); detach('package:testrffi', unload=T); x } +[1] "2" + +##com.oracle.truffle.r.test.rffi.TestRFFIPackageCoercions.testCoerceVector#Output.MayIgnoreWarningContext#Output.MayIgnoreErrorContext# +#{ library('testrffi', lib.loc = 'tmptest/com.oracle.truffle.r.test.rpackages'); x <- rffi.coerceVector(2, 19); detach('package:testrffi', unload=T); x } +[[1]] +[1] 2 + + +##com.oracle.truffle.r.test.rffi.TestRFFIPackageCoercions.testCoerceVector#Output.MayIgnoreWarningContext#Output.MayIgnoreErrorContext# +#{ library('testrffi', lib.loc = 'tmptest/com.oracle.truffle.r.test.rpackages'); x <- rffi.coerceVector(2, 24); detach('package:testrffi', unload=T); x } +[1] 02 + +##com.oracle.truffle.r.test.rffi.TestRFFIPackageCoercions.testCoerceVector#Output.MayIgnoreWarningContext#Output.MayIgnoreErrorContext# +#{ library('testrffi', lib.loc = 'tmptest/com.oracle.truffle.r.test.rpackages'); x <- rffi.coerceVector(2.2, 0); detach('package:testrffi', unload=T); x } +Error in rffi.coerceVector(2.2, 0) : + cannot coerce type 'double' to vector of type 'NULL' + +##com.oracle.truffle.r.test.rffi.TestRFFIPackageCoercions.testCoerceVector#Output.MayIgnoreWarningContext#Output.MayIgnoreErrorContext# +#{ library('testrffi', lib.loc = 'tmptest/com.oracle.truffle.r.test.rpackages'); x <- rffi.coerceVector(2.2, 1); detach('package:testrffi', unload=T); x } +`2.2` + +##com.oracle.truffle.r.test.rffi.TestRFFIPackageCoercions.testCoerceVector#Output.MayIgnoreWarningContext#Output.MayIgnoreErrorContext# +#{ library('testrffi', lib.loc = 'tmptest/com.oracle.truffle.r.test.rpackages'); x <- rffi.coerceVector(2.2, 10); detach('package:testrffi', unload=T); x } +[1] TRUE + +##com.oracle.truffle.r.test.rffi.TestRFFIPackageCoercions.testCoerceVector#Output.MayIgnoreWarningContext#Output.MayIgnoreErrorContext# +#{ library('testrffi', lib.loc = 'tmptest/com.oracle.truffle.r.test.rpackages'); x <- rffi.coerceVector(2.2, 13); detach('package:testrffi', unload=T); x } +[1] 2 + +##com.oracle.truffle.r.test.rffi.TestRFFIPackageCoercions.testCoerceVector#Output.MayIgnoreWarningContext#Output.MayIgnoreErrorContext# +#{ library('testrffi', lib.loc = 'tmptest/com.oracle.truffle.r.test.rpackages'); x <- rffi.coerceVector(2.2, 14); detach('package:testrffi', unload=T); x } +[1] 2.2 + +##com.oracle.truffle.r.test.rffi.TestRFFIPackageCoercions.testCoerceVector#Output.MayIgnoreWarningContext#Output.MayIgnoreErrorContext# +#{ library('testrffi', lib.loc = 'tmptest/com.oracle.truffle.r.test.rpackages'); x <- rffi.coerceVector(2.2, 15); detach('package:testrffi', unload=T); x } +[1] 2.2+0i + +##com.oracle.truffle.r.test.rffi.TestRFFIPackageCoercions.testCoerceVector#Output.MayIgnoreWarningContext#Output.MayIgnoreErrorContext# +#{ library('testrffi', lib.loc = 'tmptest/com.oracle.truffle.r.test.rpackages'); x <- rffi.coerceVector(2.2, 16); detach('package:testrffi', unload=T); x } +[1] "2.2" + +##com.oracle.truffle.r.test.rffi.TestRFFIPackageCoercions.testCoerceVector#Output.MayIgnoreWarningContext#Output.MayIgnoreErrorContext# +#{ library('testrffi', lib.loc = 'tmptest/com.oracle.truffle.r.test.rpackages'); x <- rffi.coerceVector(2.2, 19); detach('package:testrffi', unload=T); x } +[[1]] +[1] 2.2 + + +##com.oracle.truffle.r.test.rffi.TestRFFIPackageCoercions.testCoerceVector#Output.MayIgnoreWarningContext#Output.MayIgnoreErrorContext# +#{ library('testrffi', lib.loc = 'tmptest/com.oracle.truffle.r.test.rpackages'); x <- rffi.coerceVector(2.2, 24); detach('package:testrffi', unload=T); x } +[1] 02 + +##com.oracle.truffle.r.test.rffi.TestRFFIPackageCoercions.testCoerceVector#Output.MayIgnoreWarningContext#Output.MayIgnoreErrorContext# +#{ library('testrffi', lib.loc = 'tmptest/com.oracle.truffle.r.test.rpackages'); x <- rffi.coerceVector(T, 0); detach('package:testrffi', unload=T); x } +Error in rffi.coerceVector(T, 0) : + cannot coerce type 'logical' to vector of type 'NULL' + +##com.oracle.truffle.r.test.rffi.TestRFFIPackageCoercions.testCoerceVector#Output.MayIgnoreWarningContext#Output.MayIgnoreErrorContext# +#{ library('testrffi', lib.loc = 'tmptest/com.oracle.truffle.r.test.rpackages'); x <- rffi.coerceVector(T, 1); detach('package:testrffi', unload=T); x } +`TRUE` + +##com.oracle.truffle.r.test.rffi.TestRFFIPackageCoercions.testCoerceVector#Output.MayIgnoreWarningContext#Output.MayIgnoreErrorContext# +#{ library('testrffi', lib.loc = 'tmptest/com.oracle.truffle.r.test.rpackages'); x <- rffi.coerceVector(T, 10); detach('package:testrffi', unload=T); x } +[1] TRUE + +##com.oracle.truffle.r.test.rffi.TestRFFIPackageCoercions.testCoerceVector#Output.MayIgnoreWarningContext#Output.MayIgnoreErrorContext# +#{ library('testrffi', lib.loc = 'tmptest/com.oracle.truffle.r.test.rpackages'); x <- rffi.coerceVector(T, 13); detach('package:testrffi', unload=T); x } +[1] 1 + +##com.oracle.truffle.r.test.rffi.TestRFFIPackageCoercions.testCoerceVector#Output.MayIgnoreWarningContext#Output.MayIgnoreErrorContext# +#{ library('testrffi', lib.loc = 'tmptest/com.oracle.truffle.r.test.rpackages'); x <- rffi.coerceVector(T, 14); detach('package:testrffi', unload=T); x } +[1] 1 + +##com.oracle.truffle.r.test.rffi.TestRFFIPackageCoercions.testCoerceVector#Output.MayIgnoreWarningContext#Output.MayIgnoreErrorContext# +#{ library('testrffi', lib.loc = 'tmptest/com.oracle.truffle.r.test.rpackages'); x <- rffi.coerceVector(T, 15); detach('package:testrffi', unload=T); x } +[1] 1+0i + +##com.oracle.truffle.r.test.rffi.TestRFFIPackageCoercions.testCoerceVector#Output.MayIgnoreWarningContext#Output.MayIgnoreErrorContext# +#{ library('testrffi', lib.loc = 'tmptest/com.oracle.truffle.r.test.rpackages'); x <- rffi.coerceVector(T, 16); detach('package:testrffi', unload=T); x } +[1] "TRUE" + +##com.oracle.truffle.r.test.rffi.TestRFFIPackageCoercions.testCoerceVector#Output.MayIgnoreWarningContext#Output.MayIgnoreErrorContext# +#{ library('testrffi', lib.loc = 'tmptest/com.oracle.truffle.r.test.rpackages'); x <- rffi.coerceVector(T, 19); detach('package:testrffi', unload=T); x } +[[1]] +[1] TRUE + + +##com.oracle.truffle.r.test.rffi.TestRFFIPackageCoercions.testCoerceVector#Output.MayIgnoreWarningContext#Output.MayIgnoreErrorContext# +#{ library('testrffi', lib.loc = 'tmptest/com.oracle.truffle.r.test.rpackages'); x <- rffi.coerceVector(T, 24); detach('package:testrffi', unload=T); x } +[1] 01 + +##com.oracle.truffle.r.test.rffi.TestRFFIPackageCoercions.testCoerceVector#Output.MayIgnoreWarningContext#Output.MayIgnoreErrorContext# +#{ library('testrffi', lib.loc = 'tmptest/com.oracle.truffle.r.test.rpackages'); x <- rffi.coerceVector(c(2.3, 3.4), 0); detach('package:testrffi', unload=T); x } +Error in rffi.coerceVector(c(2.3, 3.4), 0) : + cannot coerce type 'double' to vector of type 'NULL' + +##com.oracle.truffle.r.test.rffi.TestRFFIPackageCoercions.testCoerceVector#Output.MayIgnoreWarningContext#Output.MayIgnoreErrorContext# +#{ library('testrffi', lib.loc = 'tmptest/com.oracle.truffle.r.test.rpackages'); x <- rffi.coerceVector(c(2.3, 3.4), 1); detach('package:testrffi', unload=T); x } +`2.3` + +##com.oracle.truffle.r.test.rffi.TestRFFIPackageCoercions.testCoerceVector#Output.MayIgnoreWarningContext#Output.MayIgnoreErrorContext# +#{ library('testrffi', lib.loc = 'tmptest/com.oracle.truffle.r.test.rpackages'); x <- rffi.coerceVector(c(2.3, 3.4), 10); detach('package:testrffi', unload=T); x } +[1] TRUE TRUE + +##com.oracle.truffle.r.test.rffi.TestRFFIPackageCoercions.testCoerceVector#Output.MayIgnoreWarningContext#Output.MayIgnoreErrorContext# +#{ library('testrffi', lib.loc = 'tmptest/com.oracle.truffle.r.test.rpackages'); x <- rffi.coerceVector(c(2.3, 3.4), 13); detach('package:testrffi', unload=T); x } +[1] 2 3 + +##com.oracle.truffle.r.test.rffi.TestRFFIPackageCoercions.testCoerceVector#Output.MayIgnoreWarningContext#Output.MayIgnoreErrorContext# +#{ library('testrffi', lib.loc = 'tmptest/com.oracle.truffle.r.test.rpackages'); x <- rffi.coerceVector(c(2.3, 3.4), 14); detach('package:testrffi', unload=T); x } +[1] 2.3 3.4 + +##com.oracle.truffle.r.test.rffi.TestRFFIPackageCoercions.testCoerceVector#Output.MayIgnoreWarningContext#Output.MayIgnoreErrorContext# +#{ library('testrffi', lib.loc = 'tmptest/com.oracle.truffle.r.test.rpackages'); x <- rffi.coerceVector(c(2.3, 3.4), 15); detach('package:testrffi', unload=T); x } +[1] 2.3+0i 3.4+0i + +##com.oracle.truffle.r.test.rffi.TestRFFIPackageCoercions.testCoerceVector#Output.MayIgnoreWarningContext#Output.MayIgnoreErrorContext# +#{ library('testrffi', lib.loc = 'tmptest/com.oracle.truffle.r.test.rpackages'); x <- rffi.coerceVector(c(2.3, 3.4), 16); detach('package:testrffi', unload=T); x } +[1] "2.3" "3.4" + +##com.oracle.truffle.r.test.rffi.TestRFFIPackageCoercions.testCoerceVector#Output.MayIgnoreWarningContext#Output.MayIgnoreErrorContext# +#{ library('testrffi', lib.loc = 'tmptest/com.oracle.truffle.r.test.rpackages'); x <- rffi.coerceVector(c(2.3, 3.4), 19); detach('package:testrffi', unload=T); x } +[[1]] +[1] 2.3 + +[[2]] +[1] 3.4 + + +##com.oracle.truffle.r.test.rffi.TestRFFIPackageCoercions.testCoerceVector#Output.MayIgnoreWarningContext#Output.MayIgnoreErrorContext# +#{ library('testrffi', lib.loc = 'tmptest/com.oracle.truffle.r.test.rpackages'); x <- rffi.coerceVector(c(2.3, 3.4), 24); detach('package:testrffi', unload=T); x } +[1] 02 03 + +##com.oracle.truffle.r.test.rffi.TestRFFIPackageCoercions.testCoerceVector#Output.MayIgnoreWarningContext#Output.MayIgnoreErrorContext# +#{ library('testrffi', lib.loc = 'tmptest/com.oracle.truffle.r.test.rpackages'); x <- rffi.coerceVector(c(5,6), 0); detach('package:testrffi', unload=T); x } +Error in rffi.coerceVector(c(5, 6), 0) : + cannot coerce type 'double' to vector of type 'NULL' + +##com.oracle.truffle.r.test.rffi.TestRFFIPackageCoercions.testCoerceVector#Output.MayIgnoreWarningContext#Output.MayIgnoreErrorContext# +#{ library('testrffi', lib.loc = 'tmptest/com.oracle.truffle.r.test.rpackages'); x <- rffi.coerceVector(c(5,6), 1); detach('package:testrffi', unload=T); x } +`5` + +##com.oracle.truffle.r.test.rffi.TestRFFIPackageCoercions.testCoerceVector#Output.MayIgnoreWarningContext#Output.MayIgnoreErrorContext# +#{ library('testrffi', lib.loc = 'tmptest/com.oracle.truffle.r.test.rpackages'); x <- rffi.coerceVector(c(5,6), 10); detach('package:testrffi', unload=T); x } +[1] TRUE TRUE + +##com.oracle.truffle.r.test.rffi.TestRFFIPackageCoercions.testCoerceVector#Output.MayIgnoreWarningContext#Output.MayIgnoreErrorContext# +#{ library('testrffi', lib.loc = 'tmptest/com.oracle.truffle.r.test.rpackages'); x <- rffi.coerceVector(c(5,6), 13); detach('package:testrffi', unload=T); x } +[1] 5 6 + +##com.oracle.truffle.r.test.rffi.TestRFFIPackageCoercions.testCoerceVector#Output.MayIgnoreWarningContext#Output.MayIgnoreErrorContext# +#{ library('testrffi', lib.loc = 'tmptest/com.oracle.truffle.r.test.rpackages'); x <- rffi.coerceVector(c(5,6), 14); detach('package:testrffi', unload=T); x } +[1] 5 6 + +##com.oracle.truffle.r.test.rffi.TestRFFIPackageCoercions.testCoerceVector#Output.MayIgnoreWarningContext#Output.MayIgnoreErrorContext# +#{ library('testrffi', lib.loc = 'tmptest/com.oracle.truffle.r.test.rpackages'); x <- rffi.coerceVector(c(5,6), 15); detach('package:testrffi', unload=T); x } +[1] 5+0i 6+0i + +##com.oracle.truffle.r.test.rffi.TestRFFIPackageCoercions.testCoerceVector#Output.MayIgnoreWarningContext#Output.MayIgnoreErrorContext# +#{ library('testrffi', lib.loc = 'tmptest/com.oracle.truffle.r.test.rpackages'); x <- rffi.coerceVector(c(5,6), 16); detach('package:testrffi', unload=T); x } +[1] "5" "6" + +##com.oracle.truffle.r.test.rffi.TestRFFIPackageCoercions.testCoerceVector#Output.MayIgnoreWarningContext#Output.MayIgnoreErrorContext# +#{ library('testrffi', lib.loc = 'tmptest/com.oracle.truffle.r.test.rpackages'); x <- rffi.coerceVector(c(5,6), 19); detach('package:testrffi', unload=T); x } +[[1]] +[1] 5 + +[[2]] +[1] 6 + + +##com.oracle.truffle.r.test.rffi.TestRFFIPackageCoercions.testCoerceVector#Output.MayIgnoreWarningContext#Output.MayIgnoreErrorContext# +#{ library('testrffi', lib.loc = 'tmptest/com.oracle.truffle.r.test.rpackages'); x <- rffi.coerceVector(c(5,6), 24); detach('package:testrffi', unload=T); x } +[1] 05 06 + +##com.oracle.truffle.r.test.rffi.TestRFFIPackageCoercions.testCoerceVector#Output.MayIgnoreWarningContext#Output.MayIgnoreErrorContext# +#{ library('testrffi', lib.loc = 'tmptest/com.oracle.truffle.r.test.rpackages'); x <- rffi.coerceVector(c(T, F), 0); detach('package:testrffi', unload=T); x } +Error in rffi.coerceVector(c(T, F), 0) : + cannot coerce type 'logical' to vector of type 'NULL' + +##com.oracle.truffle.r.test.rffi.TestRFFIPackageCoercions.testCoerceVector#Output.MayIgnoreWarningContext#Output.MayIgnoreErrorContext# +#{ library('testrffi', lib.loc = 'tmptest/com.oracle.truffle.r.test.rpackages'); x <- rffi.coerceVector(c(T, F), 1); detach('package:testrffi', unload=T); x } +`TRUE` + +##com.oracle.truffle.r.test.rffi.TestRFFIPackageCoercions.testCoerceVector#Output.MayIgnoreWarningContext#Output.MayIgnoreErrorContext# +#{ library('testrffi', lib.loc = 'tmptest/com.oracle.truffle.r.test.rpackages'); x <- rffi.coerceVector(c(T, F), 10); detach('package:testrffi', unload=T); x } +[1] TRUE FALSE + +##com.oracle.truffle.r.test.rffi.TestRFFIPackageCoercions.testCoerceVector#Output.MayIgnoreWarningContext#Output.MayIgnoreErrorContext# +#{ library('testrffi', lib.loc = 'tmptest/com.oracle.truffle.r.test.rpackages'); x <- rffi.coerceVector(c(T, F), 13); detach('package:testrffi', unload=T); x } +[1] 1 0 + +##com.oracle.truffle.r.test.rffi.TestRFFIPackageCoercions.testCoerceVector#Output.MayIgnoreWarningContext#Output.MayIgnoreErrorContext# +#{ library('testrffi', lib.loc = 'tmptest/com.oracle.truffle.r.test.rpackages'); x <- rffi.coerceVector(c(T, F), 14); detach('package:testrffi', unload=T); x } +[1] 1 0 + +##com.oracle.truffle.r.test.rffi.TestRFFIPackageCoercions.testCoerceVector#Output.MayIgnoreWarningContext#Output.MayIgnoreErrorContext# +#{ library('testrffi', lib.loc = 'tmptest/com.oracle.truffle.r.test.rpackages'); x <- rffi.coerceVector(c(T, F), 15); detach('package:testrffi', unload=T); x } +[1] 1+0i 0+0i + +##com.oracle.truffle.r.test.rffi.TestRFFIPackageCoercions.testCoerceVector#Output.MayIgnoreWarningContext#Output.MayIgnoreErrorContext# +#{ library('testrffi', lib.loc = 'tmptest/com.oracle.truffle.r.test.rpackages'); x <- rffi.coerceVector(c(T, F), 16); detach('package:testrffi', unload=T); x } +[1] "TRUE" "FALSE" + +##com.oracle.truffle.r.test.rffi.TestRFFIPackageCoercions.testCoerceVector#Output.MayIgnoreWarningContext#Output.MayIgnoreErrorContext# +#{ library('testrffi', lib.loc = 'tmptest/com.oracle.truffle.r.test.rpackages'); x <- rffi.coerceVector(c(T, F), 19); detach('package:testrffi', unload=T); x } +[[1]] +[1] TRUE + +[[2]] +[1] FALSE + + +##com.oracle.truffle.r.test.rffi.TestRFFIPackageCoercions.testCoerceVector#Output.MayIgnoreWarningContext#Output.MayIgnoreErrorContext# +#{ library('testrffi', lib.loc = 'tmptest/com.oracle.truffle.r.test.rpackages'); x <- rffi.coerceVector(c(T, F), 24); detach('package:testrffi', unload=T); x } +[1] 01 00 + +##com.oracle.truffle.r.test.rffi.TestRFFIPackageCoercions.testCoerceVector#Output.MayIgnoreWarningContext#Output.MayIgnoreErrorContext# +#{ library('testrffi', lib.loc = 'tmptest/com.oracle.truffle.r.test.rpackages'); x <- rffi.coerceVector(character(), 0); detach('package:testrffi', unload=T); x } +Error in rffi.coerceVector(character(), 0) : + cannot coerce type 'character' to vector of type 'NULL' + +##com.oracle.truffle.r.test.rffi.TestRFFIPackageCoercions.testCoerceVector#Output.MayIgnoreWarningContext#Output.MayIgnoreErrorContext# +#{ library('testrffi', lib.loc = 'tmptest/com.oracle.truffle.r.test.rpackages'); x <- rffi.coerceVector(character(), 1); detach('package:testrffi', unload=T); x } +Error in rffi.coerceVector(character(), 1) : + invalid data of mode 'character' (too short) + +##com.oracle.truffle.r.test.rffi.TestRFFIPackageCoercions.testCoerceVector#Output.MayIgnoreWarningContext#Output.MayIgnoreErrorContext# +#{ library('testrffi', lib.loc = 'tmptest/com.oracle.truffle.r.test.rpackages'); x <- rffi.coerceVector(character(), 10); detach('package:testrffi', unload=T); x } +logical(0) + +##com.oracle.truffle.r.test.rffi.TestRFFIPackageCoercions.testCoerceVector#Output.MayIgnoreWarningContext#Output.MayIgnoreErrorContext# +#{ library('testrffi', lib.loc = 'tmptest/com.oracle.truffle.r.test.rpackages'); x <- rffi.coerceVector(character(), 13); detach('package:testrffi', unload=T); x } +integer(0) + +##com.oracle.truffle.r.test.rffi.TestRFFIPackageCoercions.testCoerceVector#Output.MayIgnoreWarningContext#Output.MayIgnoreErrorContext# +#{ library('testrffi', lib.loc = 'tmptest/com.oracle.truffle.r.test.rpackages'); x <- rffi.coerceVector(character(), 14); detach('package:testrffi', unload=T); x } +numeric(0) + +##com.oracle.truffle.r.test.rffi.TestRFFIPackageCoercions.testCoerceVector#Output.MayIgnoreWarningContext#Output.MayIgnoreErrorContext# +#{ library('testrffi', lib.loc = 'tmptest/com.oracle.truffle.r.test.rpackages'); x <- rffi.coerceVector(character(), 15); detach('package:testrffi', unload=T); x } +complex(0) + +##com.oracle.truffle.r.test.rffi.TestRFFIPackageCoercions.testCoerceVector#Output.MayIgnoreWarningContext#Output.MayIgnoreErrorContext# +#{ library('testrffi', lib.loc = 'tmptest/com.oracle.truffle.r.test.rpackages'); x <- rffi.coerceVector(character(), 16); detach('package:testrffi', unload=T); x } +character(0) + +##com.oracle.truffle.r.test.rffi.TestRFFIPackageCoercions.testCoerceVector#Output.MayIgnoreWarningContext#Output.MayIgnoreErrorContext# +#{ library('testrffi', lib.loc = 'tmptest/com.oracle.truffle.r.test.rpackages'); x <- rffi.coerceVector(character(), 19); detach('package:testrffi', unload=T); x } +list() + +##com.oracle.truffle.r.test.rffi.TestRFFIPackageCoercions.testCoerceVector#Output.MayIgnoreWarningContext#Output.MayIgnoreErrorContext# +#{ library('testrffi', lib.loc = 'tmptest/com.oracle.truffle.r.test.rpackages'); x <- rffi.coerceVector(character(), 24); detach('package:testrffi', unload=T); x } +raw(0) + +##com.oracle.truffle.r.test.rffi.TestRFFIPackageCoercions.testCoerceVector#Output.MayIgnoreWarningContext#Output.MayIgnoreErrorContext# +#{ library('testrffi', lib.loc = 'tmptest/com.oracle.truffle.r.test.rpackages'); x <- rffi.coerceVector(integer(), 0); detach('package:testrffi', unload=T); x } +Error in rffi.coerceVector(integer(), 0) : + cannot coerce type 'integer' to vector of type 'NULL' + +##com.oracle.truffle.r.test.rffi.TestRFFIPackageCoercions.testCoerceVector#Output.MayIgnoreWarningContext#Output.MayIgnoreErrorContext# +#{ library('testrffi', lib.loc = 'tmptest/com.oracle.truffle.r.test.rpackages'); x <- rffi.coerceVector(integer(), 1); detach('package:testrffi', unload=T); x } +Error in rffi.coerceVector(integer(), 1) : + invalid data of mode 'integer' (too short) + +##com.oracle.truffle.r.test.rffi.TestRFFIPackageCoercions.testCoerceVector#Output.MayIgnoreWarningContext#Output.MayIgnoreErrorContext# +#{ library('testrffi', lib.loc = 'tmptest/com.oracle.truffle.r.test.rpackages'); x <- rffi.coerceVector(integer(), 10); detach('package:testrffi', unload=T); x } +logical(0) + +##com.oracle.truffle.r.test.rffi.TestRFFIPackageCoercions.testCoerceVector#Output.MayIgnoreWarningContext#Output.MayIgnoreErrorContext# +#{ library('testrffi', lib.loc = 'tmptest/com.oracle.truffle.r.test.rpackages'); x <- rffi.coerceVector(integer(), 13); detach('package:testrffi', unload=T); x } +integer(0) + +##com.oracle.truffle.r.test.rffi.TestRFFIPackageCoercions.testCoerceVector#Output.MayIgnoreWarningContext#Output.MayIgnoreErrorContext# +#{ library('testrffi', lib.loc = 'tmptest/com.oracle.truffle.r.test.rpackages'); x <- rffi.coerceVector(integer(), 14); detach('package:testrffi', unload=T); x } +numeric(0) + +##com.oracle.truffle.r.test.rffi.TestRFFIPackageCoercions.testCoerceVector#Output.MayIgnoreWarningContext#Output.MayIgnoreErrorContext# +#{ library('testrffi', lib.loc = 'tmptest/com.oracle.truffle.r.test.rpackages'); x <- rffi.coerceVector(integer(), 15); detach('package:testrffi', unload=T); x } +complex(0) + +##com.oracle.truffle.r.test.rffi.TestRFFIPackageCoercions.testCoerceVector#Output.MayIgnoreWarningContext#Output.MayIgnoreErrorContext# +#{ library('testrffi', lib.loc = 'tmptest/com.oracle.truffle.r.test.rpackages'); x <- rffi.coerceVector(integer(), 16); detach('package:testrffi', unload=T); x } +character(0) + +##com.oracle.truffle.r.test.rffi.TestRFFIPackageCoercions.testCoerceVector#Output.MayIgnoreWarningContext#Output.MayIgnoreErrorContext# +#{ library('testrffi', lib.loc = 'tmptest/com.oracle.truffle.r.test.rpackages'); x <- rffi.coerceVector(integer(), 19); detach('package:testrffi', unload=T); x } +list() + +##com.oracle.truffle.r.test.rffi.TestRFFIPackageCoercions.testCoerceVector#Output.MayIgnoreWarningContext#Output.MayIgnoreErrorContext# +#{ library('testrffi', lib.loc = 'tmptest/com.oracle.truffle.r.test.rpackages'); x <- rffi.coerceVector(integer(), 24); detach('package:testrffi', unload=T); x } +raw(0) + +##com.oracle.truffle.r.test.rffi.TestRFFIPackageCoercions.testCoerceVector#Output.MayIgnoreWarningContext#Output.MayIgnoreErrorContext# +#{ library('testrffi', lib.loc = 'tmptest/com.oracle.truffle.r.test.rpackages'); x <- rffi.coerceVector(list(), 0); detach('package:testrffi', unload=T); x } +Error in rffi.coerceVector(list(), 0) : + unimplemented type 'list' in 'coerceVectorList' + +##com.oracle.truffle.r.test.rffi.TestRFFIPackageCoercions.testCoerceVector#Output.MayIgnoreWarningContext#Output.MayIgnoreErrorContext# +#{ library('testrffi', lib.loc = 'tmptest/com.oracle.truffle.r.test.rpackages'); x <- rffi.coerceVector(list(), 1); detach('package:testrffi', unload=T); x } +Error in rffi.coerceVector(list(), 1) : + invalid type/length (symbol/0) in vector allocation + +##com.oracle.truffle.r.test.rffi.TestRFFIPackageCoercions.testCoerceVector#Output.MayIgnoreWarningContext#Output.MayIgnoreErrorContext# +#{ library('testrffi', lib.loc = 'tmptest/com.oracle.truffle.r.test.rpackages'); x <- rffi.coerceVector(list(), 10); detach('package:testrffi', unload=T); x } +logical(0) + +##com.oracle.truffle.r.test.rffi.TestRFFIPackageCoercions.testCoerceVector#Output.MayIgnoreWarningContext#Output.MayIgnoreErrorContext# +#{ library('testrffi', lib.loc = 'tmptest/com.oracle.truffle.r.test.rpackages'); x <- rffi.coerceVector(list(), 13); detach('package:testrffi', unload=T); x } +integer(0) + +##com.oracle.truffle.r.test.rffi.TestRFFIPackageCoercions.testCoerceVector#Output.MayIgnoreWarningContext#Output.MayIgnoreErrorContext# +#{ library('testrffi', lib.loc = 'tmptest/com.oracle.truffle.r.test.rpackages'); x <- rffi.coerceVector(list(), 14); detach('package:testrffi', unload=T); x } +numeric(0) + +##com.oracle.truffle.r.test.rffi.TestRFFIPackageCoercions.testCoerceVector#Output.MayIgnoreWarningContext#Output.MayIgnoreErrorContext# +#{ library('testrffi', lib.loc = 'tmptest/com.oracle.truffle.r.test.rpackages'); x <- rffi.coerceVector(list(), 15); detach('package:testrffi', unload=T); x } +complex(0) + +##com.oracle.truffle.r.test.rffi.TestRFFIPackageCoercions.testCoerceVector#Output.MayIgnoreWarningContext#Output.MayIgnoreErrorContext# +#{ library('testrffi', lib.loc = 'tmptest/com.oracle.truffle.r.test.rpackages'); x <- rffi.coerceVector(list(), 16); detach('package:testrffi', unload=T); x } +character(0) + +##com.oracle.truffle.r.test.rffi.TestRFFIPackageCoercions.testCoerceVector#Output.MayIgnoreWarningContext#Output.MayIgnoreErrorContext# +#{ library('testrffi', lib.loc = 'tmptest/com.oracle.truffle.r.test.rpackages'); x <- rffi.coerceVector(list(), 19); detach('package:testrffi', unload=T); x } +list() + +##com.oracle.truffle.r.test.rffi.TestRFFIPackageCoercions.testCoerceVector#Output.MayIgnoreWarningContext#Output.MayIgnoreErrorContext# +#{ library('testrffi', lib.loc = 'tmptest/com.oracle.truffle.r.test.rpackages'); x <- rffi.coerceVector(list(), 24); detach('package:testrffi', unload=T); x } +raw(0) + +##com.oracle.truffle.r.test.rffi.TestRFFIPackageCoercions.testCoerceVector#Output.MayIgnoreWarningContext#Output.MayIgnoreErrorContext# +#{ library('testrffi', lib.loc = 'tmptest/com.oracle.truffle.r.test.rpackages'); x <- rffi.coerceVector(logical(), 0); detach('package:testrffi', unload=T); x } +Error in rffi.coerceVector(logical(), 0) : + cannot coerce type 'logical' to vector of type 'NULL' + +##com.oracle.truffle.r.test.rffi.TestRFFIPackageCoercions.testCoerceVector#Output.MayIgnoreWarningContext#Output.MayIgnoreErrorContext# +#{ library('testrffi', lib.loc = 'tmptest/com.oracle.truffle.r.test.rpackages'); x <- rffi.coerceVector(logical(), 1); detach('package:testrffi', unload=T); x } +Error in rffi.coerceVector(logical(), 1) : + invalid data of mode 'logical' (too short) + +##com.oracle.truffle.r.test.rffi.TestRFFIPackageCoercions.testCoerceVector#Output.MayIgnoreWarningContext#Output.MayIgnoreErrorContext# +#{ library('testrffi', lib.loc = 'tmptest/com.oracle.truffle.r.test.rpackages'); x <- rffi.coerceVector(logical(), 10); detach('package:testrffi', unload=T); x } +logical(0) + +##com.oracle.truffle.r.test.rffi.TestRFFIPackageCoercions.testCoerceVector#Output.MayIgnoreWarningContext#Output.MayIgnoreErrorContext# +#{ library('testrffi', lib.loc = 'tmptest/com.oracle.truffle.r.test.rpackages'); x <- rffi.coerceVector(logical(), 13); detach('package:testrffi', unload=T); x } +integer(0) + +##com.oracle.truffle.r.test.rffi.TestRFFIPackageCoercions.testCoerceVector#Output.MayIgnoreWarningContext#Output.MayIgnoreErrorContext# +#{ library('testrffi', lib.loc = 'tmptest/com.oracle.truffle.r.test.rpackages'); x <- rffi.coerceVector(logical(), 14); detach('package:testrffi', unload=T); x } +numeric(0) + +##com.oracle.truffle.r.test.rffi.TestRFFIPackageCoercions.testCoerceVector#Output.MayIgnoreWarningContext#Output.MayIgnoreErrorContext# +#{ library('testrffi', lib.loc = 'tmptest/com.oracle.truffle.r.test.rpackages'); x <- rffi.coerceVector(logical(), 15); detach('package:testrffi', unload=T); x } +complex(0) + +##com.oracle.truffle.r.test.rffi.TestRFFIPackageCoercions.testCoerceVector#Output.MayIgnoreWarningContext#Output.MayIgnoreErrorContext# +#{ library('testrffi', lib.loc = 'tmptest/com.oracle.truffle.r.test.rpackages'); x <- rffi.coerceVector(logical(), 16); detach('package:testrffi', unload=T); x } +character(0) + +##com.oracle.truffle.r.test.rffi.TestRFFIPackageCoercions.testCoerceVector#Output.MayIgnoreWarningContext#Output.MayIgnoreErrorContext# +#{ library('testrffi', lib.loc = 'tmptest/com.oracle.truffle.r.test.rpackages'); x <- rffi.coerceVector(logical(), 19); detach('package:testrffi', unload=T); x } +list() + +##com.oracle.truffle.r.test.rffi.TestRFFIPackageCoercions.testCoerceVector#Output.MayIgnoreWarningContext#Output.MayIgnoreErrorContext# +#{ library('testrffi', lib.loc = 'tmptest/com.oracle.truffle.r.test.rpackages'); x <- rffi.coerceVector(logical(), 24); detach('package:testrffi', unload=T); x } +raw(0) + +##com.oracle.truffle.r.test.rffi.TestRFFIPackageCoercions.testCoerceVector#Output.MayIgnoreWarningContext#Output.MayIgnoreErrorContext# +#{ library('testrffi', lib.loc = 'tmptest/com.oracle.truffle.r.test.rpackages'); x <- rffi.coerceVector(numeric(), 0); detach('package:testrffi', unload=T); x } +Error in rffi.coerceVector(numeric(), 0) : + cannot coerce type 'double' to vector of type 'NULL' + +##com.oracle.truffle.r.test.rffi.TestRFFIPackageCoercions.testCoerceVector#Output.MayIgnoreWarningContext#Output.MayIgnoreErrorContext# +#{ library('testrffi', lib.loc = 'tmptest/com.oracle.truffle.r.test.rpackages'); x <- rffi.coerceVector(numeric(), 1); detach('package:testrffi', unload=T); x } +Error in rffi.coerceVector(numeric(), 1) : + invalid data of mode 'double' (too short) + +##com.oracle.truffle.r.test.rffi.TestRFFIPackageCoercions.testCoerceVector#Output.MayIgnoreWarningContext#Output.MayIgnoreErrorContext# +#{ library('testrffi', lib.loc = 'tmptest/com.oracle.truffle.r.test.rpackages'); x <- rffi.coerceVector(numeric(), 10); detach('package:testrffi', unload=T); x } +logical(0) + +##com.oracle.truffle.r.test.rffi.TestRFFIPackageCoercions.testCoerceVector#Output.MayIgnoreWarningContext#Output.MayIgnoreErrorContext# +#{ library('testrffi', lib.loc = 'tmptest/com.oracle.truffle.r.test.rpackages'); x <- rffi.coerceVector(numeric(), 13); detach('package:testrffi', unload=T); x } +integer(0) + +##com.oracle.truffle.r.test.rffi.TestRFFIPackageCoercions.testCoerceVector#Output.MayIgnoreWarningContext#Output.MayIgnoreErrorContext# +#{ library('testrffi', lib.loc = 'tmptest/com.oracle.truffle.r.test.rpackages'); x <- rffi.coerceVector(numeric(), 14); detach('package:testrffi', unload=T); x } +numeric(0) + +##com.oracle.truffle.r.test.rffi.TestRFFIPackageCoercions.testCoerceVector#Output.MayIgnoreWarningContext#Output.MayIgnoreErrorContext# +#{ library('testrffi', lib.loc = 'tmptest/com.oracle.truffle.r.test.rpackages'); x <- rffi.coerceVector(numeric(), 15); detach('package:testrffi', unload=T); x } +complex(0) + +##com.oracle.truffle.r.test.rffi.TestRFFIPackageCoercions.testCoerceVector#Output.MayIgnoreWarningContext#Output.MayIgnoreErrorContext# +#{ library('testrffi', lib.loc = 'tmptest/com.oracle.truffle.r.test.rpackages'); x <- rffi.coerceVector(numeric(), 16); detach('package:testrffi', unload=T); x } +character(0) + +##com.oracle.truffle.r.test.rffi.TestRFFIPackageCoercions.testCoerceVector#Output.MayIgnoreWarningContext#Output.MayIgnoreErrorContext# +#{ library('testrffi', lib.loc = 'tmptest/com.oracle.truffle.r.test.rpackages'); x <- rffi.coerceVector(numeric(), 19); detach('package:testrffi', unload=T); x } +list() + +##com.oracle.truffle.r.test.rffi.TestRFFIPackageCoercions.testCoerceVector#Output.MayIgnoreWarningContext#Output.MayIgnoreErrorContext# +#{ library('testrffi', lib.loc = 'tmptest/com.oracle.truffle.r.test.rpackages'); x <- rffi.coerceVector(numeric(), 24); detach('package:testrffi', unload=T); x } +raw(0) + +##com.oracle.truffle.r.test.rffi.TestRFFIPackageCoercions.testCoerceVector#Output.MayIgnoreWarningContext#Output.MayIgnoreErrorContext# +#{ library('testrffi', lib.loc = 'tmptest/com.oracle.truffle.r.test.rpackages'); x <- rffi.coerceVector(structure(1L,names='a',dim=c(1,1),myattr='q'), 0); detach('package:testrffi', unload=T); x } +Error in rffi.coerceVector(structure(1L, names = "a", dim = c(1, 1), myattr = "q"), : + cannot coerce type 'integer' to vector of type 'NULL' + +##com.oracle.truffle.r.test.rffi.TestRFFIPackageCoercions.testCoerceVector#Output.MayIgnoreWarningContext#Output.MayIgnoreErrorContext# +#{ library('testrffi', lib.loc = 'tmptest/com.oracle.truffle.r.test.rpackages'); x <- rffi.coerceVector(structure(1L,names='a',dim=c(1,1),myattr='q'), 1); detach('package:testrffi', unload=T); x } +`1` + +##com.oracle.truffle.r.test.rffi.TestRFFIPackageCoercions.testCoerceVector#Output.MayIgnoreWarningContext#Output.MayIgnoreErrorContext# +#{ library('testrffi', lib.loc = 'tmptest/com.oracle.truffle.r.test.rpackages'); x <- rffi.coerceVector(structure(1L,names='a',dim=c(1,1),myattr='q'), 10); detach('package:testrffi', unload=T); x } + [,1] +[1,] TRUE +attr(,"names") +[1] "a" +attr(,"myattr") +[1] "q" + +##com.oracle.truffle.r.test.rffi.TestRFFIPackageCoercions.testCoerceVector#Output.MayIgnoreWarningContext#Output.MayIgnoreErrorContext# +#{ library('testrffi', lib.loc = 'tmptest/com.oracle.truffle.r.test.rpackages'); x <- rffi.coerceVector(structure(1L,names='a',dim=c(1,1),myattr='q'), 13); detach('package:testrffi', unload=T); x } + [,1] +[1,] 1 +attr(,"names") +[1] "a" +attr(,"myattr") +[1] "q" + +##com.oracle.truffle.r.test.rffi.TestRFFIPackageCoercions.testCoerceVector#Output.MayIgnoreWarningContext#Output.MayIgnoreErrorContext# +#{ library('testrffi', lib.loc = 'tmptest/com.oracle.truffle.r.test.rpackages'); x <- rffi.coerceVector(structure(1L,names='a',dim=c(1,1),myattr='q'), 14); detach('package:testrffi', unload=T); x } + [,1] +[1,] 1 +attr(,"names") +[1] "a" +attr(,"myattr") +[1] "q" + +##com.oracle.truffle.r.test.rffi.TestRFFIPackageCoercions.testCoerceVector#Output.MayIgnoreWarningContext#Output.MayIgnoreErrorContext# +#{ library('testrffi', lib.loc = 'tmptest/com.oracle.truffle.r.test.rpackages'); x <- rffi.coerceVector(structure(1L,names='a',dim=c(1,1),myattr='q'), 15); detach('package:testrffi', unload=T); x } + [,1] +[1,] 1+0i +attr(,"names") +[1] "a" +attr(,"myattr") +[1] "q" + +##com.oracle.truffle.r.test.rffi.TestRFFIPackageCoercions.testCoerceVector#Output.MayIgnoreWarningContext#Output.MayIgnoreErrorContext# +#{ library('testrffi', lib.loc = 'tmptest/com.oracle.truffle.r.test.rpackages'); x <- rffi.coerceVector(structure(1L,names='a',dim=c(1,1),myattr='q'), 16); detach('package:testrffi', unload=T); x } + [,1] +[1,] "1" +attr(,"names") +[1] "a" +attr(,"myattr") +[1] "q" + +##com.oracle.truffle.r.test.rffi.TestRFFIPackageCoercions.testCoerceVector#Output.MayIgnoreWarningContext#Output.MayIgnoreErrorContext# +#{ library('testrffi', lib.loc = 'tmptest/com.oracle.truffle.r.test.rpackages'); x <- rffi.coerceVector(structure(1L,names='a',dim=c(1,1),myattr='q'), 19); detach('package:testrffi', unload=T); x } +$a +[1] 1 + + +##com.oracle.truffle.r.test.rffi.TestRFFIPackageCoercions.testCoerceVector#Output.MayIgnoreWarningContext#Output.MayIgnoreErrorContext# +#{ library('testrffi', lib.loc = 'tmptest/com.oracle.truffle.r.test.rpackages'); x <- rffi.coerceVector(structure(1L,names='a',dim=c(1,1),myattr='q'), 24); detach('package:testrffi', unload=T); x } + [,1] +[1,] 01 +attr(,"names") +[1] "a" +attr(,"myattr") +[1] "q" + +##com.oracle.truffle.r.test.rffi.TestRFFIPackageCoercions.testCoerceVector#Output.MayIgnoreWarningContext#Output.MayIgnoreErrorContext# +#{ library('testrffi', lib.loc = 'tmptest/com.oracle.truffle.r.test.rpackages'); x <- rffi.coerceVector(structure(2.2, names='b',dim=c(1,1),myattr='q'), 0); detach('package:testrffi', unload=T); x } +Error in rffi.coerceVector(structure(2.2, names = "b", dim = c(1, 1), : + cannot coerce type 'double' to vector of type 'NULL' + +##com.oracle.truffle.r.test.rffi.TestRFFIPackageCoercions.testCoerceVector#Output.MayIgnoreWarningContext#Output.MayIgnoreErrorContext# +#{ library('testrffi', lib.loc = 'tmptest/com.oracle.truffle.r.test.rpackages'); x <- rffi.coerceVector(structure(2.2, names='b',dim=c(1,1),myattr='q'), 1); detach('package:testrffi', unload=T); x } +`2.2` + +##com.oracle.truffle.r.test.rffi.TestRFFIPackageCoercions.testCoerceVector#Output.MayIgnoreWarningContext#Output.MayIgnoreErrorContext# +#{ library('testrffi', lib.loc = 'tmptest/com.oracle.truffle.r.test.rpackages'); x <- rffi.coerceVector(structure(2.2, names='b',dim=c(1,1),myattr='q'), 10); detach('package:testrffi', unload=T); x } + [,1] +[1,] TRUE +attr(,"names") +[1] "b" +attr(,"myattr") +[1] "q" + +##com.oracle.truffle.r.test.rffi.TestRFFIPackageCoercions.testCoerceVector#Output.MayIgnoreWarningContext#Output.MayIgnoreErrorContext# +#{ library('testrffi', lib.loc = 'tmptest/com.oracle.truffle.r.test.rpackages'); x <- rffi.coerceVector(structure(2.2, names='b',dim=c(1,1),myattr='q'), 13); detach('package:testrffi', unload=T); x } + [,1] +[1,] 2 +attr(,"names") +[1] "b" +attr(,"myattr") +[1] "q" + +##com.oracle.truffle.r.test.rffi.TestRFFIPackageCoercions.testCoerceVector#Output.MayIgnoreWarningContext#Output.MayIgnoreErrorContext# +#{ library('testrffi', lib.loc = 'tmptest/com.oracle.truffle.r.test.rpackages'); x <- rffi.coerceVector(structure(2.2, names='b',dim=c(1,1),myattr='q'), 14); detach('package:testrffi', unload=T); x } + [,1] +[1,] 2.2 +attr(,"names") +[1] "b" +attr(,"myattr") +[1] "q" + +##com.oracle.truffle.r.test.rffi.TestRFFIPackageCoercions.testCoerceVector#Output.MayIgnoreWarningContext#Output.MayIgnoreErrorContext# +#{ library('testrffi', lib.loc = 'tmptest/com.oracle.truffle.r.test.rpackages'); x <- rffi.coerceVector(structure(2.2, names='b',dim=c(1,1),myattr='q'), 15); detach('package:testrffi', unload=T); x } + [,1] +[1,] 2.2+0i +attr(,"names") +[1] "b" +attr(,"myattr") +[1] "q" + +##com.oracle.truffle.r.test.rffi.TestRFFIPackageCoercions.testCoerceVector#Output.MayIgnoreWarningContext#Output.MayIgnoreErrorContext# +#{ library('testrffi', lib.loc = 'tmptest/com.oracle.truffle.r.test.rpackages'); x <- rffi.coerceVector(structure(2.2, names='b',dim=c(1,1),myattr='q'), 16); detach('package:testrffi', unload=T); x } + [,1] +[1,] "2.2" +attr(,"names") +[1] "b" +attr(,"myattr") +[1] "q" + +##com.oracle.truffle.r.test.rffi.TestRFFIPackageCoercions.testCoerceVector#Output.MayIgnoreWarningContext#Output.MayIgnoreErrorContext# +#{ library('testrffi', lib.loc = 'tmptest/com.oracle.truffle.r.test.rpackages'); x <- rffi.coerceVector(structure(2.2, names='b',dim=c(1,1),myattr='q'), 19); detach('package:testrffi', unload=T); x } +$b +[1] 2.2 + + +##com.oracle.truffle.r.test.rffi.TestRFFIPackageCoercions.testCoerceVector#Output.MayIgnoreWarningContext#Output.MayIgnoreErrorContext# +#{ library('testrffi', lib.loc = 'tmptest/com.oracle.truffle.r.test.rpackages'); x <- rffi.coerceVector(structure(2.2, names='b',dim=c(1,1),myattr='q'), 24); detach('package:testrffi', unload=T); x } + [,1] +[1,] 02 +attr(,"names") +[1] "b" +attr(,"myattr") +[1] "q" + +##com.oracle.truffle.r.test.rffi.TestRFFIPackageCoercions.testCoerceVector#Output.MayIgnoreWarningContext#Output.MayIgnoreErrorContext# +#{ library('testrffi', lib.loc = 'tmptest/com.oracle.truffle.r.test.rpackages'); x <- rffi.coerceVector(structure(T, names='c',dim=c(1,1),myattr='q'), 0); detach('package:testrffi', unload=T); x } +Error in rffi.coerceVector(structure(T, names = "c", dim = c(1, 1), myattr = "q"), : + cannot coerce type 'logical' to vector of type 'NULL' + +##com.oracle.truffle.r.test.rffi.TestRFFIPackageCoercions.testCoerceVector#Output.MayIgnoreWarningContext#Output.MayIgnoreErrorContext# +#{ library('testrffi', lib.loc = 'tmptest/com.oracle.truffle.r.test.rpackages'); x <- rffi.coerceVector(structure(T, names='c',dim=c(1,1),myattr='q'), 1); detach('package:testrffi', unload=T); x } +`TRUE` + +##com.oracle.truffle.r.test.rffi.TestRFFIPackageCoercions.testCoerceVector#Output.MayIgnoreWarningContext#Output.MayIgnoreErrorContext# +#{ library('testrffi', lib.loc = 'tmptest/com.oracle.truffle.r.test.rpackages'); x <- rffi.coerceVector(structure(T, names='c',dim=c(1,1),myattr='q'), 10); detach('package:testrffi', unload=T); x } + [,1] +[1,] TRUE +attr(,"names") +[1] "c" +attr(,"myattr") +[1] "q" + +##com.oracle.truffle.r.test.rffi.TestRFFIPackageCoercions.testCoerceVector#Output.MayIgnoreWarningContext#Output.MayIgnoreErrorContext# +#{ library('testrffi', lib.loc = 'tmptest/com.oracle.truffle.r.test.rpackages'); x <- rffi.coerceVector(structure(T, names='c',dim=c(1,1),myattr='q'), 13); detach('package:testrffi', unload=T); x } + [,1] +[1,] 1 +attr(,"names") +[1] "c" +attr(,"myattr") +[1] "q" + +##com.oracle.truffle.r.test.rffi.TestRFFIPackageCoercions.testCoerceVector#Output.MayIgnoreWarningContext#Output.MayIgnoreErrorContext# +#{ library('testrffi', lib.loc = 'tmptest/com.oracle.truffle.r.test.rpackages'); x <- rffi.coerceVector(structure(T, names='c',dim=c(1,1),myattr='q'), 14); detach('package:testrffi', unload=T); x } + [,1] +[1,] 1 +attr(,"names") +[1] "c" +attr(,"myattr") +[1] "q" + +##com.oracle.truffle.r.test.rffi.TestRFFIPackageCoercions.testCoerceVector#Output.MayIgnoreWarningContext#Output.MayIgnoreErrorContext# +#{ library('testrffi', lib.loc = 'tmptest/com.oracle.truffle.r.test.rpackages'); x <- rffi.coerceVector(structure(T, names='c',dim=c(1,1),myattr='q'), 15); detach('package:testrffi', unload=T); x } + [,1] +[1,] 1+0i +attr(,"names") +[1] "c" +attr(,"myattr") +[1] "q" + +##com.oracle.truffle.r.test.rffi.TestRFFIPackageCoercions.testCoerceVector#Output.MayIgnoreWarningContext#Output.MayIgnoreErrorContext# +#{ library('testrffi', lib.loc = 'tmptest/com.oracle.truffle.r.test.rpackages'); x <- rffi.coerceVector(structure(T, names='c',dim=c(1,1),myattr='q'), 16); detach('package:testrffi', unload=T); x } + [,1] +[1,] "TRUE" +attr(,"names") +[1] "c" +attr(,"myattr") +[1] "q" + +##com.oracle.truffle.r.test.rffi.TestRFFIPackageCoercions.testCoerceVector#Output.MayIgnoreWarningContext#Output.MayIgnoreErrorContext# +#{ library('testrffi', lib.loc = 'tmptest/com.oracle.truffle.r.test.rpackages'); x <- rffi.coerceVector(structure(T, names='c',dim=c(1,1),myattr='q'), 19); detach('package:testrffi', unload=T); x } +$c +[1] TRUE + + +##com.oracle.truffle.r.test.rffi.TestRFFIPackageCoercions.testCoerceVector#Output.MayIgnoreWarningContext#Output.MayIgnoreErrorContext# +#{ library('testrffi', lib.loc = 'tmptest/com.oracle.truffle.r.test.rpackages'); x <- rffi.coerceVector(structure(T, names='c',dim=c(1,1),myattr='q'), 24); detach('package:testrffi', unload=T); x } + [,1] +[1,] 01 +attr(,"names") +[1] "c" +attr(,"myattr") +[1] "q" + +##com.oracle.truffle.r.test.rffi.TestRFFIPackageCoercions.testCoerceVector#Output.MayIgnoreWarningContext#Output.MayIgnoreErrorContext# +#{ library('testrffi', lib.loc = 'tmptest/com.oracle.truffle.r.test.rpackages'); x <- rffi.coerceVector(structure(list(1,'42'), names=c('q','w'),dim=c(2,1),myattr='q'), 0); detach('package:testrffi', unload=T); x } +Error in rffi.coerceVector(structure(list(1, "42"), names = c("q", "w"), : + unimplemented type 'list' in 'coerceVectorList' + +##com.oracle.truffle.r.test.rffi.TestRFFIPackageCoercions.testCoerceVector#Output.MayIgnoreWarningContext#Output.MayIgnoreErrorContext# +#{ library('testrffi', lib.loc = 'tmptest/com.oracle.truffle.r.test.rpackages'); x <- rffi.coerceVector(structure(list(1,'42'), names=c('q','w'),dim=c(2,1),myattr='q'), 1); detach('package:testrffi', unload=T); x } +Error in rffi.coerceVector(structure(list(1, "42"), names = c("q", "w"), : + invalid type/length (symbol/2) in vector allocation + +##com.oracle.truffle.r.test.rffi.TestRFFIPackageCoercions.testCoerceVector#Output.MayIgnoreWarningContext#Output.MayIgnoreErrorContext# +#{ library('testrffi', lib.loc = 'tmptest/com.oracle.truffle.r.test.rpackages'); x <- rffi.coerceVector(structure(list(1,'42'), names=c('q','w'),dim=c(2,1),myattr='q'), 10); detach('package:testrffi', unload=T); x } + q w +TRUE NA + +##com.oracle.truffle.r.test.rffi.TestRFFIPackageCoercions.testCoerceVector#Output.MayIgnoreWarningContext#Output.MayIgnoreErrorContext# +#{ library('testrffi', lib.loc = 'tmptest/com.oracle.truffle.r.test.rpackages'); x <- rffi.coerceVector(structure(list(1,'42'), names=c('q','w'),dim=c(2,1),myattr='q'), 13); detach('package:testrffi', unload=T); x } + q w + 1 42 + +##com.oracle.truffle.r.test.rffi.TestRFFIPackageCoercions.testCoerceVector#Output.MayIgnoreWarningContext#Output.MayIgnoreErrorContext# +#{ library('testrffi', lib.loc = 'tmptest/com.oracle.truffle.r.test.rpackages'); x <- rffi.coerceVector(structure(list(1,'42'), names=c('q','w'),dim=c(2,1),myattr='q'), 14); detach('package:testrffi', unload=T); x } + q w + 1 42 + +##com.oracle.truffle.r.test.rffi.TestRFFIPackageCoercions.testCoerceVector#Output.MayIgnoreWarningContext#Output.MayIgnoreErrorContext# +#{ library('testrffi', lib.loc = 'tmptest/com.oracle.truffle.r.test.rpackages'); x <- rffi.coerceVector(structure(list(1,'42'), names=c('q','w'),dim=c(2,1),myattr='q'), 15); detach('package:testrffi', unload=T); x } + q w + 1+0i 42+0i + +##com.oracle.truffle.r.test.rffi.TestRFFIPackageCoercions.testCoerceVector#Output.MayIgnoreWarningContext#Output.MayIgnoreErrorContext# +#{ library('testrffi', lib.loc = 'tmptest/com.oracle.truffle.r.test.rpackages'); x <- rffi.coerceVector(structure(list(1,'42'), names=c('q','w'),dim=c(2,1),myattr='q'), 16); detach('package:testrffi', unload=T); x } + q w + "1" "42" + +##com.oracle.truffle.r.test.rffi.TestRFFIPackageCoercions.testCoerceVector#Output.MayIgnoreWarningContext#Output.MayIgnoreErrorContext# +#{ library('testrffi', lib.loc = 'tmptest/com.oracle.truffle.r.test.rpackages'); x <- rffi.coerceVector(structure(list(1,'42'), names=c('q','w'),dim=c(2,1),myattr='q'), 19); detach('package:testrffi', unload=T); x } + [,1] +[1,] 1 +[2,] "42" +attr(,"names") +[1] "q" "w" +attr(,"myattr") +[1] "q" + +##com.oracle.truffle.r.test.rffi.TestRFFIPackageCoercions.testCoerceVector#Output.MayIgnoreWarningContext#Output.MayIgnoreErrorContext# +#{ library('testrffi', lib.loc = 'tmptest/com.oracle.truffle.r.test.rpackages'); x <- rffi.coerceVector(structure(list(1,'42'), names=c('q','w'),dim=c(2,1),myattr='q'), 24); detach('package:testrffi', unload=T); x } + q w +01 2a + +##com.oracle.truffle.r.test.rffi.TestRFFIPackageCoercions.testCoerceVectorToExpression#Output.IgnoreErrorMessage#Output.MayIgnoreWarningContext#Output.MayIgnoreErrorContext# +#{ library('testrffi', lib.loc = 'tmptest/com.oracle.truffle.r.test.rpackages'); x <- rffi.coerceVector(2, 20); detach('package:testrffi', unload=T); x } +expression(2) + +##com.oracle.truffle.r.test.rffi.TestRFFIPackageCoercions.testCoerceVectorToExpression#Output.IgnoreErrorMessage#Output.MayIgnoreWarningContext#Output.MayIgnoreErrorContext# +#{ library('testrffi', lib.loc = 'tmptest/com.oracle.truffle.r.test.rpackages'); x <- rffi.coerceVector(2.2, 20); detach('package:testrffi', unload=T); x } +expression(2.2) + +##com.oracle.truffle.r.test.rffi.TestRFFIPackageCoercions.testCoerceVectorToExpression#Output.IgnoreErrorMessage#Output.MayIgnoreWarningContext#Output.MayIgnoreErrorContext# +#{ library('testrffi', lib.loc = 'tmptest/com.oracle.truffle.r.test.rpackages'); x <- rffi.coerceVector(T, 20); detach('package:testrffi', unload=T); x } +expression(TRUE) + +##com.oracle.truffle.r.test.rffi.TestRFFIPackageCoercions.testCoerceVectorToExpression#Output.IgnoreErrorMessage#Output.MayIgnoreWarningContext#Output.MayIgnoreErrorContext# +#{ library('testrffi', lib.loc = 'tmptest/com.oracle.truffle.r.test.rpackages'); x <- rffi.coerceVector(c(2.3, 3.4), 20); detach('package:testrffi', unload=T); x } +expression(2.3, 3.4) + +##com.oracle.truffle.r.test.rffi.TestRFFIPackageCoercions.testCoerceVectorToExpression#Output.IgnoreErrorMessage#Output.MayIgnoreWarningContext#Output.MayIgnoreErrorContext# +#{ library('testrffi', lib.loc = 'tmptest/com.oracle.truffle.r.test.rpackages'); x <- rffi.coerceVector(c(5,6), 20); detach('package:testrffi', unload=T); x } +expression(5, 6) + +##com.oracle.truffle.r.test.rffi.TestRFFIPackageCoercions.testCoerceVectorToExpression#Output.IgnoreErrorMessage#Output.MayIgnoreWarningContext#Output.MayIgnoreErrorContext# +#{ library('testrffi', lib.loc = 'tmptest/com.oracle.truffle.r.test.rpackages'); x <- rffi.coerceVector(c(T, F), 20); detach('package:testrffi', unload=T); x } +expression(TRUE, FALSE) + +##com.oracle.truffle.r.test.rffi.TestRFFIPackageCoercions.testCoerceVectorToExpression#Output.IgnoreErrorMessage#Output.MayIgnoreWarningContext#Output.MayIgnoreErrorContext# +#{ library('testrffi', lib.loc = 'tmptest/com.oracle.truffle.r.test.rpackages'); x <- rffi.coerceVector(character(), 20); detach('package:testrffi', unload=T); x } +expression() + +##com.oracle.truffle.r.test.rffi.TestRFFIPackageCoercions.testCoerceVectorToExpression#Output.IgnoreErrorMessage#Output.MayIgnoreWarningContext#Output.MayIgnoreErrorContext# +#{ library('testrffi', lib.loc = 'tmptest/com.oracle.truffle.r.test.rpackages'); x <- rffi.coerceVector(integer(), 20); detach('package:testrffi', unload=T); x } +expression() + +##com.oracle.truffle.r.test.rffi.TestRFFIPackageCoercions.testCoerceVectorToExpression#Output.IgnoreErrorMessage#Output.MayIgnoreWarningContext#Output.MayIgnoreErrorContext# +#{ library('testrffi', lib.loc = 'tmptest/com.oracle.truffle.r.test.rpackages'); x <- rffi.coerceVector(list(), 20); detach('package:testrffi', unload=T); x } +expression() + +##com.oracle.truffle.r.test.rffi.TestRFFIPackageCoercions.testCoerceVectorToExpression#Output.IgnoreErrorMessage#Output.MayIgnoreWarningContext#Output.MayIgnoreErrorContext# +#{ library('testrffi', lib.loc = 'tmptest/com.oracle.truffle.r.test.rpackages'); x <- rffi.coerceVector(logical(), 20); detach('package:testrffi', unload=T); x } +expression() + +##com.oracle.truffle.r.test.rffi.TestRFFIPackageCoercions.testCoerceVectorToExpression#Output.IgnoreErrorMessage#Output.MayIgnoreWarningContext#Output.MayIgnoreErrorContext# +#{ library('testrffi', lib.loc = 'tmptest/com.oracle.truffle.r.test.rpackages'); x <- rffi.coerceVector(numeric(), 20); detach('package:testrffi', unload=T); x } +expression() + +##com.oracle.truffle.r.test.rffi.TestRFFIPackageCoercions.testCoerceVectorToExpression#Output.IgnoreErrorMessage#Output.MayIgnoreWarningContext#Output.MayIgnoreErrorContext# +#{ library('testrffi', lib.loc = 'tmptest/com.oracle.truffle.r.test.rpackages'); x <- rffi.coerceVector(structure(2.2, names='b',dim=c(1,1),myattr='q'), 20); detach('package:testrffi', unload=T); x } +expression(2.2) + +##com.oracle.truffle.r.test.rffi.TestRFFIPackageCoercions.testCoerceVectorToExpression#Output.IgnoreErrorMessage#Output.MayIgnoreWarningContext#Output.MayIgnoreErrorContext# +#{ library('testrffi', lib.loc = 'tmptest/com.oracle.truffle.r.test.rpackages'); x <- rffi.coerceVector(structure(T, names='c',dim=c(1,1),myattr='q'), 20); detach('package:testrffi', unload=T); x } +expression(TRUE) + +##com.oracle.truffle.r.test.rffi.TestRFFIPackageCoercions.testCoerceVectorToExpression#Ignored.Unimplemented# +#{ library('testrffi', lib.loc = 'tmptest/com.oracle.truffle.r.test.rpackages'); x <- rffi.coerceVector(structure(list(1,'x'), names=c('q','w'),dim=c(2,1),myattr='q'), 20); detach('package:testrffi', unload=T); x } +expression(q = 1, w = "x") +attr(,"names") +[1] "q" "w" +attr(,"myattr") +[1] "q" + ##com.oracle.truffle.r.test.rffi.TestUserRNG.testUserRNG# #{ dyn.load("com.oracle.truffle.r.test.native/urand/lib/liburand.so"); RNGkind("user"); print(RNGkind()); set.seed(4567); runif(10) } [1] "user-supplied" "Inversion" diff --git a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/builtins/TestBuiltin_asraw.java b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/builtins/TestBuiltin_asraw.java index 0de508e8b10e1ccbc7d53677626bc09affe760d6..cd7d0198a34beb1d9641563e31ec0d82da549305 100644 --- a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/builtins/TestBuiltin_asraw.java +++ b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/builtins/TestBuiltin_asraw.java @@ -4,7 +4,7 @@ * http://www.gnu.org/licenses/gpl-2.0.html * * Copyright (c) 2012-2014, Purdue University - * Copyright (c) 2013, 2016, Oracle and/or its affiliates + * Copyright (c) 2013, 2017, Oracle and/or its affiliates * * All rights reserved. */ @@ -68,5 +68,7 @@ public class TestBuiltin_asraw extends TestBase { assertEval(Output.IgnoreWarningContext, "{ as.raw(c(1,1000,NA)) }"); assertEval(Output.IgnoreWarningContext, "{ as.raw(c(1L, -2L, 3L)) }"); assertEval(Output.IgnoreWarningContext, "{ as.raw(c(1L, -2L, NA)) }"); + assertEval(Output.IgnoreWarningContext, "{ as.raw('10000001') }"); + assertEval(Output.IgnoreWarningContext, "{ as.raw(c('10000001', '42')) }"); } } diff --git a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/rffi/TestRFFIPackageCoercions.java b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/rffi/TestRFFIPackageCoercions.java new file mode 100644 index 0000000000000000000000000000000000000000..9bff0cf831b4f59dbd62acecb6dbf88ab4c820fc --- /dev/null +++ b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/rffi/TestRFFIPackageCoercions.java @@ -0,0 +1,90 @@ +/* + * Copyright (c) 2014, 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.rffi; + +import static com.oracle.truffle.r.runtime.gnur.SEXPTYPE.CPLXSXP; +import static com.oracle.truffle.r.runtime.gnur.SEXPTYPE.EXPRSXP; +import static com.oracle.truffle.r.runtime.gnur.SEXPTYPE.INTSXP; +import static com.oracle.truffle.r.runtime.gnur.SEXPTYPE.LGLSXP; +import static com.oracle.truffle.r.runtime.gnur.SEXPTYPE.NILSXP; +import static com.oracle.truffle.r.runtime.gnur.SEXPTYPE.RAWSXP; +import static com.oracle.truffle.r.runtime.gnur.SEXPTYPE.REALSXP; +import static com.oracle.truffle.r.runtime.gnur.SEXPTYPE.STRSXP; +import static com.oracle.truffle.r.runtime.gnur.SEXPTYPE.SYMSXP; +import static com.oracle.truffle.r.runtime.gnur.SEXPTYPE.VECSXP; + +import java.util.Arrays; + +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Test; + +import com.oracle.truffle.r.runtime.gnur.SEXPTYPE; +import com.oracle.truffle.r.test.rpackages.TestRPackages; + +public class TestRFFIPackageCoercions extends TestRPackages { + + private static final String[] TEST_PACKAGES = new String[]{"testrffi"}; + + @BeforeClass + public static void setupInstallMyTestPackages() { + setupInstallTestPackages(TEST_PACKAGES); + } + + @AfterClass + public static void tearDownUninstallMyTestPackages() { + tearDownUninstallTestPackages(); + } + + private String addLib(String test) { + return "{ library('testrffi', lib.loc = '" + TestRPackages.libLoc() + "'); x <- " + test + "; detach('package:testrffi', unload=T); x }"; + } + + private static final String[] COERCION_VALUES_FOR_EXPR = new String[]{ + "2", "2.2", "T", "integer()", "numeric()", "logical()", "character()", "c(5,6)", "c(2.3, 3.4)", "c(T, F)", + "list()", "structure(2.2, names='b',dim=c(1,1),myattr='q')", "structure(T, names='c',dim=c(1,1),myattr='q')"}; + + private static final String[] COERCION_VALUES = new String[]{ + "1L", "2", "2.2", "T", "integer()", "numeric()", "logical()", "character()", "c(5,6)", "c(2.3, 3.4)", + "c(T, F)", "list()", "structure(1L,names='a',dim=c(1,1),myattr='q')", "structure(2.2, names='b',dim=c(1,1),myattr='q')", + "structure(T, names='c',dim=c(1,1),myattr='q')", "structure(list(1,'42'), names=c('q','w'),dim=c(2,1),myattr='q')"}; + + private static final SEXPTYPE[] COERCION_TYPES = new SEXPTYPE[]{SYMSXP, NILSXP, VECSXP, INTSXP, REALSXP, LGLSXP, STRSXP, CPLXSXP, RAWSXP}; + + private static final String[] COERCION_MODES = Arrays.stream(COERCION_TYPES).map(x -> Integer.toString(x.code)).toArray(n -> new String[n]); + + @Test + public void testCoerceVector() { + String[] tests = template(addLib("rffi.coerceVector(%0, %1)"), COERCION_VALUES, COERCION_MODES); + assertEval(Output.MayIgnoreWarningContext, Output.MayIgnoreErrorContext, tests); + } + + @Test + public void testCoerceVectorToExpression() { + // Note: inconsistency when printing expression(1L) FastR prints just "expression(1)" + String[] tests = template(addLib("rffi.coerceVector(%0, %1)"), COERCION_VALUES_FOR_EXPR, new String[]{Integer.toString(EXPRSXP.code)}); + assertEval(Output.IgnoreErrorMessage, Output.MayIgnoreWarningContext, Output.MayIgnoreErrorContext, tests); + // removes the attributes when its single value, but keeps them when it's a list + assertEval(Ignored.Unimplemented, addLib("rffi.coerceVector(structure(list(1,'x'), names=c('q','w'),dim=c(2,1),myattr='q'), " + EXPRSXP.code + ")")); + } +} diff --git a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/rpackages/TestRPackages.java b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/rpackages/TestRPackages.java index fbac0b3aa650ad25b002676895715b25e9db219b..40e4f8d269398f4b187a9d0983b319aa329d6bd0 100644 --- a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/rpackages/TestRPackages.java +++ b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/rpackages/TestRPackages.java @@ -164,6 +164,8 @@ public abstract class TestRPackages extends TestBase { } } + private boolean packagesInstallSuccess = true; + @Override public void beforeEval() { if (needsInstall) { @@ -177,11 +179,14 @@ public abstract class TestRPackages extends TestBase { System.out.printf(".pkg: %s.", p); PackagePath packagePath = getPackagePaths(p, resolver.getPath(p)); if (!installPackage(packagePath)) { + packagesInstallSuccess = false; Assert.fail(String.format("package %s failed to install", p)); } } System.out.printf(".end install."); } + // This makes sure that any consequent tests fail with informative error + Assert.assertTrue("Error during package installation process.", packagesInstallSuccess); } protected static void tearDownUninstallTestPackages() {