Skip to content
Snippets Groups Projects
Commit 3e2e325d authored by Zbynek Slajchrt's avatar Zbynek Slajchrt
Browse files

Recent changes in FastR grid package adapted to GNUR 3.4.0

parent 61081ca7
No related branches found
No related tags found
No related merge requests found
......@@ -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;
......
......@@ -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)
}
......
......@@ -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,
......
......@@ -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;
}
......
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