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

fix for RRuntimeASTAccess.fromList with named, not-variable formal arg

parent 838c7c3f
Branches
No related tags found
No related merge requests found
...@@ -100,8 +100,8 @@ public class RRuntimeASTAccessImpl implements RRuntimeASTAccess { ...@@ -100,8 +100,8 @@ public class RRuntimeASTAccessImpl implements RRuntimeASTAccess {
RStringVector formals = list.getNames(); RStringVector formals = list.getNames();
boolean nullFormals = formals == null; boolean nullFormals = formals == null;
RNode fn = unwrapToRNode(list.getDataAtAsObject(0)); RNode fn = unwrapToRNode(list.getDataAtAsObject(0));
if (!nullFormals && fn instanceof ReadVariableNode && formals.getLength() > 0 && formals.getDataAt(0).length() > 0) { if (!nullFormals && formals.getLength() > 0 && formals.getDataAt(0).length() > 0) {
fn = new NamedReadVariableNode((ReadVariableNode) fn, formals.getDataAt(0)); fn = new NamedRNode(fn, formals.getDataAt(0));
} }
RSyntaxNode[] arguments = new RSyntaxNode[length - 1]; RSyntaxNode[] arguments = new RSyntaxNode[length - 1];
String[] sigNames = new String[arguments.length]; String[] sigNames = new String[arguments.length];
...@@ -156,9 +156,9 @@ public class RRuntimeASTAccessImpl implements RRuntimeASTAccess { ...@@ -156,9 +156,9 @@ public class RRuntimeASTAccessImpl implements RRuntimeASTAccess {
boolean hasName = false; boolean hasName = false;
String functionName = ""; String functionName = "";
RNode fnNode = RASTUtils.getFunctionNode(node); RNode fnNode = RASTUtils.getFunctionNode(node);
if (fnNode instanceof NamedReadVariableNode) { if (fnNode instanceof NamedRNode) {
hasName = true; hasName = true;
functionName = ((NamedReadVariableNode) fnNode).name; functionName = ((NamedRNode) fnNode).name;
} }
Arguments<RSyntaxNode> args = RASTUtils.findCallArguments(node); Arguments<RSyntaxNode> args = RASTUtils.findCallArguments(node);
ArgumentsSignature sig = args.getSignature(); ArgumentsSignature sig = args.getSignature();
......
...@@ -199,8 +199,8 @@ public class RASTUtils { ...@@ -199,8 +199,8 @@ public class RASTUtils {
return RCallNode.createCall(sourceSection, RASTUtils.createReadVariableNode(((String) fn)), signature, arguments); return RCallNode.createCall(sourceSection, RASTUtils.createReadVariableNode(((String) fn)), signature, arguments);
} else if (fn instanceof ReadVariableNode) { } else if (fn instanceof ReadVariableNode) {
return RCallNode.createCall(sourceSection, (ReadVariableNode) fn, signature, arguments); return RCallNode.createCall(sourceSection, (ReadVariableNode) fn, signature, arguments);
} else if (fn instanceof NamedReadVariableNode) { } else if (fn instanceof NamedRNode) {
return RCallNode.createCall(RSyntaxNode.SOURCE_UNAVAILABLE, (NamedReadVariableNode) fn, signature, arguments); return RCallNode.createCall(RSyntaxNode.SOURCE_UNAVAILABLE, (NamedRNode) fn, signature, arguments);
} else if (fn instanceof GroupDispatchNode) { } else if (fn instanceof GroupDispatchNode) {
GroupDispatchNode gdcn = (GroupDispatchNode) fn; GroupDispatchNode gdcn = (GroupDispatchNode) fn;
return GroupDispatchNode.create(gdcn.getGenericName(), gdcn.getCallSrc(), signature, arguments); return GroupDispatchNode.create(gdcn.getGenericName(), gdcn.getCallSrc(), signature, arguments);
......
...@@ -30,11 +30,11 @@ import com.oracle.truffle.r.runtime.nodes.RSyntaxNode; ...@@ -30,11 +30,11 @@ import com.oracle.truffle.r.runtime.nodes.RSyntaxNode;
* Used when creating an {@code RCallNode} with a function that has a "name". This could subclass * Used when creating an {@code RCallNode} with a function that has a "name". This could subclass
* {@link ReadVariableNode} but that is currently final. * {@link ReadVariableNode} but that is currently final.
*/ */
public final class NamedReadVariableNode extends RNode { public final class NamedRNode extends RNode {
public final ReadVariableNode original; public final RNode original;
public final String name; public final String name;
public NamedReadVariableNode(ReadVariableNode original, String name) { public NamedRNode(RNode original, String name) {
this.original = original; this.original = original;
this.name = name; this.name = name;
} }
...@@ -46,6 +46,6 @@ public final class NamedReadVariableNode extends RNode { ...@@ -46,6 +46,6 @@ public final class NamedReadVariableNode extends RNode {
@Override @Override
public RSyntaxNode getRSyntaxNode() { public RSyntaxNode getRSyntaxNode() {
return original; return original.asRSyntaxNode();
} }
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment