|
59 | 59 | import com.oracle.graal.python.builtins.objects.common.SequenceStorageNodes.GetItemNode;
|
60 | 60 | import com.oracle.graal.python.builtins.objects.common.SequenceStorageNodes.NoGeneralizationNode;
|
61 | 61 | import com.oracle.graal.python.builtins.objects.common.SequenceStorageNodes.NormalizeIndexNode;
|
62 |
| -import com.oracle.graal.python.builtins.objects.ints.PInt; |
63 | 62 | import com.oracle.graal.python.builtins.objects.memoryview.PMemoryView;
|
64 | 63 | import com.oracle.graal.python.builtins.objects.range.PRange;
|
65 | 64 | import com.oracle.graal.python.builtins.objects.slice.PSlice;
|
66 | 65 | import com.oracle.graal.python.builtins.objects.tuple.PTuple;
|
67 |
| -import com.oracle.graal.python.nodes.PGuards; |
68 | 66 | import com.oracle.graal.python.nodes.SpecialMethodNames;
|
69 | 67 | import com.oracle.graal.python.nodes.call.special.LookupAndCallUnaryNode;
|
70 | 68 | import com.oracle.graal.python.nodes.expression.BinaryComparisonNode;
|
@@ -115,68 +113,18 @@ public PNone init(Object self, Object args, Object kwargs) {
|
115 | 113 | @TypeSystemReference(PythonArithmeticTypes.class)
|
116 | 114 | @GenerateNodeFactory
|
117 | 115 | public abstract static class DelItemNode extends PythonBinaryBuiltinNode {
|
118 |
| - @Child private SequenceStorageNodes.NormalizeIndexNode normalize = SequenceStorageNodes.NormalizeIndexNode.forArray(); |
119 |
| - |
120 |
| - @Specialization(guards = "isByteStorage(primary)") |
121 |
| - protected PNone doBytes(PByteArray primary, long idx) { |
122 |
| - ByteSequenceStorage storage = (ByteSequenceStorage) primary.getSequenceStorage(); |
123 |
| - storage.delItemInBound(normalize.execute(idx, storage.length())); |
124 |
| - return PNone.NONE; |
125 |
| - } |
126 |
| - |
127 |
| - @Specialization(guards = "isByteStorage(primary)") |
128 |
| - protected PNone doBytes(PByteArray primary, PInt idx) { |
129 |
| - ByteSequenceStorage storage = (ByteSequenceStorage) primary.getSequenceStorage(); |
130 |
| - storage.delItemInBound(normalize.execute(idx, storage.length())); |
131 |
| - return PNone.NONE; |
132 |
| - } |
133 |
| - |
134 |
| - @Specialization(guards = "isIntStorage(primary)") |
135 |
| - protected PNone doInt(PByteArray primary, long idx) { |
136 |
| - IntSequenceStorage storage = (IntSequenceStorage) primary.getSequenceStorage(); |
137 |
| - storage.delItemInBound(normalize.execute(idx, storage.length())); |
138 |
| - return PNone.NONE; |
139 |
| - } |
140 |
| - |
141 |
| - @Specialization(guards = "isIntStorage(primary)") |
142 |
| - protected PNone doInt(PByteArray primary, PInt idx) { |
143 |
| - IntSequenceStorage storage = (IntSequenceStorage) primary.getSequenceStorage(); |
144 |
| - storage.delItemInBound(normalize.execute(idx, storage.length())); |
145 |
| - return PNone.NONE; |
146 |
| - } |
147 |
| - |
148 |
| - @Specialization |
149 |
| - protected PNone doArray(PByteArray byteArray, long idx) { |
150 |
| - SequenceStorage storage = byteArray.getSequenceStorage(); |
151 |
| - storage.delItemInBound(normalize.execute(idx, storage.length())); |
152 |
| - return PNone.NONE; |
153 |
| - } |
154 |
| - |
155 |
| - @Specialization |
156 |
| - protected PNone doArray(PByteArray byteArray, PInt idx) { |
157 |
| - SequenceStorage storage = byteArray.getSequenceStorage(); |
158 |
| - storage.delItemInBound(normalize.execute(idx, storage.length())); |
159 |
| - return PNone.NONE; |
160 |
| - } |
161 |
| - |
162 | 116 | @Specialization
|
163 |
| - protected PNone doSlice(PByteArray self, PSlice slice) { |
164 |
| - self.delSlice(slice); |
| 117 | + protected PNone doGeneric(PByteArray self, Object key, |
| 118 | + @Cached("create()") SequenceStorageNodes.DeleteNode deleteNode) { |
| 119 | + deleteNode.execute(self.getSequenceStorage(), key); |
165 | 120 | return PNone.NONE;
|
166 | 121 | }
|
167 | 122 |
|
168 | 123 | @SuppressWarnings("unused")
|
169 | 124 | @Fallback
|
170 | 125 | protected Object doGeneric(Object self, Object idx) {
|
171 |
| - if (!isValidIndexType(idx)) { |
172 |
| - throw raise(TypeError, "bytearray indices must be integers or slices, not %p", idx); |
173 |
| - } |
174 | 126 | throw raise(TypeError, "descriptor '__delitem__' requires a 'bytearray' object but received a '%p'", idx);
|
175 | 127 | }
|
176 |
| - |
177 |
| - protected boolean isValidIndexType(Object idx) { |
178 |
| - return PGuards.isInteger(idx) || idx instanceof PSlice; |
179 |
| - } |
180 | 128 | }
|
181 | 129 |
|
182 | 130 | @Builtin(name = __EQ__, fixedNumOfPositionalArgs = 2)
|
|
0 commit comments