|
45 | 45 | import com.oracle.graal.python.builtins.objects.function.PKeyword; |
46 | 46 | import com.oracle.graal.python.builtins.objects.module.PythonModule; |
47 | 47 | import com.oracle.graal.python.builtins.objects.object.PythonObject; |
| 48 | +import com.oracle.graal.python.nodes.argument.positional.PositionalArgumentsNode; |
48 | 49 | import com.oracle.graal.python.nodes.attributes.ReadAttributeFromObjectNode; |
49 | 50 | import com.oracle.graal.python.nodes.attributes.WriteAttributeToObjectNode; |
50 | 51 | import com.oracle.graal.python.nodes.call.special.LookupAndCallBinaryNode; |
@@ -73,16 +74,26 @@ protected List<? extends NodeFactory<? extends PythonBuiltinBaseNode>> getNodeFa |
73 | 74 | public abstract static class CallNode extends PythonVarargsBuiltinNode { |
74 | 75 | @Child private com.oracle.graal.python.nodes.call.CallNode callNode = com.oracle.graal.python.nodes.call.CallNode.create(); |
75 | 76 |
|
76 | | - @Specialization |
| 77 | + @Specialization(guards = "isFunction(self.getFunction())") |
77 | 78 | protected Object doIt(VirtualFrame frame, PMethod self, Object[] arguments, PKeyword[] keywords) { |
78 | 79 | return callNode.execute(frame, self, arguments, keywords); |
79 | 80 | } |
80 | 81 |
|
81 | | - @Specialization |
| 82 | + @Specialization(guards = "isFunction(self.getFunction())") |
82 | 83 | protected Object doIt(VirtualFrame frame, PBuiltinMethod self, Object[] arguments, PKeyword[] keywords) { |
83 | 84 | return callNode.execute(frame, self, arguments, keywords); |
84 | 85 | } |
85 | 86 |
|
| 87 | + @Specialization(guards = "!isFunction(self.getFunction())") |
| 88 | + protected Object doItNonFunction(VirtualFrame frame, PMethod self, Object[] arguments, PKeyword[] keywords) { |
| 89 | + return callNode.execute(frame, self.getFunction(), PositionalArgumentsNode.prependArgument(self.getSelf(), arguments), keywords); |
| 90 | + } |
| 91 | + |
| 92 | + @Specialization(guards = "!isFunction(self.getFunction())") |
| 93 | + protected Object doItNonFunction(VirtualFrame frame, PBuiltinMethod self, Object[] arguments, PKeyword[] keywords) { |
| 94 | + return callNode.execute(frame, self.getFunction(), PositionalArgumentsNode.prependArgument(self.getSelf(), arguments), keywords); |
| 95 | + } |
| 96 | + |
86 | 97 | @Override |
87 | 98 | public Object varArgExecute(VirtualFrame frame, Object[] arguments, PKeyword[] keywords) throws VarargsBuiltinDirectInvocationNotSupported { |
88 | 99 | Object[] argsWithoutSelf = new Object[arguments.length - 1]; |
|
0 commit comments