Skip to content

Commit 7286778

Browse files
zslajchrtansalond
authored andcommitted
Several fixes for shiny 1.1.0
(cherry picked from commit bc02f96)
1 parent 82e5e31 commit 7286778

File tree

5 files changed

+91
-5
lines changed

5 files changed

+91
-5
lines changed

README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,3 +119,25 @@ We encourage contributions, and invite interested developers to join in.
119119
Prospective contributors need to sign the [Oracle Contributor Agreement (OCA)](http://www.oracle.com/technetwork/community/oca-486395.html).
120120
The access point for contributions, issues and questions about FastR is the [GitHub repository ](https://github.com/graalvm/fastr)
121121

122+
## Troubleshooting
123+
124+
### Build fails when generating R grammar
125+
126+
This problem manifests by the following error message in the build output:
127+
128+
`Parser failed to execute command`
129+
130+
followed by a series of parser errors, such as:
131+
132+
`error(170): R.g:<LINE>:<COL>: the .. range operator isn't allowed in parser rules`
133+
134+
It seems to be an ANTLR issue occurring when `LANG`, `LC_ALL` and `LC_CTYPE` environment
135+
variables are not set to the same value.
136+
137+
The solution is to set those variables to the same value, e.g.
138+
139+
```
140+
export LANG=en_US.UTF-8
141+
export LC_ALL=en_US.UTF-8
142+
export LC_CTYPE=en_US.UTF-8
143+
```

com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/fastrGrid/FastRGridExternalLookup.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
import com.oracle.truffle.r.library.fastrGrid.color.RGB;
3232
import com.oracle.truffle.r.library.fastrGrid.grDevices.DevCairo;
3333
import com.oracle.truffle.r.library.fastrGrid.grDevices.DevCurr;
34+
import com.oracle.truffle.r.library.fastrGrid.grDevices.DevSet;
3435
import com.oracle.truffle.r.library.fastrGrid.grDevices.DevHoldFlush;
3536
import com.oracle.truffle.r.library.fastrGrid.grDevices.DevOff;
3637
import com.oracle.truffle.r.library.fastrGrid.grDevices.DevSize;
@@ -63,6 +64,8 @@ public static RExternalBuiltinNode lookupDotExternal(String name) {
6364
return new DevSize();
6465
case "devcur":
6566
return new DevCurr();
67+
case "devset":
68+
return DevSet.create();
6669
case "devoff":
6770
return DevOff.create();
6871
case "svgstring":

com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/fastrGrid/GridContext.java

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,15 +59,15 @@ public final class GridContext {
5959
private int currentDeviceIdx = 0;
6060

6161
private GridContext() {
62-
devices.add(new DeviceAndState(null, null));
62+
devices.add(new DeviceAndState(null, null, null));
6363
}
6464

6565
private GridContext(GridContext parent) {
6666
// initialized grid in spawned context. Grid R code calls initGrid(gridEnv) only once and
6767
// then sets global variable to remember to not call it again, but we need to initialize
6868
// grid context in newly spawned context, so we do it manually here.
6969
gridState.init(parent.getGridState().getGridEnv());
70-
devices.add(new DeviceAndState(null, null));
70+
devices.add(new DeviceAndState(null, null, null));
7171
}
7272

7373
public static GridContext getContext(RContext rCtx) {
@@ -120,10 +120,17 @@ public void setCurrentDevice(String name, GridDevice currentDevice, String filen
120120
RGridGraphicsAdapter.addDevice(rCtx, name);
121121
RGridGraphicsAdapter.setCurrentDevice(rCtx, name);
122122
currentDeviceIdx = this.devices.size();
123-
this.devices.add(new DeviceAndState(currentDevice, filenamePattern));
123+
this.devices.add(new DeviceAndState(name, currentDevice, filenamePattern));
124124
assert devices.size() == RGridGraphicsAdapter.getDevicesCount() : devices.size() + " vs " + RGridGraphicsAdapter.getDevicesCount();
125125
}
126126

127+
public void setCurrentDevice(int deviceIdx) {
128+
assert deviceIdx > 0 && deviceIdx < this.devices.size();
129+
RContext rCtx = RContext.getInstance();
130+
RGridGraphicsAdapter.setCurrentDevice(rCtx, this.devices.get(deviceIdx).name);
131+
currentDeviceIdx = deviceIdx;
132+
}
133+
127134
public void openDefaultDevice() {
128135
String defaultDev = RGridGraphicsAdapter.getDefaultDevice();
129136
if (defaultDev.equals("awt") || defaultDev.startsWith("X11")) {
@@ -190,10 +197,12 @@ private void safeOpenImageDev(String filename, String formatName) {
190197
}
191198

192199
private static final class DeviceAndState {
200+
final String name;
193201
final GridDevice device;
194202
final GridDeviceState state;
195203

196-
DeviceAndState(GridDevice device, String filenamePattern) {
204+
DeviceAndState(String name, GridDevice device, String filenamePattern) {
205+
this.name = name;
197206
this.device = device;
198207
this.state = new GridDeviceState(filenamePattern);
199208
}
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
/*
2+
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
3+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+
*
5+
* This code is free software; you can redistribute it and/or modify it
6+
* under the terms of the GNU General Public License version 3 only, as
7+
* published by the Free Software Foundation.
8+
*
9+
* This code is distributed in the hope that it will be useful, but WITHOUT
10+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12+
* version 3 for more details (a copy is included in the LICENSE file that
13+
* accompanied this code).
14+
*
15+
* You should have received a copy of the GNU General Public License version
16+
* 3 along with this work; if not, write to the Free Software Foundation,
17+
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18+
*
19+
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20+
* or visit www.oracle.com if you need additional information or have any
21+
* questions.
22+
*/
23+
package com.oracle.truffle.r.library.fastrGrid.grDevices;
24+
25+
import static com.oracle.truffle.r.nodes.builtin.CastBuilder.Predef.numericValue;
26+
27+
import com.oracle.truffle.api.dsl.Specialization;
28+
import com.oracle.truffle.r.library.fastrGrid.GridContext;
29+
import com.oracle.truffle.r.library.fastrGrid.graphics.RGridGraphicsAdapter;
30+
import com.oracle.truffle.r.nodes.builtin.RExternalBuiltinNode;
31+
import com.oracle.truffle.r.runtime.context.RContext;
32+
33+
public abstract class DevSet extends RExternalBuiltinNode.Arg1 {
34+
35+
static {
36+
Casts casts = new Casts(DevSet.class);
37+
casts.arg(0).mustBe(numericValue()).asIntegerVector().findFirst();
38+
}
39+
40+
public static DevSet create() {
41+
return DevSetNodeGen.create();
42+
}
43+
44+
@Specialization
45+
public int doInteger(int deviceIdx) {
46+
RContext rCtx = RContext.getInstance();
47+
RGridGraphicsAdapter.fixupDevicesVariable(rCtx);
48+
GridContext.getContext(rCtx).setCurrentDevice(deviceIdx - 1);
49+
return deviceIdx;
50+
}
51+
52+
}

com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/FrameFunctions.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -507,7 +507,7 @@ protected Object sysCalls(VirtualFrame frame) {
507507
@Override
508508
public Object apply(Frame f) {
509509
RCaller currentCall = RArguments.getCall(f);
510-
if (!currentCall.isPromise() && currentCall.getDepth() <= depth) {
510+
if (currentCall.isValidCaller() && !currentCall.isPromise() && currentCall.getDepth() <= depth) {
511511
result = RDataFactory.createPairList(createCall(currentCall), result);
512512
}
513513
return (!currentCall.isPromise() && RArguments.getDepth(f) == 1) ? result : null;

0 commit comments

Comments
 (0)