diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Quit.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Quit.java index ce221bec417b545f6a1c3652b5c75f71bd2e0e2f..764ce8d805b048b0ebd42bc0fc2cb1115bb761a7 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Quit.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Quit.java @@ -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; } diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/helpers/BrowserInteractNode.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/helpers/BrowserInteractNode.java index 0376ce1a06b9798d26ac86dc8ffa1057ec0d80da..38452e83e0b92842ed44645ea53d5495d69f711a 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/helpers/BrowserInteractNode.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/helpers/BrowserInteractNode.java @@ -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; } diff --git a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/context/RContext.java b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/context/RContext.java index 5d7f114ca44eae9b2a7736f980eef314adc4dd96..fd38892ac1b0a8ef66097e5935288fed04eed03f 100644 --- a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/context/RContext.java +++ b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/context/RContext.java @@ -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; }