|
27 | 27 |
|
28 | 28 | import static com.oracle.graal.python.nodes.SpecialMethodNames.__ITER__;
|
29 | 29 | import static com.oracle.graal.python.nodes.SpecialMethodNames.__NEXT__;
|
| 30 | +import static com.oracle.graal.python.nodes.SpecialMethodNames.__REDUCE__; |
30 | 31 |
|
31 | 32 | import java.util.List;
|
32 | 33 |
|
33 | 34 | import com.oracle.graal.python.builtins.Builtin;
|
34 | 35 | import com.oracle.graal.python.builtins.CoreFunctions;
|
35 | 36 | import com.oracle.graal.python.builtins.PythonBuiltinClassType;
|
36 | 37 | import com.oracle.graal.python.builtins.PythonBuiltins;
|
| 38 | +import com.oracle.graal.python.builtins.objects.tuple.PTuple; |
37 | 39 | import com.oracle.graal.python.nodes.control.GetNextNode;
|
38 | 40 | import com.oracle.graal.python.nodes.function.PythonBuiltinBaseNode;
|
39 | 41 | import com.oracle.graal.python.nodes.function.builtins.PythonUnaryBuiltinNode;
|
| 42 | +import com.oracle.graal.python.nodes.object.GetClassNode; |
40 | 43 | import com.oracle.graal.python.runtime.exception.PythonErrorType;
|
41 | 44 | import com.oracle.truffle.api.dsl.Cached;
|
42 | 45 | import com.oracle.truffle.api.dsl.GenerateNodeFactory;
|
@@ -82,4 +85,16 @@ static Object doPZip(PZip self) {
|
82 | 85 | return self;
|
83 | 86 | }
|
84 | 87 | }
|
| 88 | + |
| 89 | + @Builtin(name = __REDUCE__, minNumOfPositionalArgs = 1) |
| 90 | + @GenerateNodeFactory |
| 91 | + public abstract static class ReduceNode extends PythonUnaryBuiltinNode { |
| 92 | + @Specialization |
| 93 | + Object reducePos(PZip self, |
| 94 | + @Cached GetClassNode getClass) { |
| 95 | + Object type = getClass.execute(self); |
| 96 | + PTuple tuple = factory().createTuple(self.getIterators()); |
| 97 | + return factory().createTuple(new Object[]{type, tuple}); |
| 98 | + } |
| 99 | + } |
85 | 100 | }
|
0 commit comments