From c8bb1a54f8c91e2e4a092962b813016536b48009 Mon Sep 17 00:00:00 2001 From: Florian Angerer <florian.angerer@oracle.com> Date: Tue, 19 Sep 2017 18:31:06 +0200 Subject: [PATCH] Added dummy implementations for some native functions. --- .../ffi/impl/common/JavaUpCallsRFFIImpl.java | 6 +++ .../truffle/r/ffi/impl/nodes/MiscNodes.java | 11 +++++ .../r/ffi/impl/upcalls/StdUpCallsRFFI.java | 2 + .../fficall/src/jni/unique.c | 45 +++++++++++++++++++ .../fficall/src/truffle_common/Utils.c | 7 +++ 5 files changed, 71 insertions(+) create mode 100644 com.oracle.truffle.r.native/fficall/src/jni/unique.c 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 0fd2bf80d7..b73fac10a4 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 6d7d2f2c57..a643bc35e3 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 4b7965ab31..8edb1b5c7c 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 0000000000..6d4aab293b --- /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 6c0a8d482c..7b3a17dfc2 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")); +} -- GitLab