diff --git a/com.oracle.truffle.r.engine/src/com/oracle/truffle/r/engine/shell/REmbedded.java b/com.oracle.truffle.r.engine/src/com/oracle/truffle/r/engine/shell/REmbedded.java index 42a9482ac635b093a0c467c440f7170da6c40c00..43d1fa997feab8a3bc30012d81d9b08f528aada3 100644 --- a/com.oracle.truffle.r.engine/src/com/oracle/truffle/r/engine/shell/REmbedded.java +++ b/com.oracle.truffle.r.engine/src/com/oracle/truffle/r/engine/shell/REmbedded.java @@ -113,4 +113,8 @@ public class REmbedded { runRmainloop(vm); } + private static void R_Suicide(String msg) { + + } + } diff --git a/com.oracle.truffle.r.native/fficall/src/jni/Rembedded.c b/com.oracle.truffle.r.native/fficall/src/jni/Rembedded.c index 6c00b921468e8aab0d1eb9567b73024266bfa080..4bde43ed9475dd7edffdfc04fe85c0b322be9ff6 100644 --- a/com.oracle.truffle.r.native/fficall/src/jni/Rembedded.c +++ b/com.oracle.truffle.r.native/fficall/src/jni/Rembedded.c @@ -14,6 +14,7 @@ #include <sys/stat.h> #include <rffiutils.h> #include <R_ext/RStartup.h> +#define R_INTERFACE_PTRS #include <Rinterface.h> extern char **environ; @@ -217,9 +218,8 @@ void R_SaveGlobalEnvToFile(const char *f) { unimplemented("R_SaveGlobalEnvToFile"); } -void R_Suicide(const char *x) { - unimplemented("R_Suicide"); -} +void R_Suicide(const char *s) { ptr_R_Suicide(s); } + void R_DefParams(Rstart rs) { // These are the GnuR defaults and correspond to the settings in RStartParams @@ -298,7 +298,10 @@ void Rf_mainloop(void) { // functions that can be assigned by an embedded client to change behavior void uR_Suicide(const char *x) { - unimplemented("R_Suicide"); + JNIEnv *jniEnv = getEnv(); + jstring msg = (*jniEnv)->NewStringUTF(jniEnv, x); + jmethodID suicideMethod = checkGetMethodID(jniEnv, rembeddedClass, "R_Suicide", "(Ljava/lang/String;)V", 1); + (*jniEnv)->CallStaticVoidMethod(jniEnv, rembeddedClass, suicideMethod, msg); } void uR_ShowMessage(const char *x) { 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 5d5cf9f4d139c2c7e0f273aac8e7077a02831aae..b093067e626213a5e3621a53f1a00d6aa3d3f1ca 100644 --- a/com.oracle.truffle.r.native/fficall/src/jni/Rinternals.c +++ b/com.oracle.truffle.r.native/fficall/src/jni/Rinternals.c @@ -96,6 +96,7 @@ static jmethodID SET_RDEBUGMethodID; static jmethodID RSTEPMethodID; static jmethodID SET_RSTEPMethodID; static jmethodID ENCLOSMethodID; +static jmethodID R_lsInternal3MethodID; static jclass rErrorHandlingClass; static jclass handlerStacksClass; @@ -189,6 +190,7 @@ void init_internals(JNIEnv *env) { RSTEPMethodID = checkGetMethodID(env, CallRFFIHelperClass, "RSTEP", "(Ljava/lang/Object;)I", 1); SET_RSTEPMethodID = checkGetMethodID(env, CallRFFIHelperClass, "SET_RSTEP", "(Ljava/lang/Object;I)V", 1); ENCLOSMethodID = checkGetMethodID(env, CallRFFIHelperClass, "ENCLOS", "(Ljava/lang/Object;)Ljava/lang/Object;", 1); + R_lsInternal3MethodID = checkGetMethodID(env, CallRFFIHelperClass, "R_lsInternal3", "(Ljava/lang/Object;II)Ljava/lang/Object;", 1); rErrorHandlingClass = checkFindClass(env, "com/oracle/truffle/r/runtime/RErrorHandling"); handlerStacksClass = checkFindClass(env, "com/oracle/truffle/r/runtime/RErrorHandling$HandlerStacks"); @@ -671,10 +673,19 @@ SEXP Rf_xlengthgets(SEXP x, R_xlen_t y) { } -SEXP R_lsInternal(SEXP x, Rboolean y) { - return unimplemented("R_lsInternal"); +SEXP R_lsInternal(SEXP env, Rboolean all) { + return R_lsInternal3(env, all, TRUE); } +SEXP R_lsInternal3(SEXP env, Rboolean all, Rboolean sorted) { + JNIEnv *thisenv = getEnv(); + SEXP result = (*thisenv)->CallStaticObjectMethod(thisenv, CallRFFIHelperClass, R_lsInternal3MethodID, env, all, sorted); + return checkRef(thisenv, result); + + +} + + SEXP Rf_namesgets(SEXP x, SEXP y) { return unimplemented("Rf_namesgets"); } diff --git a/com.oracle.truffle.r.runtime.ffi/src/com/oracle/truffle/r/runtime/ffi/RFFIUtils.java b/com.oracle.truffle.r.runtime.ffi/src/com/oracle/truffle/r/runtime/ffi/RFFIUtils.java index 01dc849c60c565ce63aadd152ba5f5eb0910da81..26f1c5599dbf3b78d5b9aa1ea783564aeb81fbed 100644 --- a/com.oracle.truffle.r.runtime.ffi/src/com/oracle/truffle/r/runtime/ffi/RFFIUtils.java +++ b/com.oracle.truffle.r.runtime.ffi/src/com/oracle/truffle/r/runtime/ffi/RFFIUtils.java @@ -36,7 +36,7 @@ public class RFFIUtils { /** * Set this to {@code true} when it is not possible to set {@link FastROptions}. */ - private static boolean alwaysTrace; + private static boolean alwaysTrace = true; public static byte[] wrapChar(char v) { return new byte[]{(byte) v}; diff --git a/com.oracle.truffle.r.runtime.ffi/src/com/oracle/truffle/r/runtime/ffi/jnr/CallRFFIHelper.java b/com.oracle.truffle.r.runtime.ffi/src/com/oracle/truffle/r/runtime/ffi/jnr/CallRFFIHelper.java index fd341adf53bbbe8451cc6d6b8dd50f25ba6338f9..04d60117440d71cb1714e68f5d7d0aa2e29ae126 100644 --- a/com.oracle.truffle.r.runtime.ffi/src/com/oracle/truffle/r/runtime/ffi/jnr/CallRFFIHelper.java +++ b/com.oracle.truffle.r.runtime.ffi/src/com/oracle/truffle/r/runtime/ffi/jnr/CallRFFIHelper.java @@ -107,7 +107,7 @@ public class CallRFFIHelper { } private static RuntimeException unimplemented(String message) { - System.out.println(message); + System.err.println(message); try { throw RInternalError.unimplemented(message); } catch (Error e) { @@ -919,6 +919,14 @@ public class CallRFFIHelper { } + public static Object R_lsInternal3(Object envArg, int allArg, int sortedArg) { + RFFIUtils.traceUpCall("R_lsInternal3", envArg, allArg, sortedArg); + boolean sorted = sortedArg != 0; + boolean all = allArg != 0; + REnvironment env = guaranteeInstanceOf(envArg, REnvironment.class); + return env.ls(all, null, sorted); + } + @SuppressWarnings("unused") private static String R_HomeDir() { RFFIUtils.traceUpCall("R_HomeDir");