Skip to content
Snippets Groups Projects
Commit 4573844c authored by Mick Jordan's avatar Mick Jordan
Browse files

Merge

parents cac2d1ae 4ade790d
Branches
No related tags found
No related merge requests found
......@@ -469,8 +469,8 @@ final class REngine implements Engine, Engine.Timings {
}
/**
* Creates an anonymous function, with no arguments to evaluate {@code body}. If {@body}
* is a not a syntax node, uses a simple {@link BodyNode} with no source information. Otherwise
* Creates an anonymous function, with no arguments to evaluate {@code body}. If {@body} is a
* not a syntax node, uses a simple {@link BodyNode} with no source information. Otherwise
* creates a {@link FunctionStatementsNode} using {@code body}. and ensures that the
* {@link FunctionBodyNode} has a {@link SourceSection}, for instrumentation, although the
* anonymous {@link FunctionDefinitionNode} itself does not need one.
......
......@@ -35,6 +35,8 @@ import com.oracle.truffle.r.nodes.builtin.*;
import com.oracle.truffle.r.nodes.instrument.*;
import com.oracle.truffle.r.runtime.*;
import com.oracle.truffle.r.runtime.context.*;
import com.oracle.truffle.r.runtime.context.Engine.IncompleteSourceException;
import com.oracle.truffle.r.runtime.context.Engine.ParseException;
import com.oracle.truffle.r.runtime.ffi.*;
import com.oracle.truffle.r.runtime.nodes.*;
......@@ -112,7 +114,21 @@ public final class TruffleRLanguage extends TruffleLanguage<RContext> {
@Override
protected CallTarget parse(Source source, Node context, String... argumentNames) throws IOException {
return RContext.getEngine().parseToCallTarget(source);
try {
return RContext.getEngine().parseToCallTarget(source);
} catch (IncompleteSourceException e) {
throw new com.oracle.truffle.api.vm.IncompleteSourceException(e);
} catch (ParseException e) {
return new CallTarget() {
public Object call(Object... arguments) {
try {
throw e.throwAsRError();
} catch (@SuppressWarnings("hiding") RError e) {
return null;
}
}
};
}
}
@Override
......
/*
* Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
......@@ -221,7 +221,7 @@ public class RCommand {
*/
try {
vm.eval(subSource);
} catch (IncompleteSourceException e) {
} catch (IncompleteSourceException | com.oracle.truffle.api.vm.IncompleteSourceException e) {
// read another line of input
consoleHandler.setPrompt(doEcho ? continuePrompt : null);
String additionalInput = consoleHandler.readLine();
......
......@@ -563,12 +563,14 @@ public final class RCallNode extends RNode implements RSyntaxNode {
if (newFunctionNode instanceof NamedRNode) {
newFunctionNode = ((NamedRNode) newFunctionNode).original;
}
if (newFunctionNode instanceof ConstantNode &&
(((ConstantNode) newFunctionNode).getValue() instanceof RSymbol || ((ConstantNode) newFunctionNode).getValue() instanceof RAbstractVector)) {
return ((ConstantNode) newFunctionNode).getValue();
} else {
return RDataFactory.createLanguage(newFunctionNode);
if (newFunctionNode instanceof ConstantNode) {
Object funcNodeValue = ((ConstantNode) newFunctionNode).getValue();
if (funcNodeValue instanceof RSymbol || funcNodeValue instanceof RAbstractVector || funcNodeValue instanceof Integer || funcNodeValue instanceof Double ||
funcNodeValue instanceof Byte || funcNodeValue instanceof String) {
return ((ConstantNode) newFunctionNode).getValue();
}
}
return RDataFactory.createLanguage(newFunctionNode);
}
} else {
Arguments<RSyntaxNode> args = getArguments();
......
......@@ -154,9 +154,7 @@ public class FastRTckTest extends TruffleTCK {
protected String invalidCode() {
// @formatter:off
return
"main <- f unction() {\n" +
" re turn(42)\n" +
"}\n";
"main <- function() {\n";
// @formatter:on
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment