diff --git a/com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/methods/MethodsListDispatch.java b/com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/methods/MethodsListDispatch.java index ec801c5738807ea575b3516daf8418ec46b04bb5..28a93fd8c07ea1f3b3b8c2cd10952f0d4ddef089 100644 --- a/com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/methods/MethodsListDispatch.java +++ b/com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/methods/MethodsListDispatch.java @@ -51,7 +51,7 @@ public class MethodsListDispatch { @TruffleBoundary @Specialization - protected Object callGetClassFromCache(REnvironment table, Object klass) { + protected Object callGetClassFromCache(Object klass, REnvironment table) { String klassString = RRuntime.asString(klass); if (klassString != null) { diff --git a/com.oracle.truffle.r.native/fficall/jni/src/misc.c b/com.oracle.truffle.r.native/fficall/jni/src/misc.c index fef275f202b61561763e3f3e7b49211cd6e5a227..afbc0e520c3078fad8735763777443f0ce69bb7f 100644 --- a/com.oracle.truffle.r.native/fficall/jni/src/misc.c +++ b/com.oracle.truffle.r.native/fficall/jni/src/misc.c @@ -67,6 +67,14 @@ void R_qsort_int_I(int *iv, int *II, int i, int j) { unimplemented("R_qsort_int_I"); } +void rsort_with_index(double *a, int *b, int c) { + unimplemented("rsort_with_index"); +} + +void revsort(double *a, int *b, int c) { + unimplemented("revsort"); +} + void R_CheckUserInterrupt() { // TODO (we don't even do this in the Java code) } diff --git a/com.oracle.truffle.r.native/fficall/jni/src/rf_functions.c b/com.oracle.truffle.r.native/fficall/jni/src/rf_functions.c index b2ac82ebab94bb10c6cdffc6aff88f901b000b9c..2c1c41fbb6d518a7daa28e864081413841729f8e 100644 --- a/com.oracle.truffle.r.native/fficall/jni/src/rf_functions.c +++ b/com.oracle.truffle.r.native/fficall/jni/src/rf_functions.c @@ -382,6 +382,15 @@ void Rf_unprotect(int x) { // TODO perhaps we can use this } +void R_ProtectWithIndex(SEXP x, PROTECT_INDEX *y) { + +} + +void R_Reprotect(SEXP x, PROTECT_INDEX y) { + +} + + void Rf_unprotect_ptr(SEXP x) { // TODO perhaps we can use this } @@ -467,6 +476,11 @@ void Rf_rPsort(double *x, int n, int k) { unimplemented("Rf_rPsort"); } +void Rf_cPsort(Rcomplex *x, int n, int k) { + JNIEnv *thisenv = getEnv(); + unimplemented("Rf_cPsort"); +} + SEXP Rf_classgets(SEXP x, SEXP y) { unimplemented("Rf_classgets"); } diff --git a/com.oracle.truffle.r.native/fficall/jni/src/rfficall.c b/com.oracle.truffle.r.native/fficall/jni/src/rfficall.c index b00783dbbf923cce017585dabd3b9e2f89b20109..75589f4a8673b1b252b4c3a17badfa34e8c11455 100644 --- a/com.oracle.truffle.r.native/fficall/jni/src/rfficall.c +++ b/com.oracle.truffle.r.native/fficall/jni/src/rfficall.c @@ -36,6 +36,7 @@ Java_com_oracle_truffle_r_runtime_ffi_jnr_CallRFFIWithJNI_initialize(JNIEnv *env init_typecoerce(env); init_attrib(env); init_misc(env); + init_rmath(env); init_rng(env); init_optim(env); init_vectoraccess(env); diff --git a/com.oracle.truffle.r.native/fficall/jni/src/rmathc.c b/com.oracle.truffle.r.native/fficall/jni/src/rmathc.c new file mode 100644 index 0000000000000000000000000000000000000000..47599d9a21a6432aaca08ff8b82ae4240604503e --- /dev/null +++ b/com.oracle.truffle.r.native/fficall/jni/src/rmathc.c @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2015, 2015, 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" + +void init_rmath(JNIEnv *env) { + +} + +double Rf_dnorm4(double a, double b, double c , int d) { + unimplemented("Rf_dnorm4"); +} diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Format.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Format.java index 2282d892211616466be0632e643360ca2f34c0f3..2a5b4839cf2c789c2d47850842248632bbd1e1b7 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Format.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Format.java @@ -236,11 +236,11 @@ public abstract class Format extends RBuiltinNode { } @Specialization - protected RStringVector format(RStringVector value, RLogicalVector trimVec, RIntVector digitsVec, RIntVector nsmallVec, RIntVector widthVec, RIntVector justifyVec, RLogicalVector naEncodeVec, - RAbstractVector sciVec) { + protected RStringVector format(RAbstractStringVector value, RLogicalVector trimVec, RIntVector digitsVec, RIntVector nsmallVec, RIntVector widthVec, RIntVector justifyVec, + RLogicalVector naEncodeVec, RAbstractVector sciVec) { checkArgs(trimVec, digitsVec, nsmallVec, widthVec, justifyVec, naEncodeVec, sciVec); // TODO: implement full semantics - return value; + return value.materialize(); } @Specialization diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Structure.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Structure.java index c8dac4d265fd7721275d3b83f4a9ea54e9d4ce39..0585aaea16a85ebe0117fabf0d45d67f165c5284 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Structure.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Structure.java @@ -32,6 +32,7 @@ import com.oracle.truffle.r.nodes.builtin.*; import com.oracle.truffle.r.runtime.*; import com.oracle.truffle.r.runtime.data.*; import com.oracle.truffle.r.runtime.data.model.*; +import com.oracle.truffle.r.runtime.env.REnvironment; /** * A temporary substitution to work around bug with {@code list(...)} used in R version. @@ -71,24 +72,51 @@ public abstract class Structure extends RBuiltinNode { } @Specialization - @TruffleBoundary + protected Object structure(RFunction obj, RArgsValuesAndNames args) { + return doStructure(obj, args); + } + + @Specialization + protected Object structure(REnvironment obj, RArgsValuesAndNames args) { + return doStructure(obj, args); + } + + @Specialization + protected Object structure(RSymbol obj, RArgsValuesAndNames args) { + return doStructure(obj, args); + } + + @Specialization + protected Object structure(RExternalPtr obj, RArgsValuesAndNames args) { + return doStructure(obj, args); + } + + @Specialization protected Object structure(RAbstractContainer obj, RArgsValuesAndNames args) { - Object[] values = args.getArguments(); - ArgumentsSignature signature = getSuppliedSignature(); - validateArgNames(signature); - RAbstractContainer res = obj; + RAttributable res = obj; // TODO: should we consider storing attributes with sequences? if (res instanceof RSequence) { res = ((RSequence) res).createVector(); } + return doStructure(res, args); + } + + // Ideally we would only need this as a specialization, but then we fail due to + // lack of auto-translation of, e.g. Double to RAbstractContainer. + @TruffleBoundary + protected Object doStructure(RAttributable obj, RArgsValuesAndNames args) { + Object[] values = args.getArguments(); + ArgumentsSignature signature = getSuppliedSignature(); + validateArgNames(signature); + RAttributable res = obj; for (int i = 0; i < values.length; i++) { Object value = fixupValue(values[i]); String attrName = fixupAttrName(signature.getName(i + 1)); if (attrName.equals(RRuntime.CLASS_ATTR_KEY)) { if (value == RNull.instance) { - res = (RAbstractContainer) res.setClassAttr(null, true); + res = res.setClassAttr(null, true); } else { - res = (RAbstractContainer) res.setClassAttr((RStringVector) value, true); + res = res.setClassAttr((RStringVector) value, true); } } else { if (value == RNull.instance) { diff --git a/com.oracle.truffle.r.test.cran/r/install.cran.packages.R b/com.oracle.truffle.r.test.cran/r/install.cran.packages.R index dd7ba22be1d81c78c9f315991f6b6ab493d8e89b..f61643d474353ca638c0f0de71a493a5f437d5a8 100644 --- a/com.oracle.truffle.r.test.cran/r/install.cran.packages.R +++ b/com.oracle.truffle.r.test.cran/r/install.cran.packages.R @@ -70,24 +70,31 @@ create.blacklist.iter <- function(blacklist) { } # known to be uninstallable -# uses ++ +# uses C++ cplusplus <- c("Rcpp", "Segmentor3IsBack", "QUIC", "kernlab", "adaptivetau", "geepack", "caTools", "amap", "rgenoud", "stringi", "rjson", "ars", "e1071", "aylmer") +# tcltk +tcltk <- c("AnnotLists", "tcltk2", "aplpack") # parser bugs -parserbug <- character() -# unimplemented feature -unimplemented <- c("ABCoptim") +parserbug <- c("R2HTML") +# e.g., unimplemented builtin, assertion error +core <- c("ade4", "ABCoptim", "R.methodsS3", "lattice", "aidar", "DBI", "SparseM", "quantreg", "doParallel", "ApacheLogProcessor", "aplore3", + "vignettes", "archiDART", "corpcor", "acss.data") # e.g. complex replacement assignments -trufflevisitor.nyi <- c("colorspace", "R.methodsS3", "ade4", "lattice") +trufflevisitor.nyi <- c("colorspace") # problems with native code -nativeinstall <- c("Rglpk", "overlap", "adimpro") +nativeinstall <- c("Rglpk", "overlap", "adimpro", "deSolve") # S4 anything using S4 objects -s4 <- c("matrixStats") +s4 <- c("matrixStats", "AcceptanceSampling", "biglm", "analyz", "RCurl", "anfis", "aod", "ascii") # graphics -graphics <- c("Cairo") +graphics <- c("Cairo", "rgl") +# incomplete definitions from Rmath.h +math <- c("mvtnorm") # serialize -serialize <- c("actuar", "spam") -initial.blacklist <- c(cplusplus, parserbug, unimplemented, trufflevisitor.nyi, nativeinstall, s4, graphics, serialize) +serialize <- c("actuar", "spam", "codetools", "iterators", "apc", "apsrtable", "assertthat") +# fortran related +fortran <- c("appell") +initial.blacklist <- c(cplusplus, tcltk, parserbug, core, math, trufflevisitor.nyi, nativeinstall, s4, graphics, serialize, fortran) create.blacklist <- function() { create.blacklist.iter(initial.blacklist)