Skip to content
Snippets Groups Projects
Commit 67fb9089 authored by Mick Jordan's avatar Mick Jordan
Browse files

Merge

parents 44943c13 e37daa6f
No related branches found
No related tags found
No related merge requests found
......@@ -29,10 +29,8 @@
static jmethodID Rf_ScalarIntegerMethodID;
static jmethodID Rf_ScalarDoubleMethodID;
static jmethodID Rf_ScalarStringMethodID;
static jmethodID createIntArrayMethodID;
static jmethodID createDoubleArrayMethodID;
static jmethodID createStringArrayMethodID;
static jmethodID createListMethodID;
static jmethodID Rf_allocateVectorMethodID;
static jmethodID Rf_allocateMatrixMethodID;
static jmethodID Rf_duplicateMethodID;
static jmethodID Rf_consMethodID;
static jmethodID Rf_defineVarMethodID;
......@@ -60,10 +58,8 @@ void init_rf_functions(JNIEnv *env) {
Rf_isNullMethodID = checkGetMethodID(env, CallRFFIHelperClass, "Rf_isNull", "(Ljava/lang/Object;)I", 1);
Rf_warningMethodID = checkGetMethodID(env, CallRFFIHelperClass, "Rf_warning", "(Ljava/lang/String;)V", 1);
Rf_errorMethodID = checkGetMethodID(env, CallRFFIHelperClass, "Rf_error", "(Ljava/lang/String;)V", 1);
createIntArrayMethodID = checkGetMethodID(env, RDataFactoryClass, "createIntVector", "(I)Lcom/oracle/truffle/r/runtime/data/RIntVector;", 1);
createDoubleArrayMethodID = checkGetMethodID(env, RDataFactoryClass, "createDoubleVector", "(I)Lcom/oracle/truffle/r/runtime/data/RDoubleVector;", 1);
createStringArrayMethodID = checkGetMethodID(env, RDataFactoryClass, "createStringVector", "(I)Lcom/oracle/truffle/r/runtime/data/RStringVector;", 1);
createListMethodID = checkGetMethodID(env, RDataFactoryClass, "createList", "(I)Lcom/oracle/truffle/r/runtime/data/RList;", 1);
Rf_allocateVectorMethodID = checkGetMethodID(env, CallRFFIHelperClass, "Rf_allocateVector", "(II)Ljava/lang/Object;", 1);
Rf_allocateMatrixMethodID = checkGetMethodID(env, CallRFFIHelperClass, "Rf_allocateMatrix", "(III)Ljava/lang/Object;", 1);
Rf_duplicateMethodID = checkGetMethodID(env, CallRFFIHelperClass, "Rf_duplicate", "(Ljava/lang/Object;)Ljava/lang/Object;", 1);
Rf_NewHashedEnvMethodID = checkGetMethodID(env, RDataFactoryClass, "createNewEnv", "(Lcom/oracle/truffle/r/runtime/env/REnvironment;Ljava/lang/String;ZI)Lcom/oracle/truffle/r/runtime/env/REnvironment;", 1);
// Rf_rPsortMethodID = checkGetMethodID(env, CallRFFIHelperClass, "Rf_rPsort", "(Lcom/oracle/truffle/r/runtime/data/RDoubleVector;II)", 1);
......@@ -93,29 +89,14 @@ SEXP Rf_ScalarString(SEXP value) {
SEXP Rf_allocVector(SEXPTYPE t, R_xlen_t len) {
TRACE(TARG2d, t, len);
JNIEnv *thisenv = getEnv();
SEXP result;
switch (t) {
case INTSXP: {
result = (*thisenv)->CallStaticObjectMethod(thisenv, RDataFactoryClass, createIntArrayMethodID, len);
break;
}
case REALSXP: {
result = (*thisenv)->CallStaticObjectMethod(thisenv, RDataFactoryClass, createDoubleArrayMethodID, len);
break;
}
case STRSXP: {
result = (*thisenv)->CallStaticObjectMethod(thisenv, RDataFactoryClass, createStringArrayMethodID, len);
break;
}
case VECSXP: {
result = (*thisenv)->CallStaticObjectMethod(thisenv, RDataFactoryClass, createListMethodID, len);
break;
}
default:
printf("t=%d\n", t);
unimplemented("vector type not handled");
return NULL;
}
SEXP result = (*thisenv)->CallStaticObjectMethod(thisenv, CallRFFIHelperClass, Rf_allocateVectorMethodID, t, len);
return checkRef(thisenv, result);
}
SEXP Rf_allocMatrix(SEXPTYPE mode, int nrow, int ncol) {
TRACE(TARG2d, t, len);
JNIEnv *thisenv = getEnv();
SEXP result = (*thisenv)->CallStaticObjectMethod(thisenv, CallRFFIHelperClass, Rf_allocateMatrixMethodID, mode, nrow, ncol);
return checkRef(thisenv, result);
}
......@@ -196,7 +177,7 @@ SEXP Rf_mkString(const char *s) {
}
SEXP Rf_protect(SEXP x) {
// TODO perhaps we can use this
return x;
}
void Rf_unprotect(int x) {
......
......@@ -57,7 +57,8 @@ public class DynLoadFunctions {
DLLInfo dllInfo = DLL.loadPackageDLL(lib, asBoolean(local), asBoolean(now));
return dllInfo.toRList();
} catch (DLLException ex) {
throw RError.error(this, ex);
// This is not a recoverable error
throw RInternalError.shouldNotReachHere(ex);
}
}
......
......@@ -28,6 +28,7 @@ import com.oracle.truffle.r.runtime.data.*;
import com.oracle.truffle.r.runtime.data.model.*;
import com.oracle.truffle.r.runtime.env.*;
import com.oracle.truffle.r.runtime.env.REnvironment.PutException;
import com.oracle.truffle.r.runtime.gnur.*;
import com.oracle.truffle.r.runtime.ops.na.*;
/**
......@@ -173,6 +174,54 @@ public class CallRFFIHelper {
RError.warning(RError.NO_NODE, RError.Message.GENERIC, msg);
}
static Object Rf_allocateVector(int mode, int n) {
SEXPTYPE type = SEXPTYPE.mapInt(mode);
if (n < 0) {
throw RError.error(RError.NO_NODE, RError.Message.NEGATIVE_LENGTH_VECTORS_NOT_ALLOWED);
// TODO check long vector
}
switch (type) {
case INTSXP:
return RDataFactory.createIntVector(new int[n], RDataFactory.COMPLETE_VECTOR);
case REALSXP:
return RDataFactory.createDoubleVector(new double[n], RDataFactory.COMPLETE_VECTOR);
case LGLSXP:
return RDataFactory.createLogicalVector(new byte[n], RDataFactory.COMPLETE_VECTOR);
case STRSXP:
return RDataFactory.createStringVector(new String[n], RDataFactory.COMPLETE_VECTOR);
case CPLXSXP:
return RDataFactory.createComplexVector(new double[2 * n], RDataFactory.COMPLETE_VECTOR);
case VECSXP:
return RDataFactory.createList(n);
default:
throw RInternalError.unimplemented();
}
}
static Object Rf_allocateMatrix(int mode, int ncol, int nrow) {
SEXPTYPE type = SEXPTYPE.mapInt(mode);
if (nrow < 0 || ncol < 0) {
throw RError.error(RError.NO_NODE, RError.Message.NEGATIVE_EXTENTS_TO_MATRIX);
}
// TODO check long vector
int[] dims = new int[]{nrow, ncol};
switch (type) {
case INTSXP:
return RDataFactory.createIntVector(new int[nrow * ncol], RDataFactory.COMPLETE_VECTOR, dims);
case REALSXP:
return RDataFactory.createDoubleVector(new double[nrow * ncol], RDataFactory.COMPLETE_VECTOR, dims);
case LGLSXP:
return RDataFactory.createLogicalVector(new byte[nrow * ncol], RDataFactory.COMPLETE_VECTOR, dims);
case CHARSXP:
return RDataFactory.createStringVector(new String[nrow * ncol], RDataFactory.COMPLETE_VECTOR, dims);
case CPLXSXP:
return RDataFactory.createComplexVector(new double[2 * (nrow * ncol)], RDataFactory.COMPLETE_VECTOR, dims);
default:
throw RInternalError.unimplemented();
}
}
static int LENGTH(Object x) {
if (x instanceof RAbstractContainer) {
return ((RAbstractContainer) x).getLength();
......
......@@ -261,6 +261,7 @@ public final class RError extends RuntimeException {
BY_TOO_SMALL("'by' argument is much too small"),
INCORRECT_SUBSCRIPTS("incorrect number of subscripts"),
INCORRECT_SUBSCRIPTS_MATRIX("incorrect number of subscripts on matrix"),
NEGATIVE_EXTENTS_TO_MATRIX("negative extents to matrix"),
INVALID_SEP("invalid 'sep' specification"),
INVALID_LENGTH("invalid '%s' length"),
EMPTY_WHAT("empty 'what' specified"),
......
......@@ -61,7 +61,7 @@ create.blacklist.iter <- function(blacklist) {
}
# known to be uninstallable
initial.blacklist <- c("Rcpp", "grid", "splines", "parallel")
initial.blacklist <- c("Rcpp")
create.blacklist <- function() {
create.blacklist.iter(initial.blacklist)
......
......@@ -3,7 +3,9 @@
<name>mx.fastr</name>
<comment></comment>
<projects>
<project>mxtool</project>
<project>mx</project>
<project>mx.graal</project>
<project>mx.jvmci</project>
</projects>
<buildSpec>
<buildCommand>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment