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 ...@@ -359,22 +359,24 @@ public abstract class RCallNode extends RCallBaseNode implements RSyntaxNode, RS
RBuiltinDescriptor builtin = builtinProfile.profile(function.getRBuiltin()); RBuiltinDescriptor builtin = builtinProfile.profile(function.getRBuiltin());
RArgsValuesAndNames argAndNames = (RArgsValuesAndNames) explicitArgs.execute(frame); RArgsValuesAndNames argAndNames = (RArgsValuesAndNames) explicitArgs.execute(frame);
Object dispatchObject = argAndNames.getArgument(0); RStringVector type = null;
if (!argAndNames.isEmpty()) {
if (isAttributableProfile.profile(dispatchObject instanceof RAttributeStorage) && isS4Profile.profile(((RAttributeStorage) dispatchObject).isS4())) { Object dispatchObject = argAndNames.getArgument(0);
RList list = (RList) promiseHelperNode.checkEvaluate(frame, REnvironment.getRegisteredNamespace("methods").get(".BasicFunsList")); if (isAttributableProfile.profile(dispatchObject instanceof RAttributeStorage) && isS4Profile.profile(((RAttributeStorage) dispatchObject).isS4())) {
// TODO create a node that looks up the name in the names attribute RList list = (RList) promiseHelperNode.checkEvaluate(frame, REnvironment.getRegisteredNamespace("methods").get(".BasicFunsList"));
int index = list.getElementIndexByName(builtin.getName()); // TODO create a node that looks up the name in the names attribute
if (index != -1) { int index = list.getElementIndexByName(builtin.getName());
RFunction basicFun = (RFunction) list.getDataAt(index); if (index != -1) {
Object result = call.execute(frame, basicFun, argAndNames, null, null); RFunction basicFun = (RFunction) list.getDataAt(index);
if (result != RRuntime.DEFERRED_DEFAULT_MARKER) { Object result = call.execute(frame, basicFun, argAndNames, null, null);
return result; 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; S3Args s3Args;
RFunction resultFunction; RFunction resultFunction;
if (implicitTypeProfile.profile(type != null)) { if (implicitTypeProfile.profile(type != null)) {
......
...@@ -48,5 +48,7 @@ public class TestBuiltin_docall extends TestBase { ...@@ -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(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("{ 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("{ 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