|
47 | 47 | import static com.oracle.graal.python.builtins.PythonBuiltinClassType.StopIteration;
|
48 | 48 | import static com.oracle.graal.python.builtins.PythonBuiltinClassType.TypeError;
|
49 | 49 | import static com.oracle.graal.python.builtins.PythonBuiltinClassType.ValueError;
|
| 50 | +import static com.oracle.graal.python.nodes.SpecialAttributeNames.__DICT__; |
50 | 51 | import static com.oracle.graal.python.nodes.SpecialMethodNames.__ADD__;
|
51 | 52 | import static com.oracle.graal.python.nodes.SpecialMethodNames.__CONTAINS__;
|
52 | 53 | import static com.oracle.graal.python.nodes.SpecialMethodNames.__DELITEM__;
|
|
94 | 95 | import com.oracle.graal.python.builtins.objects.type.TypeNodes.GetNameNode;
|
95 | 96 | import com.oracle.graal.python.lib.PyNumberAsSizeNode;
|
96 | 97 | import com.oracle.graal.python.lib.PyObjectIsTrueNode;
|
| 98 | +import com.oracle.graal.python.lib.PyObjectLookupAttr; |
| 99 | +import com.oracle.graal.python.lib.PyObjectSizeNode; |
97 | 100 | import com.oracle.graal.python.nodes.ErrorMessages;
|
98 | 101 | import com.oracle.graal.python.nodes.PGuards;
|
99 | 102 | import com.oracle.graal.python.nodes.PRaiseNode;
|
@@ -945,12 +948,17 @@ static Object repr(PDeque self) {
|
945 | 948 | abstract static class DequeReduceNode extends PythonUnaryBuiltinNode {
|
946 | 949 |
|
947 | 950 | @Specialization(limit = "1")
|
948 |
| - Object doGeneric(PDeque self, |
| 951 | + Object doGeneric(VirtualFrame frame, PDeque self, |
949 | 952 | @CachedLibrary("self") PythonObjectLibrary lib,
|
| 953 | + @Cached PyObjectLookupAttr lookupAttr, |
| 954 | + @Cached PyObjectSizeNode sizeNode, |
950 | 955 | @Cached GetClassNode getClassNode,
|
951 | 956 | @Cached ConditionProfile profile) {
|
952 | 957 | Object clazz = getPythonClass(getClassNode.execute(self), profile);
|
953 |
| - Object dict = lib.hasDict(self) ? lib.getDict(self) : PNone.NONE; |
| 958 | + Object dict = lookupAttr.execute(frame, self, __DICT__); |
| 959 | + if (PGuards.isNoValue(dict) || sizeNode.execute(frame, dict) <= 0) { |
| 960 | + dict = PNone.NONE; |
| 961 | + } |
954 | 962 | Object it = lib.getIterator(self);
|
955 | 963 | PTuple emptyTuple = factory().createEmptyTuple();
|
956 | 964 | int maxLength = self.getMaxLength();
|
|
0 commit comments