diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/AsCall.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/AsCall.java index 5cc9d7e5b4364f57955e18f69513c626e87a271a..2bf26e03612ee11a3c3458c7f959dc8a0e4622bf 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/AsCall.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/AsCall.java @@ -32,6 +32,7 @@ import com.oracle.truffle.api.profiles.ConditionProfile; import com.oracle.truffle.r.nodes.RASTUtils; import com.oracle.truffle.r.nodes.attributes.SpecialAttributesFunctions.GetNamesAttributeNode; import com.oracle.truffle.r.nodes.builtin.RBuiltinNode; +import com.oracle.truffle.r.nodes.function.RCallBaseNode; import com.oracle.truffle.r.runtime.ArgumentsSignature; import com.oracle.truffle.r.runtime.RError; import com.oracle.truffle.r.runtime.RError.Message; @@ -87,6 +88,15 @@ public abstract class AsCall extends RBuiltinNode.Arg1 { } } + protected boolean containsCall(RLanguage l) { + return l.getRep() instanceof RCallBaseNode; + } + + @Specialization(guards = "containsCall(l)") + protected RLanguage asCall(RLanguage l) { + return l; + } + @Fallback protected Object asCallFunction(@SuppressWarnings("unused") Object x) { throw error(RError.Message.GENERIC, "invalid argument list"); diff --git a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/builtins/TestBuiltin_ascall.java b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/builtins/TestBuiltin_ascall.java index 864149114c81a19a9232cfe7e5b0b0bbe2e28780..7b5523963748615dc4b7c21994975f8f3acf90f4 100644 --- a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/builtins/TestBuiltin_ascall.java +++ b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/builtins/TestBuiltin_ascall.java @@ -78,5 +78,7 @@ public class TestBuiltin_ascall extends TestBase { assertEval(Output.IgnoreWhitespace, "as.call(list(as.symbol('function'), pairlist(a=1)))"); assertEval(Output.IgnoreWhitespace, "as.call(list(as.symbol('function')))"); assertEval(Output.IgnoreWhitespace, "call('function')"); + + assertEval(Output.IgnoreWhitespace, "{ cl <- quote(fun(3)); as.call(cl) }"); } }