Skip to content
Snippets Groups Projects
Commit 75899d97 authored by Lukas Stadler's avatar Lukas Stadler
Browse files

Merge pull request #165 in G/fastr from jtulach/NoIOException to master

* commit 'c8319850':
  Wrap only IOException to RuntimeException. Leave other exceptions untouched.
  Adjusting the code to not expect IOException from PolyglotEngine.eval and co.
parents 46e1d0dc c8319850
Branches
No related tags found
No related merge requests found
...@@ -216,6 +216,7 @@ public class RCommand { ...@@ -216,6 +216,7 @@ public class RCommand {
*/ */
try { try {
vm.eval(source); vm.eval(source);
emitIO();
} catch (IncompleteSourceException | com.oracle.truffle.api.vm.IncompleteSourceException e) { } catch (IncompleteSourceException | com.oracle.truffle.api.vm.IncompleteSourceException e) {
// read another line of input // read another line of input
consoleHandler.setPrompt(doEcho ? continuePrompt : null); consoleHandler.setPrompt(doEcho ? continuePrompt : null);
...@@ -279,6 +280,7 @@ public class RCommand { ...@@ -279,6 +280,7 @@ public class RCommand {
PolyglotEngine.Value echoValue; PolyglotEngine.Value echoValue;
try { try {
echoValue = vm.eval(GET_ECHO); echoValue = vm.eval(GET_ECHO);
emitIO();
Object echo = echoValue.get(); Object echo = echoValue.get();
if (echo instanceof TruffleObject) { if (echo instanceof TruffleObject) {
RLogicalVector echoVec = echoValue.as(RLogicalVector.class); RLogicalVector echoVec = echoValue.as(RLogicalVector.class);
...@@ -296,4 +298,7 @@ public class RCommand { ...@@ -296,4 +298,7 @@ public class RCommand {
private static String getContinuePrompt() { private static String getContinuePrompt() {
return RRuntime.asString(RRuntime.asAbstractVector(RContext.getInstance().stateROptions.getValue("continue"))); return RRuntime.asString(RRuntime.asAbstractVector(RContext.getInstance().stateROptions.getValue("continue")));
} }
private static void emitIO() throws IOException {
}
} }
...@@ -53,12 +53,16 @@ public class FastRInterop { ...@@ -53,12 +53,16 @@ public class FastRInterop {
try { try {
callTarget = RContext.getInstance().getEnv().parse(sourceObject); callTarget = RContext.getInstance().getEnv().parse(sourceObject);
emitIO();
} catch (IOException e) { } catch (IOException e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} }
return callTarget.call(); return callTarget.call();
} }
private void emitIO() throws IOException {
}
} }
@RBuiltin(name = ".fastr.interop.export", visibility = RVisibility.OFF, kind = RBuiltinKind.PRIMITIVE, parameterNames = {"name", "value"}) @RBuiltin(name = ".fastr.interop.export", visibility = RVisibility.OFF, kind = RBuiltinKind.PRIMITIVE, parameterNames = {"name", "value"})
......
...@@ -192,7 +192,7 @@ public final class RContext extends ExecutionContext implements TruffleObject { ...@@ -192,7 +192,7 @@ public final class RContext extends ExecutionContext implements TruffleObject {
PolyglotEngine vm = info.apply(PolyglotEngine.newBuilder()).build(); PolyglotEngine vm = info.apply(PolyglotEngine.newBuilder()).build();
try { try {
setContext(vm.eval(GET_CONTEXT).as(RContext.class)); setContext(vm.eval(GET_CONTEXT).as(RContext.class));
} catch (IOException e1) { } catch (Exception e1) {
throw new RInternalError(e1, "error while initializing eval thread"); throw new RInternalError(e1, "error while initializing eval thread");
} }
try { try {
......
...@@ -168,6 +168,7 @@ public final class FastRSession implements RSession { ...@@ -168,6 +168,7 @@ public final class FastRSession implements RSession {
main = info.apply(PolyglotEngine.newBuilder()).build(); main = info.apply(PolyglotEngine.newBuilder()).build();
try { try {
mainContext = main.eval(GET_CONTEXT).as(RContext.class); mainContext = main.eval(GET_CONTEXT).as(RContext.class);
emitIO();
} catch (IOException e) { } catch (IOException e) {
throw new RuntimeException("error while retrieving test context", e); throw new RuntimeException("error while retrieving test context", e);
} }
...@@ -248,6 +249,7 @@ public final class FastRSession implements RSession { ...@@ -248,6 +249,7 @@ public final class FastRSession implements RSession {
try { try {
vm.eval(source); vm.eval(source);
input = consoleHandler.readLine(); input = consoleHandler.readLine();
emitIO();
} catch (IncompleteSourceException | com.oracle.truffle.api.vm.IncompleteSourceException e) { } catch (IncompleteSourceException | com.oracle.truffle.api.vm.IncompleteSourceException e) {
String additionalInput = consoleHandler.readLine(); String additionalInput = consoleHandler.readLine();
if (additionalInput == null) { if (additionalInput == null) {
...@@ -289,4 +291,7 @@ public final class FastRSession implements RSession { ...@@ -289,4 +291,7 @@ public final class FastRSession implements RSession {
public String name() { public String name() {
return "FastR"; return "FastR";
} }
static void emitIO() throws IOException {
}
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment