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

Merge pull request #168 in G/fastr from...

Merge pull request #168 in G/fastr from ~LUKAS.STADLER_ORACLE.COM/fastr:feature/remove_NamedRNode to master

* commit 'd210c2ee':
  remove NamedRNode (use field in RLanguage instead)
parents 885084fd d210c2ee
No related branches found
No related tags found
No related merge requests found
......@@ -36,7 +36,6 @@ import com.oracle.truffle.r.nodes.RASTUtils;
import com.oracle.truffle.r.nodes.RRootNode;
import com.oracle.truffle.r.nodes.access.ConstantNode;
import com.oracle.truffle.r.nodes.access.WriteVariableNode;
import com.oracle.truffle.r.nodes.access.variables.NamedRNode;
import com.oracle.truffle.r.nodes.access.variables.ReadVariableNode;
import com.oracle.truffle.r.nodes.builtin.RBuiltinNode;
import com.oracle.truffle.r.nodes.builtin.RBuiltinRootNode;
......@@ -233,19 +232,18 @@ class RRuntimeASTAccessImpl implements RRuntimeASTAccess {
return RNull.instance;
} else if (repType == RLanguage.RepType.CALL) {
RStringVector formals = list.getNames();
boolean nullFormals = formals == null;
RNode fn = unwrapToRNode(list.getDataAtAsObject(0));
if (!nullFormals && formals.getLength() > 0 && formals.getDataAt(0).length() > 0) {
fn = new NamedRNode(fn, formals.getDataAt(0));
}
RSyntaxNode[] arguments = new RSyntaxNode[length - 1];
String[] sigNames = new String[arguments.length];
for (int i = 1; i < length; i++) {
arguments[i - 1] = (RSyntaxNode) unwrapToRNode(list.getDataAtAsObject(i));
String formal = nullFormals ? null : formals.getDataAt(i);
String formal = formals == null ? null : formals.getDataAt(i);
sigNames[i - 1] = formal != null && formal.length() > 0 ? formal : null;
}
RNode fn = unwrapToRNode(list.getDataAtAsObject(0));
RLanguage result = RDataFactory.createLanguage(RASTUtils.createCall(fn, false, ArgumentsSignature.get(sigNames), arguments).asRNode());
if (formals != null && formals.getLength() > 0 && formals.getDataAt(0).length() > 0) {
result.setCallLHSName(formals.getDataAt(0));
}
return addAttributes(result, list);
} else if (repType == RLanguage.RepType.FUNCTION) {
RList argsList = (RList) list.getDataAt(1);
......@@ -315,10 +313,9 @@ class RRuntimeASTAccessImpl implements RRuntimeASTAccess {
*/
boolean hasName = false;
String functionName = "";
RNode fnNode = call.getFunctionNode();
if (fnNode instanceof NamedRNode) {
if (rl.getCallLHSName() != null) {
hasName = true;
functionName = ((NamedRNode) fnNode).name;
functionName = rl.getCallLHSName();
}
ArgumentsSignature sig = call.getSyntaxSignature();
if (!hasName) {
......
......@@ -30,7 +30,6 @@ import com.oracle.truffle.api.nodes.NodeUtil;
import com.oracle.truffle.api.source.SourceSection;
import com.oracle.truffle.r.nodes.access.ConstantNode;
import com.oracle.truffle.r.nodes.access.ReadVariadicComponentNode;
import com.oracle.truffle.r.nodes.access.variables.NamedRNode;
import com.oracle.truffle.r.nodes.access.variables.ReadVariableNode;
import com.oracle.truffle.r.nodes.builtin.RBuiltinNode;
import com.oracle.truffle.r.nodes.function.PromiseNode.VarArgNode;
......@@ -229,8 +228,6 @@ public class RASTUtils {
SourceSection sourceSection = sourceUnavailable ? RSyntaxNode.SOURCE_UNAVAILABLE : RSyntaxNode.EAGER_DEPARSE;
if (fn instanceof ReadVariableNode) {
return RCallNode.createCall(sourceSection, (ReadVariableNode) fn, signature, arguments);
} else if (fn instanceof NamedRNode) {
return RCallNode.createCall(RSyntaxNode.SOURCE_UNAVAILABLE, (NamedRNode) fn, signature, arguments);
} else if (fn instanceof RCallNode) {
return RCallNode.createCall(sourceSection, (RCallNode) fn, signature, arguments);
} else {
......
/*
* Copyright (c) 2015, 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
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.oracle.truffle.r.nodes.access.variables;
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.r.runtime.nodes.RNode;
import com.oracle.truffle.r.runtime.nodes.RSyntaxNode;
/**
* Used when creating an {@code RCallNode} with a function that has a "name". This could subclass
* {@link ReadVariableNode} but that is currently final.
*/
public final class NamedRNode extends RNode {
private final RNode original;
public final String name;
public NamedRNode(RNode original, String name) {
this.original = original;
this.name = name;
}
@Override
public Object execute(VirtualFrame frame) {
return original.execute(frame);
}
@Override
public RSyntaxNode getRSyntaxNode() {
return original.asRSyntaxNode();
}
}
......@@ -59,6 +59,7 @@ public class RLanguage extends RSharingAttributeStorage implements RAbstractCont
}
private RBaseNode rep;
private String callLHSName;
/**
* Lazily computed value.
......@@ -82,6 +83,14 @@ public class RLanguage extends RSharingAttributeStorage implements RAbstractCont
this.rep = rep;
}
public String getCallLHSName() {
return callLHSName;
}
public void setCallLHSName(String callLHSName) {
this.callLHSName = callLHSName;
}
@Override
public RType getRType() {
return RType.Language;
......
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