Skip to content
Snippets Groups Projects
Commit 1d442e9f authored by Adam Welc's avatar Adam Welc Committed by Mick Jordan
Browse files

Moved a flag determining browser mode to context.

parent 97088749
No related branches found
No related tags found
No related merge requests found
......@@ -52,7 +52,7 @@ public abstract class Quit extends RBuiltinNode {
@Specialization
@TruffleBoundary
protected Object doQuit(RAbstractStringVector saveArg, final int status, final byte runLastIn) {
if (BrowserInteractNode.inBrowser()) {
if (RContext.getInstance().isInBrowser()) {
RError.warning(this, RError.Message.BROWSER_QUIT);
return RNull.instance;
}
......
......@@ -61,16 +61,6 @@ public abstract class BrowserInteractNode extends RNode {
private static final String BROWSER_SOURCE = "<browser_input>";
private static String lastEmptyLineCommand = "n";
/**
* This used by {@link Quit} to prevent a "quit" from the browser (as per GnuR). If we supported
* multiple interactive contexts, this would need become context specific.
*/
private static boolean inBrowser;
public static boolean inBrowser() {
return inBrowser;
}
@Specialization
protected int interact(VirtualFrame frame) {
CompilerDirectives.transferToInterpreter();
......@@ -80,7 +70,7 @@ public abstract class BrowserInteractNode extends RNode {
ch.setPrompt(browserPrompt(RArguments.getDepth(frame)));
int exitMode = NEXT;
try {
inBrowser = true;
RContext.getInstance().setInBrowser(true);
LW: while (true) {
String input = ch.readLine();
if (input != null) {
......@@ -141,7 +131,7 @@ public abstract class BrowserInteractNode extends RNode {
}
} finally {
ch.setPrompt(savedPrompt);
inBrowser = false;
RContext.getInstance().setInBrowser(false);
}
return exitMode;
}
......
......@@ -292,6 +292,11 @@ public final class RContext extends ExecutionContext implements TruffleObject {
private boolean nullS4Object = false;
/**
* This used to prevent a "quit" from the browser (as per GnuR).
*/
private boolean inBrowser = false;
private boolean active;
private PrimitiveMethodsInfo primitiveMethodsInfo;
......@@ -617,6 +622,14 @@ public final class RContext extends ExecutionContext implements TruffleObject {
nullS4Object = on;
}
public boolean isInBrowser() {
return inBrowser;
}
public void setInBrowser(boolean on) {
inBrowser = on;
}
public boolean allowPrimitiveMethods() {
return allowPrimitiveMethods;
}
......
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