diff --git a/com.oracle.truffle.r.engine/src/com/oracle/truffle/r/engine/RRuntimeASTAccessImpl.java b/com.oracle.truffle.r.engine/src/com/oracle/truffle/r/engine/RRuntimeASTAccessImpl.java index 373cfaaa2ca63d14652c19863db21e870e88a617..ae923ddf7dfec7fea072485620b749bf8d61e504 100644 --- a/com.oracle.truffle.r.engine/src/com/oracle/truffle/r/engine/RRuntimeASTAccessImpl.java +++ b/com.oracle.truffle.r.engine/src/com/oracle/truffle/r/engine/RRuntimeASTAccessImpl.java @@ -137,7 +137,7 @@ public class RRuntimeASTAccessImpl implements RRuntimeASTAccess { return len == 1 ? 1 : len + 1; } else { // TODO fill out - throw RInternalError.unimplemented(node.toString()); + assert false : node; } return result; } @@ -246,7 +246,7 @@ public class RRuntimeASTAccessImpl implements RRuntimeASTAccess { return RNull.instance; } else { // TODO fill out - throw RInternalError.unimplemented(node.toString()); + assert false : node; } return null; } diff --git a/com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/grid/GridFunctions.java b/com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/grid/GridFunctions.java new file mode 100644 index 0000000000000000000000000000000000000000..65323916758388bdad40a80631f4710429f5b7b9 --- /dev/null +++ b/com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/grid/GridFunctions.java @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2013, 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. + */ +package com.oracle.truffle.r.library.grid; + +import com.oracle.truffle.api.dsl.*; +import com.oracle.truffle.r.nodes.builtin.*; +import com.oracle.truffle.r.runtime.data.*; +import com.oracle.truffle.r.runtime.env.*; +import com.oracle.truffle.r.runtime.ffi.*; + +/** + * The .Call support for the grid package. + */ +public class GridFunctions { + public abstract static class InitGrid extends RExternalBuiltinNode.Arg1 { + @Specialization + protected Object initGrid(REnvironment gridEvalEnv) { + return RFFIFactory.getRFFI().getGridRFFI().initGrid(gridEvalEnv); + } + } + + public static final class KillGrid extends RExternalBuiltinNode { + @Override + public Object call(RArgsValuesAndNames args) { + return RFFIFactory.getRFFI().getGridRFFI().killGrid(); + } + } +} diff --git a/com.oracle.truffle.r.native/fficall/jni/src/alloc.c b/com.oracle.truffle.r.native/fficall/jni/src/alloc.c index c46ae28e16eeab94bdfb84067be6fae5ff16a672..0a8eed302df13b40e0c7824304ba0170eef2d7f3 100644 --- a/com.oracle.truffle.r.native/fficall/jni/src/alloc.c +++ b/com.oracle.truffle.r.native/fficall/jni/src/alloc.c @@ -70,3 +70,20 @@ void *R_chk_realloc(void *p, size_t size) { void R_chk_free(void *p) { unimplemented("R_chk_free"); } + +void* vmaxget(void) { + unimplemented("vmaxget"); +} + +void vmaxset(const void * x) { + unimplemented("vmaxget"); +} + + +void R_gc(void) { + unimplemented("R_gc"); +} + +int R_gc_running() { + unimplemented("R_gc_running"); +} diff --git a/com.oracle.truffle.r.native/fficall/jni/src/graphicsdevices.c b/com.oracle.truffle.r.native/fficall/jni/src/graphicsdevices.c new file mode 100644 index 0000000000000000000000000000000000000000..0f71b495b826a6f655fc23be01db907aa92ed81b --- /dev/null +++ b/com.oracle.truffle.r.native/fficall/jni/src/graphicsdevices.c @@ -0,0 +1,85 @@ +/* + * 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. + */ + +// For now, failing implementations of the functions from GnuR src/main/engine.c + +#include "rffiutils.h" +#include <GraphicsEngine.h> + +void init_graphicsdevices(JNIEnv *env) { +} + +int ndevNumber(pDevDesc x) { + return (int) unimplemented("ndevNumber"); +} + + +int NumDevices(void) { + return (int)unimplemented("NumDevices"); +} + + +void R_CheckDeviceAvailable(void) { + unimplemented("R_CheckDeviceAvailable"); +} + +Rboolean R_CheckDeviceAvailableBool(void) { + unimplemented("R_CheckDeviceAvailable"); + return FALSE; +} + + +int curDevice(void) { + return (int) unimplemented("curDevice"); +} + + +int nextDevice(int x) { + return (int) unimplemented("curDevice"); +} + + +int prevDevice(int x) { + return (int) unimplemented("prevDevice"); +} + + +int selectDevice(int x) { + return (int) unimplemented("selectDevice"); +} + + +void killDevice(int x) { + unimplemented("killDevice"); +} + + +int NoDevices(void) { + return (int) unimplemented("killDevice"); +} + + +void NewFrameConfirm(pDevDesc x) { + unimplemented("NoDevices"); +} + diff --git a/com.oracle.truffle.r.native/fficall/jni/src/graphicsengine.c b/com.oracle.truffle.r.native/fficall/jni/src/graphicsengine.c new file mode 100644 index 0000000000000000000000000000000000000000..4203767ff6b228104063bcfa8ed80402661c6dd3 --- /dev/null +++ b/com.oracle.truffle.r.native/fficall/jni/src/graphicsengine.c @@ -0,0 +1,408 @@ +/* + * 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. + */ + +// For now, failing implementations of the functions from GnuR src/main/engine.c + +#include "rffiutils.h" +#include <GraphicsEngine.h> + +void init_graphicsengine(JNIEnv *env) { +} + +R_GE_lineend GE_LENDpar(SEXP value, int ind) { + return (R_GE_lineend) unimplemented("GE_LENDpar"); +} + +SEXP GE_LENDget(R_GE_lineend lend) { + return (SEXP) unimplemented("GE_LENDget"); +} + +R_GE_linejoin GE_LJOINpar(SEXP value, int ind) { + return (R_GE_linejoin) unimplemented("GE_LJOINpar"); +} + +SEXP GE_LJOINget(R_GE_linejoin ljoin) { + return (SEXP) unimplemented("GE_LJOINget"); +} + + +void GESetClip(double x1, double y1, double x2, double y2, pGEDevDesc dd) { + unimplemented("GESetClip"); +} + +void GENewPage(const pGEcontext gc, pGEDevDesc dd) { + unimplemented("GENewPage"); +} + +void GELine(double x1, double y1, double x2, double y2, + const pGEcontext gc, pGEDevDesc dd) { + unimplemented("GELine"); +} + +void GEPolyline(int n, double *x, double *y, + const pGEcontext gc, pGEDevDesc dd) { + unimplemented("GEPolyline"); +} + +void GEPolygon(int n, double *x, double *y, + const pGEcontext gc, pGEDevDesc dd) { + unimplemented("GEPolygon"); +} + +SEXP GEXspline(int n, double *x, double *y, double *s, Rboolean open, + Rboolean repEnds, Rboolean draw, + const pGEcontext gc, pGEDevDesc dd) { + return (SEXP) unimplemented("GEXspline"); +} + +void GECircle(double x, double y, double radius, + const pGEcontext gc, pGEDevDesc dd) { + unimplemented(""); +} + +void GERect(double x0, double y0, double x1, double y1, + const pGEcontext gc, pGEDevDesc dd) { + unimplemented("GECircle"); +} + +void GEPath(double *x, double *y, + int npoly, int *nper, + Rboolean winding, + const pGEcontext gc, pGEDevDesc dd) { + unimplemented("GEPath"); +} + +void GERaster(unsigned int *raster, int w, int h, + double x, double y, double width, double height, + double angle, Rboolean interpolate, + const pGEcontext gc, pGEDevDesc dd) { + unimplemented("GERaster"); +} + +SEXP GECap(pGEDevDesc dd) { + return (SEXP) unimplemented("GECap"); +} + +void GEText(double x, double y, const char * const str, cetype_t enc, + double xc, double yc, double rot, + const pGEcontext gc, pGEDevDesc dd) { + unimplemented("GEText"); +} + +void GEMode(int mode, pGEDevDesc dd) { + unimplemented("GEText"); +} + +void GESymbol(double x, double y, int pch, double size, + const pGEcontext gc, pGEDevDesc dd) { + unimplemented("GESymbol"); +} + +void GEPretty(double *lo, double *up, int *ndiv) { + unimplemented("GEPretty"); +} + +void GEMetricInfo(int c, const pGEcontext gc, + double *ascent, double *descent, double *width, + pGEDevDesc dd) { + unimplemented("GEPretty"); +} + +double GEStrWidth(const char *str, cetype_t enc, + const pGEcontext gc, pGEDevDesc dd) { + unimplemented("GEStrWidth"); + return 0.0; +} + +double GEStrHeight(const char *str, cetype_t enc, + const pGEcontext gc, pGEDevDesc dd) { + unimplemented("GEStrHeight"); + return 0.0; +} + +void GEStrMetric(const char *str, cetype_t enc, const pGEcontext gc, + double *ascent, double *descent, double *width, + pGEDevDesc dd) { + unimplemented("GEStrMetric"); +} + +int GEstring_to_pch(SEXP pch) { + return (int) unimplemented("GEstring_to_pch"); +} + +unsigned int GE_LTYpar(SEXP x, int y) { + return unimplemented("GE_LTYpar"); +} + +SEXP GE_LTYget(unsigned int x) { + return (SEXP) unimplemented("GE_LTYget"); +} + +void R_GE_rasterScale(unsigned int *sraster, int sw, int sh, + unsigned int *draster, int dw, int dh) { + unimplemented("R_GE_rasterScale"); +} + +void R_GE_rasterInterpolate(unsigned int *sraster, int sw, int sh, + unsigned int *draster, int dw, int dh) { + unimplemented("R_GE_rasterInterpolate"); +} + +void R_GE_rasterRotatedSize(int w, int h, double angle, + int *wnew, int *hnew) { + unimplemented("R_GE_rasterRotatedSize"); +} + +void R_GE_rasterRotatedOffset(int w, int h, double angle, int botleft, + double *xoff, double *yoff) { + unimplemented("R_GE_rasterRotatedOffset"); +} + +void R_GE_rasterResizeForRotation(unsigned int *sraster, + int w, int h, + unsigned int *newRaster, + int wnew, int hnew, + const pGEcontext gc) { + unimplemented("R_GE_rasterResizeForRotation"); +} + +void R_GE_rasterRotate(unsigned int *sraster, int w, int h, double angle, + unsigned int *draster, const pGEcontext gc, + Rboolean perPixelAlpha) { + unimplemented("R_GE_rasterRotate"); +} + +double GEExpressionWidth(SEXP expr, + const pGEcontext gc, pGEDevDesc dd) { + unimplemented(""); + return 0.0; +} + +double GEExpressionHeight(SEXP expr, + const pGEcontext gc, pGEDevDesc dd) { + unimplemented("GEExpressionHeight"); + return 0.0; +} + +void GEExpressionMetric(SEXP expr, const pGEcontext gc, + double *ascent, double *descent, double *width, + pGEDevDesc dd) { + unimplemented("GEExpressionMetric"); +} + +void GEMathText(double x, double y, SEXP expr, + double xc, double yc, double rot, + const pGEcontext gc, pGEDevDesc dd) { + unimplemented("GEMathText"); +} + +SEXP GEcontourLines(double *x, int nx, double *y, int ny, + double *z, double *levels, int nl) { + return (SEXP) unimplemented("GEcontourLines"); +} + +double R_GE_VStrWidth(const char *s, cetype_t enc, const pGEcontext gc, pGEDevDesc dd) { + unimplemented("R_GE_VStrWidth"); + return 0.0; +} + + +double R_GE_VStrHeight(const char *s, cetype_t enc, const pGEcontext gc, pGEDevDesc dd) { + unimplemented("R_GE_VStrHeight"); + return 0.0; +} + +void R_GE_VText(double x, double y, const char * const s, cetype_t enc, + double x_justify, double y_justify, double rotation, + const pGEcontext gc, pGEDevDesc dd) { + unimplemented("R_GE_VText"); +} + +pGEDevDesc GEcurrentDevice(void) { + return (pGEDevDesc) unimplemented("GEcurrentDevice"); +} + +Rboolean GEdeviceDirty(pGEDevDesc dd) { + unimplemented("GEcurrentDevice"); + return FALSE; +} + +void GEdirtyDevice(pGEDevDesc dd) { + unimplemented("GEdirtyDevice"); +} + +Rboolean GEcheckState(pGEDevDesc dd) { + unimplemented("GEcheckState"); + return FALSE; +} + +Rboolean GErecording(SEXP call, pGEDevDesc dd) { + unimplemented("GErecording"); + return FALSE; +} + +void GErecordGraphicOperation(SEXP op, SEXP args, pGEDevDesc dd) { + unimplemented("GErecordGraphicOperation"); +} + +void GEinitDisplayList(pGEDevDesc dd) { + unimplemented("GEinitDisplayList"); +} + +void GEplayDisplayList(pGEDevDesc dd) { + unimplemented("GEplayDisplayList"); +} + +void GEcopyDisplayList(int fromDevice) { + unimplemented("GEcopyDisplayList"); +} + +SEXP GEcreateSnapshot(pGEDevDesc dd) { + return (SEXP) unimplemented("GEcreateSnapshot"); +} + +void GEplaySnapshot(SEXP snapshot, pGEDevDesc dd) { + unimplemented(""); +} + +void GEonExit(void) { + unimplemented("GEplaySnapshot"); +} + +void GEnullDevice(void) { + unimplemented("GEnullDevice"); +} + +SEXP CreateAtVector(double* x, double* y, int z, Rboolean w) { + return (SEXP) unimplemented("CreateAtVector"); +} + +void GAxisPars(double *min, double *max, int *n, Rboolean log, int axis) { + unimplemented("GAxisPars"); +} + +pGEDevDesc desc2GEDesc(pDevDesc dd) { + return (pGEDevDesc) unimplemented("desc2GEDesc"); +} + +int GEdeviceNumber(pGEDevDesc x) { + return (int) unimplemented("GEdeviceNumber"); +} + +pGEDevDesc GEgetDevice(int x) { + return (pGEDevDesc) unimplemented("GEgetDevice"); +} + +void GEaddDevice(pGEDevDesc x) { + unimplemented("GEaddDevice"); +} + +void GEaddDevice2(pGEDevDesc x, const char *y) { + unimplemented("GEaddDevice2"); +} + +void GEkillDevice(pGEDevDesc x) { + unimplemented("GEkillDevice"); +} + +pGEDevDesc GEcreateDevDesc(pDevDesc dev) { + return (pGEDevDesc) unimplemented(""); +} + +void GEdestroyDevDesc(pGEDevDesc dd) { + unimplemented("GEdestroyDevDesc"); +} + +void *GEsystemState(pGEDevDesc dd, int index) { + return unimplemented("GEsystemState"); +} + +void GEregisterWithDevice(pGEDevDesc dd) { + unimplemented("GEregisterWithDevice"); +} + +void GEregisterSystem(GEcallback callback, int *systemRegisterIndex) { + // TODO for now we just ignore this to allow the grid package to load +} + +void GEunregisterSystem(int registerIndex) { + // TODO for now we just ignore this to allow the grid package to unload +} + +SEXP GEhandleEvent(GEevent event, pDevDesc dev, SEXP data) { + return (SEXP) unimplemented("GEhandleEvent"); +} + + +double fromDeviceX(double value, GEUnit to, pGEDevDesc dd) { + unimplemented("fromDeviceX"); + return 0.0; +} + +double toDeviceX(double value, GEUnit from, pGEDevDesc dd) { + unimplemented("toDeviceX"); + return 0.0; +} + +double fromDeviceY(double value, GEUnit to, pGEDevDesc dd) { + unimplemented("fromDeviceY"); + return 0.0; +} + +double toDeviceY(double value, GEUnit from, pGEDevDesc dd) { + unimplemented("toDeviceY"); + return 0.0; +} + +double fromDeviceWidth(double value, GEUnit to, pGEDevDesc dd) { + unimplemented("fromDeviceWidth"); + return 0.0; +} + +double toDeviceWidth(double value, GEUnit from, pGEDevDesc dd) { + unimplemented("toDeviceWidth"); + return 0.0; +} + +double fromDeviceHeight(double value, GEUnit to, pGEDevDesc dd) { + unimplemented("fromDeviceHeight"); + return 0.0; +} + +double toDeviceHeight(double value, GEUnit from, pGEDevDesc dd) { + unimplemented("toDeviceHeight"); + return 0.0; +} + +rcolor Rf_RGBpar(SEXP x, int y) { + return (rcolor) unimplemented("RGBpar"); +} + +rcolor Rf_RGBpar3(SEXP x, int y, rcolor z) { + return (rcolor) unimplemented("RGBpar3"); +} + + +const char *Rf_col2name(rcolor col) { + return (const char *) unimplemented("col2name"); +} 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 7b0cf110fc686daa027f1a7c89f1942be964c716..2df69009843c11690f71aebe62cfddbc6b5a773f 100644 --- a/com.oracle.truffle.r.native/fficall/jni/src/misc.c +++ b/com.oracle.truffle.r.native/fficall/jni/src/misc.c @@ -32,6 +32,10 @@ void init_misc(JNIEnv *env) { isFiniteMethodID = checkGetMethodID(env, RRuntimeClass, "isFinite", "(D)Z", 1); } +char *dgettext(const char *domainname, const char *msgid) { + unimplemented("dgettext"); +} + const char *R_CHAR(SEXP string) { TRACE("%s(%p)", string); // This is nasty: 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 24825674fa9d6d01663bc46a211e209c96be9837..e57fa74520238abfc9785665d61a02e4bfae758c 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 @@ -133,6 +133,11 @@ SEXP Rf_eval(SEXP expr, SEXP env) { unimplemented("Rf_eval)"); } +SEXP Rf_findFun(SEXP symbol, SEXP rho) { + JNIEnv *thisenv = getEnv(); + unimplemented("Rf_eval)"); +} + SEXP Rf_findVar(SEXP symbol, SEXP rho) { JNIEnv *thisenv = getEnv(); SEXP result =(*thisenv)->CallStaticObjectMethod(thisenv, CallRFFIHelperClass, Rf_findVarMethodID, symbol, rho); @@ -181,6 +186,18 @@ Rboolean Rf_isInteger(SEXP x) { unimplemented("Rf_isInteger"); } +Rboolean Rf_isReal(SEXP x) { + unimplemented("Rf_isReal"); +} + +Rboolean Rf_isSymbol(SEXP x) { + unimplemented("Rf_isSymbol"); +} + +Rboolean Rf_isExpression(SEXP x) { + unimplemented("Rf_isExpression"); +} + Rboolean Rf_isLanguage(SEXP x) { unimplemented("Rf_isLanguage"); } @@ -263,10 +280,37 @@ Rboolean Rf_isString(SEXP s) { } +SEXP Rf_lang1(SEXP a) { + unimplemented("Rf_lang1"); +} + +SEXP Rf_lang2(SEXP a, SEXP b) { + unimplemented("Rf_lang2"); +} + +SEXP Rf_lang3(SEXP a, SEXP b, SEXP c) { + unimplemented("Rf_lang3"); +} + +SEXP Rf_lang4(SEXP a, SEXP b, SEXP c, SEXP d) { + unimplemented("Rf_lang2"); +} + +SEXP Rf_lang5(SEXP a, SEXP b, SEXP c, SEXP d, SEXP e) { + unimplemented("Rf_lang5"); +} + +SEXP Rf_lang6(SEXP a, SEXP b, SEXP c, SEXP d, SEXP e, SEXP f) { + unimplemented("Rf_lang6"); +} + SEXP Rf_lcons(SEXP x, SEXP y) { unimplemented("Rf_lcons"); } +cetype_t Rf_getCharCE(SEXP x) { + unimplemented("Rf_getCharCE"); +} SEXP Rf_mkChar(const char *x) { JNIEnv *thisenv = getEnv(); @@ -357,3 +401,16 @@ void Rf_rPsort(double *x, int n, int k) { JNIEnv *thisenv = getEnv(); unimplemented("Rf_rPsort"); } + +SEXP Rf_classgets(SEXP x, SEXP y) { + unimplemented("Rf_classgets"); +} + +double Rf_fmax2(double x, double y) { + unimplemented("Rf_fmax2"); +} + +double Rf_fmin2(double x, double y) { + unimplemented("Rf_fmin2"); +} + 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 939c7a7a026266bf85a0017d058d226e2633d60c..b00783dbbf923cce017585dabd3b9e2f89b20109 100644 --- a/com.oracle.truffle.r.native/fficall/jni/src/rfficall.c +++ b/com.oracle.truffle.r.native/fficall/jni/src/rfficall.c @@ -40,6 +40,8 @@ Java_com_oracle_truffle_r_runtime_ffi_jnr_CallRFFIWithJNI_initialize(JNIEnv *env init_optim(env); init_vectoraccess(env); init_listaccess(env); + init_graphicsengine(env); + init_graphicsdevices(env); } static jmp_buf error_jmpbuf; diff --git a/com.oracle.truffle.r.native/fficall/jni/src/rffiutils.c b/com.oracle.truffle.r.native/fficall/jni/src/rffiutils.c index 8811ec1af11626b3d70e98ea66317c3386c3f88c..f253d4d0f78f22f071fe885dbc198cad8cbb734c 100644 --- a/com.oracle.truffle.r.native/fficall/jni/src/rffiutils.c +++ b/com.oracle.truffle.r.native/fficall/jni/src/rffiutils.c @@ -227,9 +227,11 @@ void setEnv(JNIEnv *env) { curenv = env; } -void unimplemented(char *msg) { +void *unimplemented(char *msg) { JNIEnv *thisenv = getEnv(); (*thisenv)->FatalError(thisenv, msg); + // to keep compiler happy + return NULL; } void fatalError(char *msg) { diff --git a/com.oracle.truffle.r.native/fficall/jni/src/rffiutils.h b/com.oracle.truffle.r.native/fficall/jni/src/rffiutils.h index 68b98a8665fdba874150df2beb1750ab4bda8c91..a8545151b2c1ff94c475c2d2ef6c521d8d69ae04 100644 --- a/com.oracle.truffle.r.native/fficall/jni/src/rffiutils.h +++ b/com.oracle.truffle.r.native/fficall/jni/src/rffiutils.h @@ -37,7 +37,7 @@ jmethodID checkGetMethodID(JNIEnv *env, jclass klass, const char *name, const ch extern jmethodID createSymbolMethodID; // use for an unimplemented API function -void unimplemented(char *msg); +void *unimplemented(char *msg); // use for any fatal error void fatalError(char *msg); // makes a call to the VM with x as an argument (for debugger validation) diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/foreign/ForeignFunctions.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/foreign/ForeignFunctions.java index b57ef462af7805b774de943ad62bef55038f8292..a07116dcfdb760bc8af21a0b13b962c4f9563bd5 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/foreign/ForeignFunctions.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/foreign/ForeignFunctions.java @@ -17,6 +17,7 @@ import com.oracle.truffle.r.library.grDevices.DevicesCCalls; import com.oracle.truffle.r.library.graphics.GraphicsCCalls; import com.oracle.truffle.r.library.graphics.GraphicsCCalls.C_Par; import com.oracle.truffle.r.library.graphics.GraphicsCCalls.C_PlotXY; +import com.oracle.truffle.r.library.grid.GridFunctionsFactory.InitGridNodeGen; import com.oracle.truffle.r.library.methods.MethodsListDispatchFactory.R_M_setPrimitiveMethodsNodeGen; import com.oracle.truffle.r.library.methods.MethodsListDispatchFactory.R_getClassFromCacheNodeGen; import com.oracle.truffle.r.library.methods.MethodsListDispatchFactory.R_initMethodDispatchNodeGen; @@ -178,6 +179,8 @@ public class ForeignFunctions { return new MakeQuartzDefault(); case "menu": return MenuNodeGen.create(); + case "L_initGrid": + return InitGridNodeGen.create(); default: return null; } diff --git a/com.oracle.truffle.r.runtime.ffi/src/com/oracle/truffle/r/runtime/ffi/jnr/JNR_RFFIFactory.java b/com.oracle.truffle.r.runtime.ffi/src/com/oracle/truffle/r/runtime/ffi/jnr/JNR_RFFIFactory.java index 8168b6dfc50db9c6e86135649bd8114a1257af55..fcfc5c93fd434e1253c5fcc4af181861302efe97 100644 --- a/com.oracle.truffle.r.runtime.ffi/src/com/oracle/truffle/r/runtime/ffi/jnr/JNR_RFFIFactory.java +++ b/com.oracle.truffle.r.runtime.ffi/src/com/oracle/truffle/r/runtime/ffi/jnr/JNR_RFFIFactory.java @@ -45,7 +45,7 @@ import com.oracle.truffle.r.runtime.ffi.DLL.DLLInfo; /** * JNR/JNI-based factory. */ -public class JNR_RFFIFactory extends RFFIFactory implements RFFI, BaseRFFI, StatsRFFI, ToolsRFFI, RApplRFFI, LapackRFFI, UserRngRFFI, PCRERFFI { +public class JNR_RFFIFactory extends RFFIFactory implements RFFI, BaseRFFI, StatsRFFI, ToolsRFFI, GridRFFI, RApplRFFI, LapackRFFI, UserRngRFFI, PCRERFFI { public JNR_RFFIFactory() { } @@ -450,7 +450,7 @@ public class JNR_RFFIFactory extends RFFIFactory implements RFFI, BaseRFFI, Stat public interface Stats { /* * TODO add @In/@Out to any arrays that are known to be either @In or @Out (default is - * + * * @Inout) */ @@ -535,6 +535,50 @@ public class JNR_RFFIFactory extends RFFIFactory implements RFFI, BaseRFFI, Stat } } + // Grid + + @Override + public GridRFFI getGridRFFI() { + return this; + } + + private static class GridProvider { + private static GridProvider grid; + private static DLL.SymbolInfo initGrid; + private static DLL.SymbolInfo killGrid; + + @TruffleBoundary + private GridProvider() { + System.load(LibPaths.getPackageLibPath("grid")); + initGrid = DLL.findSymbolInfo("L_initGrid", "grid"); + killGrid = DLL.findSymbolInfo("L_killGrid", "grid"); + } + + static GridProvider gridProvider() { + if (grid == null) { + grid = new GridProvider(); + } + return grid; + } + + DLL.SymbolInfo getInitGrid() { + return initGrid; + } + + DLL.SymbolInfo getKillGrid() { + return killGrid; + } + + } + + public Object initGrid(REnvironment gridEvalEnv) { + return getCallRFFI().invokeCall(GridProvider.gridProvider().getInitGrid(), new Object[]{gridEvalEnv}); + } + + public Object killGrid() { + return getCallRFFI().invokeCall(GridProvider.gridProvider().getKillGrid(), new Object[0]); + } + /* * UserRng. This is a singleton instance, although the actual library may vary from run to run. */ diff --git a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/ffi/GridRFFI.java b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/ffi/GridRFFI.java new file mode 100644 index 0000000000000000000000000000000000000000..638dc4183ed0bd60eace6afebe22ea90510ebf22 --- /dev/null +++ b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/ffi/GridRFFI.java @@ -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. + */ +package com.oracle.truffle.r.runtime.ffi; + +import com.oracle.truffle.r.runtime.env.*; + +public interface GridRFFI { + Object initGrid(REnvironment gridEvalEnv); + + Object killGrid(); +} diff --git a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/ffi/RFFI.java b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/ffi/RFFI.java index 17e532bf6b947c956d91e47ea58436a7ed51f345..556933b4efe5d9bd165a6cef94f6fd5fd0fa579b 100644 --- a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/ffi/RFFI.java +++ b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/ffi/RFFI.java @@ -54,6 +54,8 @@ public interface RFFI { ToolsRFFI getToolsRFFI(); + GridRFFI getGridRFFI(); + CRFFI getCRFFI(); CallRFFI getCallRFFI(); diff --git a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/ffi/RFFIFactory.java b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/ffi/RFFIFactory.java index 0eb95d6bc7155e95a03b5e402788b4f26bd35ecc..b59cf1103e0aca949fffc1bc5b2beaa9d87b31d4 100644 --- a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/ffi/RFFIFactory.java +++ b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/ffi/RFFIFactory.java @@ -75,6 +75,10 @@ public abstract class RFFIFactory { throw missing("Tools"); } + public GridRFFI getGridRFFI() { + throw missing("Grid"); + } + public RApplRFFI getRApplRFFI() { throw missing("RDerived"); }