diff --git a/com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/fastrGrid/FastRGridExternalLookup.java b/com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/fastrGrid/FastRGridExternalLookup.java index 8080509ff2632dda308cd04d0f8ac44f9323aad0..e3555f6a22a5e967eef83646ee3d1300c28d055b 100644 --- a/com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/fastrGrid/FastRGridExternalLookup.java +++ b/com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/fastrGrid/FastRGridExternalLookup.java @@ -38,7 +38,6 @@ import com.oracle.truffle.r.library.fastrGrid.graphics.CPar; import com.oracle.truffle.r.nodes.builtin.RExternalBuiltinNode; import com.oracle.truffle.r.nodes.builtin.RInternalCodeBuiltinNode; import com.oracle.truffle.r.runtime.RInternalCode; -import com.oracle.truffle.r.runtime.RInternalError; import com.oracle.truffle.r.runtime.RRuntime; import com.oracle.truffle.r.runtime.data.RList; import com.oracle.truffle.r.runtime.data.RNull; diff --git a/com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/fastrGrid/fastrGrid.R b/com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/fastrGrid/fastrGrid.R index 068c5fb4f50a1c2eb42ef574881321d47aee4db3..2dfc34c84e6597cb045b562d891f173e954dd226 100644 --- a/com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/fastrGrid/fastrGrid.R +++ b/com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/fastrGrid/fastrGrid.R @@ -63,8 +63,8 @@ find.in.children <- function(path, name, strict, currPath, children, depth) { # path is a string, e.g. "A::B::C", or NULL if we are not searching for particular path # name is a string, the name of child we are looking for -L_downvppath <- function(path, name, strict) { - currVp <- .Call(grid:::L_currentViewport) +downvppath <- function(path, name, strict) { + currVp <- .Call(grid:::C_currentViewport) result <- find.viewport(path, name, strict, NULL, currVp, 1L); if (result[[1]]) { .Internal(.fastr.grid.doSetViewPort(result[[2L]], FALSE, FALSE)); @@ -74,17 +74,17 @@ L_downvppath <- function(path, name, strict) { } } -L_downviewport <- function(name, strict) { - L_downvppath(0L, name, strict) +downviewport <- function(name, strict) { + downvppath(0L, name, strict) } -L_setviewport <- function(vp, hasParent) { +setviewport <- function(vp, hasParent) { pushedVP <- grid:::pushedvp(vp); .Internal(.fastr.grid.doSetViewPort(pushedVP, hasParent, TRUE)); } -L_unsetviewport <- function(n) { - gvp <- .Call(grid:::L_currentViewport) +unsetviewport <- function(n) { + gvp <- .Call(grid:::C_currentViewport) newVp <- gvp; for (i in 1:n) { gvp <- newVp; @@ -152,8 +152,8 @@ getUnitData <- function(unit, index) { isPureNullUnitGrobDim <- function(unit, index, dimFunction) { # Can a grob have "null" width/height? # to be sure we cover everything, we keep the check here (like in GnuR) - savedgpar <- .Call(grid:::L_getGPar) - savedgrob <- .Call(grid:::L_getCurrentGrob) + savedgpar <- .Call(grid:::C_getGPar) + savedgrob <- .Call(grid:::C_getCurrentGrob) grob <- findGrob(getUnitData(unit, index), savedgrob) @@ -161,8 +161,8 @@ isPureNullUnitGrobDim <- function(unit, index, dimFunction) { result <- isPureNullUnit(dimFunction(updatedgrob), 1) grid:::postDraw(updatedgrob) - .Call(grid:::L_setGPar, savedgpar) - .Call(grid:::L_setCurrentGrob, savedgrob) + .Call(grid:::C_setGPar, savedgpar) + .Call(grid:::C_setCurrentGrob, savedgrob) result } @@ -190,7 +190,7 @@ isPureNullUnitArithmetic <- function(x, index) { # { gt <- grid.text("Hi there"); isPureNullUnit(unit(1, "grobheight", gt), 1) } == FALSE grobConversionPreDraw <- function(grobIn) { - grob <- findGrob(grobIn, .Call(grid:::L_getCurrentGrob)) + grob <- findGrob(grobIn, .Call(grid:::C_getCurrentGrob)) grid:::preDraw(grob) } diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Match.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Match.java index af640e76afc687bf585d135996c0770cbf667552..41c44bc23f77fc1acfcb0419ce20286fd084c6bc 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Match.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Match.java @@ -390,6 +390,38 @@ public abstract class Match extends RBuiltinNode.Arg4 { return RDataFactory.createIntVector(result, setCompleteState(matchAll, nomatch)); } + @Specialization + @TruffleBoundary + protected RIntVector match(RAbstractDoubleVector x, RAbstractLogicalVector table, int nomatch) { + int[] result = initResult(x.getLength(), nomatch); + boolean matchAll = true; + int[] values = {RRuntime.LOGICAL_TRUE, RRuntime.LOGICAL_FALSE, RRuntime.LOGICAL_NA}; + int[] indexes = new int[values.length]; + for (int i = 0; i < values.length; i++) { + byte value = (byte) values[i]; + for (int j = 0; j < table.getLength(); j++) { + if (table.getDataAt(j) == value) { + indexes[i] = j + 1; + break; + } + } + values[i] = RRuntime.logical2int(value); + } + for (int i = 0; i < result.length; i++) { + double xx = x.getDataAt(i); + boolean match = false; + for (int j = 0; j < values.length; j++) { + if (xx == values[j] && indexes[j] != 0) { + result[i] = indexes[j]; + match = true; + break; + } + } + matchAll &= match; + } + return RDataFactory.createIntVector(result, setCompleteState(matchAll, nomatch)); + } + @Specialization(guards = "x.getLength() == 1") @TruffleBoundary protected int matchSizeOne(RAbstractStringVector x, RAbstractStringVector table, int nomatch, diff --git a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/RInternalCode.java b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/RInternalCode.java index 90d023e31c62ba4bf10880c1224d146134ad2096..ee2c370c74c3b364bccce555def88ef5bc516574 100644 --- a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/RInternalCode.java +++ b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/RInternalCode.java @@ -80,7 +80,7 @@ public final class RInternalCode { this.evaluatedEnvironment = env; } RFunction fun = (RFunction) env.get(name); - assert fun != null; + assert fun != null : "No internal function '" + name + "' found"; return fun; }