|
41 | 41 | package com.oracle.graal.python.builtins.objects.generator;
|
42 | 42 |
|
43 | 43 | import static com.oracle.graal.python.nodes.SpecialMethodNames.J___AWAIT__;
|
| 44 | +import static com.oracle.graal.python.nodes.SpecialMethodNames.J___REPR__; |
44 | 45 |
|
45 | 46 | import java.util.List;
|
46 | 47 |
|
|
49 | 50 | import com.oracle.graal.python.builtins.PythonBuiltinClassType;
|
50 | 51 | import com.oracle.graal.python.builtins.PythonBuiltins;
|
51 | 52 | import com.oracle.graal.python.builtins.objects.PNone;
|
| 53 | +import com.oracle.graal.python.builtins.objects.PythonAbstractObject; |
| 54 | +import com.oracle.graal.python.builtins.objects.str.StringUtils.SimpleTruffleStringFormatNode; |
52 | 55 | import com.oracle.graal.python.nodes.function.PythonBuiltinBaseNode;
|
53 | 56 | import com.oracle.graal.python.nodes.function.builtins.PythonUnaryBuiltinNode;
|
54 | 57 | import com.oracle.graal.python.runtime.object.PythonObjectFactory;
|
|
60 | 63 | import com.oracle.truffle.api.frame.VirtualFrame;
|
61 | 64 | import com.oracle.truffle.api.nodes.Node;
|
62 | 65 | import com.oracle.truffle.api.profiles.InlinedConditionProfile;
|
| 66 | +import com.oracle.truffle.api.strings.TruffleString; |
63 | 67 |
|
64 | 68 | @CoreFunctions(extendClasses = PythonBuiltinClassType.PCoroutine)
|
65 | 69 | public final class CoroutineBuiltins extends PythonBuiltins {
|
@@ -127,4 +131,14 @@ static Object await(PGenerator self,
|
127 | 131 | return factory.createCoroutineWrapper(self);
|
128 | 132 | }
|
129 | 133 | }
|
| 134 | + |
| 135 | + @Builtin(name = J___REPR__, minNumOfPositionalArgs = 1) |
| 136 | + @GenerateNodeFactory |
| 137 | + abstract static class ReprNode extends PythonUnaryBuiltinNode { |
| 138 | + @Specialization |
| 139 | + static TruffleString repr(PGenerator self, |
| 140 | + @Cached SimpleTruffleStringFormatNode simpleTruffleStringFormatNode) { |
| 141 | + return simpleTruffleStringFormatNode.format("<coroutine object %s at 0x%d>", self.getQualname(), PythonAbstractObject.objectHashCode(self)); |
| 142 | + } |
| 143 | + } |
130 | 144 | }
|
0 commit comments