diff --git a/com.oracle.truffle.r.engine/src/com/oracle/truffle/r/engine/RRuntimeASTAccessImpl.java b/com.oracle.truffle.r.engine/src/com/oracle/truffle/r/engine/RRuntimeASTAccessImpl.java index 2a466c21c34681bc37a8451ee4af6caead6fb9fc..1cc9f5502c982708473f2bfa859f3c34486382a9 100644 --- a/com.oracle.truffle.r.engine/src/com/oracle/truffle/r/engine/RRuntimeASTAccessImpl.java +++ b/com.oracle.truffle.r.engine/src/com/oracle/truffle/r/engine/RRuntimeASTAccessImpl.java @@ -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) { diff --git a/com.oracle.truffle.r.engine/src/com/oracle/truffle/r/engine/shell/RCommand.java b/com.oracle.truffle.r.engine/src/com/oracle/truffle/r/engine/shell/RCommand.java index 5b675e59eb716b5be109f2685bdbb83f8a1a6600..3911f4468da9e666304337ef8daead8ddaa8ec5c 100644 --- a/com.oracle.truffle.r.engine/src/com/oracle/truffle/r/engine/shell/RCommand.java +++ b/com.oracle.truffle.r.engine/src/com/oracle/truffle/r/engine/shell/RCommand.java @@ -298,6 +298,7 @@ public class RCommand { return RRuntime.asString(RRuntime.asAbstractVector(RContext.getInstance().stateROptions.getValue("continue"))); } + @SuppressWarnings("unused") private static void emitIO() throws IOException { } } diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/FrameFunctions.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/FrameFunctions.java index e3155732010bd228e65006444219556897d93c0a..3b17aa2d14ded603332a137dfb3a337dadd5baf4 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/FrameFunctions.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/FrameFunctions.java @@ -53,7 +53,6 @@ import com.oracle.truffle.r.nodes.function.PromiseNode; import com.oracle.truffle.r.nodes.function.PromiseNode.VarArgNode; import com.oracle.truffle.r.nodes.function.PromiseNode.VarArgsPromiseNode; import com.oracle.truffle.r.nodes.function.RCallNode; -import com.oracle.truffle.r.nodes.function.UnmatchedArguments; import com.oracle.truffle.r.runtime.ArgumentsSignature; import com.oracle.truffle.r.runtime.HasSignature; import com.oracle.truffle.r.runtime.RArguments; @@ -234,8 +233,7 @@ public class FrameFunctions { RCallNode callNode = (RCallNode) RASTUtils.unwrap(call.getRep()); CallArgumentsNode callArgs = callNode.createArguments(null, false, false); ArgumentsSignature inputVarArgSignature = callArgs.containsVarArgsSymbol() ? CallArgumentsNode.getVarargsAndNames(cframe).getSignature() : null; - UnmatchedArguments executeFlatten = callArgs.unrollArguments(inputVarArgSignature); - RNode[] matchedArgNodes = ArgumentMatcher.matchArguments((RRootNode) definition.getRootNode(), executeFlatten, null, null, true).getArguments(); + RNode[] matchedArgNodes = ArgumentMatcher.matchArguments((RRootNode) definition.getRootNode(), callArgs, inputVarArgSignature, null, null, true).getArguments(); ArgumentsSignature sig = ((HasSignature) definition.getRootNode()).getSignature(); // expand any varargs ArrayList<RNode> nodes = new ArrayList<>(); diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/fastr/FastRInterop.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/fastr/FastRInterop.java index 36548916431d5b7eed98771b6592ccacdf59a98c..06daa8d3da89d6e579c97fd7240d2b04f651bc36 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/fastr/FastRInterop.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/fastr/FastRInterop.java @@ -60,6 +60,7 @@ public class FastRInterop { return callTarget.call(); } + @SuppressWarnings("unused") private void emitIO() throws IOException { } } diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/RASTUtils.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/RASTUtils.java index 098ec29439080109c0b0c614fb0f34e0e2546096..42f0b1a887eaf84e4589b76c6fba5db5e0d32f5b 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/RASTUtils.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/RASTUtils.java @@ -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 { diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/variables/NamedRNode.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/variables/NamedRNode.java deleted file mode 100644 index db51c51ecf5f1dfa8237e787eec3364188efb8cf..0000000000000000000000000000000000000000 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/variables/NamedRNode.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * 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(); - } -} diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/function/ArgumentMatcher.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/function/ArgumentMatcher.java index aa919f2e6f4d7e37624ddeed5e6b753b343f5f4b..1023abc190bd2ded474b10747834df7d325fb1d7 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/function/ArgumentMatcher.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/function/ArgumentMatcher.java @@ -37,6 +37,7 @@ import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.r.nodes.RRootNode; import com.oracle.truffle.r.nodes.access.ConstantNode; import com.oracle.truffle.r.nodes.function.PromiseNode.VarArgNode; +import com.oracle.truffle.r.runtime.Arguments; import com.oracle.truffle.r.runtime.ArgumentsSignature; import com.oracle.truffle.r.runtime.RArguments; import com.oracle.truffle.r.runtime.RArguments.S3DefaultArguments; @@ -62,8 +63,8 @@ import com.oracle.truffle.r.runtime.nodes.RNode; * <p> * {@link ArgumentMatcher} serves the purpose of matching {@link CallArgumentsNode} to * {@link FormalArguments} of a specific function, see - * {@link #matchArguments(RRootNode, UnmatchedArguments, S3DefaultArguments, RBaseNode, boolean)} . - * The other match functions are used for special cases, where builtins make it necessary to + * {@link #matchArguments(RRootNode, CallArgumentsNode, ArgumentsSignature, S3DefaultArguments, RBaseNode, boolean)} + * . The other match functions are used for special cases, where builtins make it necessary to * re-match parameters, e.g.: * {@link #matchArgumentsEvaluated(RRootNode, RArgsValuesAndNames, S3DefaultArguments, boolean, RBaseNode)} * for 'UseMethod'. @@ -132,13 +133,27 @@ public class ArgumentMatcher { * in {@link PromiseNode}s. Used for calls to all functions parsed from R code * * @param target The function which is to be called - * @param suppliedArgs The arguments supplied to the call + * @param arguments The arguments supplied to the call * @param callingNode The {@link RBaseNode} invoking the match - * @return A fresh {@link MatchedArguments} containing the arguments in correct order and - * wrapped in {@link PromiseNode}s + * @return A fresh {@link Arguments} containing the arguments in correct order and wrapped in + * {@link PromiseNode}s */ - public static MatchedArguments matchArguments(RRootNode target, UnmatchedArguments suppliedArgs, S3DefaultArguments s3DefaultArguments, RBaseNode callingNode, boolean noOpt) { - return matchNodes(target, suppliedArgs.getArguments(), suppliedArgs.getSignature(), s3DefaultArguments, callingNode, suppliedArgs, noOpt); + public static Arguments<RNode> matchArguments(RRootNode target, CallArgumentsNode arguments, ArgumentsSignature varArgSignature, S3DefaultArguments s3DefaultArguments, RBaseNode callingNode, + boolean noOpt) { + CompilerAsserts.neverPartOfCompilation(); + assert arguments.containsVarArgsSymbol() == (varArgSignature != null); + + RNode[] argNodes; + ArgumentsSignature signature; + if (!arguments.containsVarArgsSymbol()) { + argNodes = arguments.getArguments(); + signature = arguments.getSignature(); + } else { + Arguments<RNode> suppliedArgs = arguments.unrollArguments(varArgSignature); + argNodes = suppliedArgs.getArguments(); + signature = suppliedArgs.getSignature(); + } + return ArgumentMatcher.matchNodes(target, argNodes, signature, s3DefaultArguments, callingNode, arguments, noOpt); } public static MatchPermutation matchArguments(ArgumentsSignature supplied, ArgumentsSignature formal, RBaseNode callingNode, boolean forNextMethod, RBuiltinDescriptor builtin) { @@ -286,7 +301,7 @@ public class ArgumentMatcher { * and wrapped into the proper {@link PromiseNode}s and the supplied signature reordered * accordingly. */ - private static MatchedArguments matchNodes(RRootNode target, RNode[] suppliedArgs, ArgumentsSignature suppliedSignature, S3DefaultArguments s3DefaultArguments, RBaseNode callingNode, + private static Arguments<RNode> matchNodes(RRootNode target, RNode[] suppliedArgs, ArgumentsSignature suppliedSignature, S3DefaultArguments s3DefaultArguments, RBaseNode callingNode, ClosureCache closureCache, boolean noOpt) { CompilerAsserts.neverPartOfCompilation(); assert suppliedArgs.length == suppliedSignature.getLength(); @@ -382,7 +397,7 @@ public class ArgumentMatcher { resArgs[formalIndex] = wrapMatched(formals, builtin, closureCache, suppliedArgs[suppliedIndex], formalIndex, noOpt, fastPath); } } - return MatchedArguments.create(resArgs, match.resultSignature); + return Arguments.create(resArgs, match.resultSignature); } /** diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/function/CallArgumentsNode.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/function/CallArgumentsNode.java index a9fbc9be4e7a714c57cf21e8d47bc528186c9075..6359e94caa2fbf0e94bdf95af98c5b7dc4633ace 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/function/CallArgumentsNode.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/function/CallArgumentsNode.java @@ -37,6 +37,7 @@ import com.oracle.truffle.api.profiles.BranchProfile; import com.oracle.truffle.r.nodes.access.FrameSlotNode; import com.oracle.truffle.r.nodes.access.variables.ReadVariableNode; import com.oracle.truffle.r.nodes.function.PromiseHelperNode.PromiseCheckHelperNode; +import com.oracle.truffle.r.runtime.Arguments; import com.oracle.truffle.r.runtime.ArgumentsSignature; import com.oracle.truffle.r.runtime.RError; import com.oracle.truffle.r.runtime.Utils; @@ -127,42 +128,37 @@ public final class CallArgumentsNode extends RBaseNode implements UnmatchedArgum * This methods unrolls all "..." in the argument list. The result varies if the number of * arguments in the varargs or their names change. */ - public UnmatchedArguments unrollArguments(ArgumentsSignature varArgSignature) { - CompilerAsserts.neverPartOfCompilation(); - assert containsVarArgsSymbol() == (varArgSignature != null); - if (!containsVarArgsSymbol()) { - return this; - } else { - RNode[] values = new RNode[arguments.length]; - String[] newNames = new String[arguments.length]; + public Arguments<RNode> unrollArguments(ArgumentsSignature varArgSignature) { + assert containsVarArgsSymbol(); + RNode[] values = new RNode[arguments.length]; + String[] newNames = new String[arguments.length]; - int vargsSymbolsIndex = 0; - int index = 0; - for (int i = 0; i < arguments.length; i++) { - if (vargsSymbolsIndex < varArgsSymbolIndices.length && varArgsSymbolIndices[vargsSymbolsIndex] == i) { - if (varArgSignature.isEmpty()) { - // An empty "..." vanishes - values = Utils.resizeArray(values, values.length - 1); - newNames = Utils.resizeArray(newNames, newNames.length - 1); - continue; - } + int vargsSymbolsIndex = 0; + int index = 0; + for (int i = 0; i < arguments.length; i++) { + if (vargsSymbolsIndex < varArgsSymbolIndices.length && varArgsSymbolIndices[vargsSymbolsIndex] == i) { + if (varArgSignature.isEmpty()) { + // An empty "..." vanishes + values = Utils.resizeArray(values, values.length - 1); + newNames = Utils.resizeArray(newNames, newNames.length - 1); + continue; + } - values = Utils.resizeArray(values, values.length + varArgSignature.getLength() - 1); - newNames = Utils.resizeArray(newNames, newNames.length + varArgSignature.getLength() - 1); - for (int j = 0; j < varArgSignature.getLength(); j++) { - values[index] = PromiseNode.createVarArg(j); - newNames[index] = varArgSignature.getName(j); - index++; - } - vargsSymbolsIndex++; - } else { - values[index] = arguments[i]; - newNames[index] = signature.getName(i); + values = Utils.resizeArray(values, values.length + varArgSignature.getLength() - 1); + newNames = Utils.resizeArray(newNames, newNames.length + varArgSignature.getLength() - 1); + for (int j = 0; j < varArgSignature.getLength(); j++) { + values[index] = PromiseNode.createVarArg(j); + newNames[index] = varArgSignature.getName(j); index++; } + vargsSymbolsIndex++; + } else { + values[index] = arguments[i]; + newNames[index] = signature.getName(i); + index++; } - return UnrolledVariadicArguments.create(values, ArgumentsSignature.get(newNames), this); } + return Arguments.create(values, ArgumentsSignature.get(newNames)); } private ArgumentsSignature cachedVarArgsSignature; diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/function/InlinedArguments.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/function/InlinedArguments.java deleted file mode 100644 index 13239ec31744610a029341497936170368665211..0000000000000000000000000000000000000000 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/function/InlinedArguments.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * 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 - * 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.function; - -import com.oracle.truffle.r.runtime.Arguments; -import com.oracle.truffle.r.runtime.ArgumentsSignature; -import com.oracle.truffle.r.runtime.nodes.RNode; - -/** - * Simple container class for holding arguments which are going to be inlined into FastR built-ins. - */ -public final class InlinedArguments extends Arguments<RNode> { - - InlinedArguments(RNode[] evaluatedArgs, ArgumentsSignature signature) { - super(evaluatedArgs, signature); - } -} diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/function/MatchedArguments.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/function/MatchedArguments.java deleted file mode 100644 index fe8d480d0baa267a6d854b050707a370647d27c8..0000000000000000000000000000000000000000 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/function/MatchedArguments.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * 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 - * 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.function; - -import com.oracle.truffle.r.runtime.Arguments; -import com.oracle.truffle.r.runtime.ArgumentsSignature; -import com.oracle.truffle.r.runtime.nodes.RNode; - -/** - * <p> - * This class denotes a list of name/argument pairs which are in the order of the - * {@link FormalArguments} of a function. Each argument is either filled with the supplied argument, - * the default argument or <code>null</code>, if neither is provided. - * </p> - */ -public final class MatchedArguments extends Arguments<RNode> { - - private MatchedArguments(RNode[] arguments, ArgumentsSignature signature) { - super(arguments, signature); - } - - /** - * @return A fresh {@link MatchedArguments}; arguments may contain <code>null</code> iff there - * is neither a supplied argument nor a default argument - */ - static MatchedArguments create(RNode[] arguments, ArgumentsSignature signature) { - return new MatchedArguments(arguments, signature); - } -} diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/function/RCallNode.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/function/RCallNode.java index 0801bd67364246b655d09a2c95a94b1df7da0e99..4b98031ad87c5650bcce34ddc1cb34f075909cb3 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/function/RCallNode.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/function/RCallNode.java @@ -236,7 +236,7 @@ public abstract class RCallNode extends RCallBaseNode implements RSyntaxNode, RS } public Arguments<RSyntaxNode> getArguments() { - return new Arguments<>(arguments, signature); + return Arguments.create(arguments, signature); } private RArgsValuesAndNames lookupVarArgs(VirtualFrame frame) { diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/function/UnrolledVariadicArguments.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/function/UnrolledVariadicArguments.java deleted file mode 100644 index b671bfe682c05ca423bce40b3f645ee5f3e11f76..0000000000000000000000000000000000000000 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/function/UnrolledVariadicArguments.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * 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 - * 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.function; - -import java.util.IdentityHashMap; - -import com.oracle.truffle.r.runtime.Arguments; -import com.oracle.truffle.r.runtime.ArgumentsSignature; -import com.oracle.truffle.r.runtime.data.RPromise.Closure; -import com.oracle.truffle.r.runtime.nodes.RNode; - -/** - * This is a simple container class for arguments whose "..." have been unrolled and inserted into - * the original arguments, as it happens in - * {@link CallArgumentsNode#unrollArguments(ArgumentsSignature)}. - */ -public final class UnrolledVariadicArguments extends Arguments<RNode> implements UnmatchedArguments { - - private final IdentityHashMap<RNode, Closure> closureCache; - - private UnrolledVariadicArguments(RNode[] arguments, ArgumentsSignature signature, ClosureCache closureCache) { - super(arguments, signature); - this.closureCache = closureCache.getContent(); - } - - static UnrolledVariadicArguments create(RNode[] arguments, ArgumentsSignature signature, ClosureCache closureCache) { - return new UnrolledVariadicArguments(arguments, signature, closureCache); - } - - @Override - public IdentityHashMap<RNode, Closure> getContent() { - return closureCache; - } -} diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/function/call/PrepareArguments.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/function/call/PrepareArguments.java index 329266ab3560d31cf98093ebff37b128a306c1ce..ee7c56dace3c2fb6fc13e9ff516535ec2344587d 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/function/call/PrepareArguments.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/function/call/PrepareArguments.java @@ -31,9 +31,8 @@ import com.oracle.truffle.r.nodes.function.ArgumentMatcher; import com.oracle.truffle.r.nodes.function.ArgumentMatcher.MatchPermutation; import com.oracle.truffle.r.nodes.function.CallArgumentsNode; import com.oracle.truffle.r.nodes.function.FormalArguments; -import com.oracle.truffle.r.nodes.function.MatchedArguments; import com.oracle.truffle.r.nodes.function.RCallNode; -import com.oracle.truffle.r.nodes.function.UnmatchedArguments; +import com.oracle.truffle.r.runtime.Arguments; import com.oracle.truffle.r.runtime.ArgumentsSignature; import com.oracle.truffle.r.runtime.RArguments.S3DefaultArguments; import com.oracle.truffle.r.runtime.RError; @@ -73,7 +72,7 @@ public abstract class PrepareArguments extends Node { return new RArgsValuesAndNames(result, suppliedSignature); } - private static RArgsValuesAndNames executeArgs(MatchedArguments matched, VirtualFrame frame) { + private static RArgsValuesAndNames executeArgs(Arguments<RNode> matched, VirtualFrame frame) { return executeArgs(matched.getArguments(), matched.getSignature(), frame); } @@ -115,7 +114,7 @@ public abstract class PrepareArguments extends Node { boolean noOpt) { this.next = next; cachedVarArgSignature = varArgSignature; - MatchedArguments matched = ArgumentMatcher.matchArguments(target, args.unrollArguments(varArgSignature), s3DefaultArguments, call, noOpt); + Arguments<RNode> matched = ArgumentMatcher.matchArguments(target, args, varArgSignature, s3DefaultArguments, call, noOpt); this.matchedArguments = matched.getArguments(); this.matchedSuppliedSignature = matched.getSignature(); this.cachedS3DefaultArguments = s3DefaultArguments; @@ -146,8 +145,7 @@ public abstract class PrepareArguments extends Node { public RArgsValuesAndNames execute(VirtualFrame frame, RArgsValuesAndNames varArgs, S3DefaultArguments s3DefaultArguments, RCallNode call) { CompilerDirectives.transferToInterpreter(); ArgumentsSignature varArgSignature = varArgs == null ? null : varArgs.getSignature(); - UnmatchedArguments argsValuesAndNames = args.unrollArguments(varArgSignature); - MatchedArguments matchedArgs = ArgumentMatcher.matchArguments(target, argsValuesAndNames, s3DefaultArguments, RError.ROOTNODE, true); + Arguments<RNode> matchedArgs = ArgumentMatcher.matchArguments(target, args, varArgSignature, s3DefaultArguments, RError.ROOTNODE, true); return executeArgs(matchedArgs, frame); } } diff --git a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/Arguments.java b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/Arguments.java index ddbb852fe3c36338234f9e3e8d7699cb06504dd6..e599ec89e528ac32c9dd43c0ecf40fde33771ea8 100644 --- a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/Arguments.java +++ b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/Arguments.java @@ -23,16 +23,29 @@ package com.oracle.truffle.r.runtime; import com.oracle.truffle.api.CompilerDirectives.CompilationFinal; -import com.oracle.truffle.api.nodes.Node; +import com.oracle.truffle.r.runtime.nodes.RNode; +import com.oracle.truffle.r.runtime.nodes.RSyntaxElement; +import com.oracle.truffle.r.runtime.nodes.RSyntaxNode; /** - * Simple generic base class for pairs of {@link #values} and {@link #signature} (that are not - * {@link Node}s). + * Simple generic base class for pairs of values and signature. * - * @param <T> The type of {@link #values} + * @param <T> The type of values */ public class Arguments<T> { + public static Arguments<RNode> create(RNode[] arguments, ArgumentsSignature signature) { + return new Arguments<>(arguments, signature); + } + + public static Arguments<RSyntaxNode> create(RSyntaxNode[] arguments, ArgumentsSignature signature) { + return new Arguments<>(arguments, signature); + } + + public static Arguments<RSyntaxElement> create(RSyntaxElement[] arguments, ArgumentsSignature signature) { + return new Arguments<>(arguments, signature); + } + /** * Array of arguments; semantics have to be specified by child classes. */ @@ -43,7 +56,7 @@ public class Arguments<T> { */ private final ArgumentsSignature signature; - public Arguments(T[] arguments, ArgumentsSignature signature) { + protected Arguments(T[] arguments, ArgumentsSignature signature) { this.values = arguments; this.signature = signature; } diff --git a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/RDeparse.java b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/RDeparse.java index ac10259ee495e1d703ad9fcbff400cb87d8f8ce4..0516ba9dac1739769d78185452ac6523eae330e3 100644 --- a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/RDeparse.java +++ b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/RDeparse.java @@ -847,8 +847,7 @@ public class RDeparse { } RSyntaxElement[] arguments = argElements.toArray(new RSyntaxElement[argElements.size()]); ArgumentsSignature signature = ArgumentsSignature.get(argNames.toArray(new String[argNames.size()])); - Arguments<RSyntaxElement> arg = new Arguments<>(arguments, signature); - return arg; + return Arguments.create(arguments, signature); } private static RPairList next(RPairList pairlist) { diff --git a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/data/RLanguage.java b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/data/RLanguage.java index 19523d1446e97d9b515635260f7fb39a5341edd5..fab7bda0eb01d0a97daf70dc11b3785f85957e33 100644 --- a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/data/RLanguage.java +++ b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/data/RLanguage.java @@ -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; diff --git a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/generate/FastRSession.java b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/generate/FastRSession.java index 6598fb567c934a1a9646b58804762c3319074849..b4720533ce8e7378ebe9df32d4c73f6cc2ccf59c 100644 --- a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/generate/FastRSession.java +++ b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/generate/FastRSession.java @@ -291,6 +291,7 @@ public final class FastRSession implements RSession { return "FastR"; } + @SuppressWarnings("unused") static void emitIO() throws IOException { } }