diff --git a/com.oracle.truffle.r.ffi.impl/src/com/oracle/truffle/r/ffi/impl/common/JavaUpCallsRFFIImpl.java b/com.oracle.truffle.r.ffi.impl/src/com/oracle/truffle/r/ffi/impl/common/JavaUpCallsRFFIImpl.java index 0fd2bf80d7febf8ed9d5b24c8dccc5a01cad255f..b73fac10a48f45e65171eed16e7b4aba01f21c94 100644 --- a/com.oracle.truffle.r.ffi.impl/src/com/oracle/truffle/r/ffi/impl/common/JavaUpCallsRFFIImpl.java +++ b/com.oracle.truffle.r.ffi.impl/src/com/oracle/truffle/r/ffi/impl/common/JavaUpCallsRFFIImpl.java @@ -1678,4 +1678,10 @@ public abstract class JavaUpCallsRFFIImpl implements UpCallsRFFI { private static RFFIContext getContext() { return RContext.getInstance().getStateRFFI(); } + + @Override + public Object Rf_match(Object itables, Object ix, int nmatch) { + throw implementedAsNode(); + } + } diff --git a/com.oracle.truffle.r.ffi.impl/src/com/oracle/truffle/r/ffi/impl/nodes/MiscNodes.java b/com.oracle.truffle.r.ffi.impl/src/com/oracle/truffle/r/ffi/impl/nodes/MiscNodes.java index 6d7d2f2c571aa8bfcf848a11ae41e5e9bf295a12..a643bc35e3c8e358c67eb523cb7c62fc059caf87 100644 --- a/com.oracle.truffle.r.ffi.impl/src/com/oracle/truffle/r/ffi/impl/nodes/MiscNodes.java +++ b/com.oracle.truffle.r.ffi.impl/src/com/oracle/truffle/r/ffi/impl/nodes/MiscNodes.java @@ -40,6 +40,7 @@ import com.oracle.truffle.r.nodes.objects.NewObject; import com.oracle.truffle.r.nodes.objects.NewObjectNodeGen; import com.oracle.truffle.r.runtime.RError; import com.oracle.truffle.r.runtime.data.CharSXPWrapper; +import com.oracle.truffle.r.runtime.RInternalError; import com.oracle.truffle.r.runtime.data.RArgsValuesAndNames; import com.oracle.truffle.r.runtime.data.RNull; import com.oracle.truffle.r.runtime.data.RSymbol; @@ -195,4 +196,14 @@ public final class MiscNodes { } } + @TypeSystemReference(RTypes.class) + abstract static class MatchNode extends FFIUpCallNode.Arg3 { + + @SuppressWarnings("unused") + @Specialization + Object match(Object itables, Object ix, int nmatch) { + throw RInternalError.unimplemented("Rf_match"); + } + } + } diff --git a/com.oracle.truffle.r.ffi.impl/src/com/oracle/truffle/r/ffi/impl/upcalls/StdUpCallsRFFI.java b/com.oracle.truffle.r.ffi.impl/src/com/oracle/truffle/r/ffi/impl/upcalls/StdUpCallsRFFI.java index 4b7965ab318ddf4b53548d9d3036c4aaf72c2f52..8edb1b5c7c3262ac081a513a7257aaf4650332d6 100644 --- a/com.oracle.truffle.r.ffi.impl/src/com/oracle/truffle/r/ffi/impl/upcalls/StdUpCallsRFFI.java +++ b/com.oracle.truffle.r.ffi.impl/src/com/oracle/truffle/r/ffi/impl/upcalls/StdUpCallsRFFI.java @@ -343,4 +343,6 @@ public interface StdUpCallsRFFI { @RFFIUpCallNode(CADDRNode.class) Object Rf_asCharacterFactor(Object x); + + Object Rf_match(Object itables, Object ix, int nmatch); } diff --git a/com.oracle.truffle.r.native/fficall/src/jni/unique.c b/com.oracle.truffle.r.native/fficall/src/jni/unique.c new file mode 100644 index 0000000000000000000000000000000000000000..6d4aab293b7a87adff92abc08cc86563f4e5f582 --- /dev/null +++ b/com.oracle.truffle.r.native/fficall/src/jni/unique.c @@ -0,0 +1,45 @@ +/* + * 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. + */ +#include <rffiutils.h> + +static jmethodID Rf_matchMethodID; + +void init_unique(JNIEnv *env) { + + Rf_matchMethodID = checkGetMethodID(env, UpCallsRFFIClass, "Rf_match", "(Ljava/lang/Object;Ljava/lang/Object;I)Ljava/lang/Object;", 0); +} + +SEXP Rf_matchE(SEXP itable, SEXP ix, int nmatch, SEXP env) +{ + unimplemented("Rf_matchE"); +} + +/* used from other code, not here: */ +SEXP Rf_match(SEXP itable, SEXP ix, int nmatch) +{ + TRACE(TARGppd, itable, ix, nmatch); + JNIEnv *thisenv = getEnv(); + SEXP result = (*thisenv)->CallObjectMethod(thisenv, UpCallsRFFIObject, Rf_matchMethodID, itable, ix, nmatch); + return checkRef(thisenv, result); +} + diff --git a/com.oracle.truffle.r.native/fficall/src/truffle_common/Utils.c b/com.oracle.truffle.r.native/fficall/src/truffle_common/Utils.c index 6c0a8d482cb9556b55b8475a0cd61c8c016d41b7..7b3a17dfc2a2dbd3fccb08d5040d491df232d83e 100644 --- a/com.oracle.truffle.r.native/fficall/src/truffle_common/Utils.c +++ b/com.oracle.truffle.r.native/fficall/src/truffle_common/Utils.c @@ -41,3 +41,10 @@ void Rf_onintr() { // TODO: implement interrupt handling, signal errors // ignored } + +Rboolean isOrdered(SEXP s) +{ + return (TYPEOF(s) == INTSXP + && inherits(s, "factor") + && inherits(s, "ordered")); +}