Skip to content
Snippets Groups Projects
Commit c20d88cd authored by stepan's avatar stepan
Browse files

Fix calls with explicit args and internal generic dispatch

parent e0aa3b2b
No related branches found
No related tags found
No related merge requests found
......@@ -359,22 +359,24 @@ public abstract class RCallNode extends RCallBaseNode implements RSyntaxNode, RS
RBuiltinDescriptor builtin = builtinProfile.profile(function.getRBuiltin());
RArgsValuesAndNames argAndNames = (RArgsValuesAndNames) explicitArgs.execute(frame);
Object dispatchObject = argAndNames.getArgument(0);
if (isAttributableProfile.profile(dispatchObject instanceof RAttributeStorage) && isS4Profile.profile(((RAttributeStorage) dispatchObject).isS4())) {
RList list = (RList) promiseHelperNode.checkEvaluate(frame, REnvironment.getRegisteredNamespace("methods").get(".BasicFunsList"));
// TODO create a node that looks up the name in the names attribute
int index = list.getElementIndexByName(builtin.getName());
if (index != -1) {
RFunction basicFun = (RFunction) list.getDataAt(index);
Object result = call.execute(frame, basicFun, argAndNames, null, null);
if (result != RRuntime.DEFERRED_DEFAULT_MARKER) {
return result;
RStringVector type = null;
if (!argAndNames.isEmpty()) {
Object dispatchObject = argAndNames.getArgument(0);
if (isAttributableProfile.profile(dispatchObject instanceof RAttributeStorage) && isS4Profile.profile(((RAttributeStorage) dispatchObject).isS4())) {
RList list = (RList) promiseHelperNode.checkEvaluate(frame, REnvironment.getRegisteredNamespace("methods").get(".BasicFunsList"));
// TODO create a node that looks up the name in the names attribute
int index = list.getElementIndexByName(builtin.getName());
if (index != -1) {
RFunction basicFun = (RFunction) list.getDataAt(index);
Object result = call.execute(frame, basicFun, argAndNames, null, null);
if (result != RRuntime.DEFERRED_DEFAULT_MARKER) {
return result;
}
}
}
type = classHierarchyNode.execute(promiseHelperNode.checkEvaluate(frame, dispatchObject));
}
RStringVector type = argAndNames.isEmpty() ? null : classHierarchyNode.execute(promiseHelperNode.checkEvaluate(frame, dispatchObject));
S3Args s3Args;
RFunction resultFunction;
if (implicitTypeProfile.profile(type != null)) {
......
......@@ -48,5 +48,7 @@ public class TestBuiltin_docall extends TestBase {
assertEval("{ boo <- function(c) ls(parent.frame(2)); foo <- function(a,b) boo(a); bar <- function(x,z) do.call('foo', list(parse(text='goo()'),2)); bar() }");
assertEval("{ boo <- function(c) ls(parent.frame(3)); foo <- function(a,b) boo(a); bar <- function(x,z) do.call('foo', list(parse(text='goo()'),2)); baz <- function(bazX) bar(bazX,1); baz(); }");
assertEval("{ f1 <- function(a) ls(parent.frame(2)); f2 <- function(b) f1(b); f3 <- function(c) f2(c); f4 <- function(d) do.call('f3', list(d)); f4(42); }");
assertEval("do.call('c', list())");
}
}
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