|
52 | 52 | import com.oracle.graal.python.builtins.objects.common.HashingStorageNodes;
|
53 | 53 | import com.oracle.graal.python.builtins.objects.common.HashingStorageNodes.PythonEquivalence;
|
54 | 54 | import com.oracle.graal.python.builtins.objects.common.PHashingCollection;
|
| 55 | +import com.oracle.graal.python.builtins.objects.dict.PDictView; |
55 | 56 | import com.oracle.graal.python.builtins.objects.set.FrozenSetBuiltinsFactory.BinaryUnionNodeGen;
|
56 | 57 | import com.oracle.graal.python.builtins.objects.tuple.PTuple;
|
57 | 58 | import com.oracle.graal.python.nodes.PNodeWithContext;
|
@@ -208,6 +209,22 @@ PBaseSet doPBaseSet(PFrozenSet left, PBaseSet right) {
|
208 | 209 | return factory().createFrozenSet(intersectedStorage);
|
209 | 210 | }
|
210 | 211 |
|
| 212 | + @Specialization |
| 213 | + PBaseSet doPBaseSet(PSet left, PDictView right, |
| 214 | + @Cached("create()") SetNodes.ConstructSetNode constructSetNode) { |
| 215 | + PSet rightSet = constructSetNode.executeWith(right); |
| 216 | + HashingStorage intersectedStorage = getIntersectNode().execute(left.getDictStorage(), rightSet.getDictStorage()); |
| 217 | + return factory().createSet(intersectedStorage); |
| 218 | + } |
| 219 | + |
| 220 | + @Specialization |
| 221 | + PBaseSet doPBaseSet(PFrozenSet left, PDictView right, |
| 222 | + @Cached("create()") SetNodes.ConstructSetNode constructSetNode) { |
| 223 | + PSet rightSet = constructSetNode.executeWith(right); |
| 224 | + HashingStorage intersectedStorage = getIntersectNode().execute(left.getDictStorage(), rightSet.getDictStorage()); |
| 225 | + return factory().createSet(intersectedStorage); |
| 226 | + } |
| 227 | + |
211 | 228 | @Fallback
|
212 | 229 | Object doAnd(Object self, Object other) {
|
213 | 230 | throw raise(PythonErrorType.TypeError, "unsupported operand type(s) for &: '%p' and '%p'", self, other);
|
@@ -267,9 +284,25 @@ PBaseSet doPBaseSet(PFrozenSet left, PBaseSet right) {
|
267 | 284 | HashingStorage intersectedStorage = getUnionNode().execute(left.getDictStorage(), right.getDictStorage());
|
268 | 285 | return factory().createFrozenSet(intersectedStorage);
|
269 | 286 | }
|
270 |
| - |
| 287 | + |
| 288 | + @Specialization |
| 289 | + PBaseSet doPBaseSet(PSet left, PDictView right, |
| 290 | + @Cached("create()") SetNodes.ConstructSetNode constructSetNode) { |
| 291 | + PSet rightSet = constructSetNode.executeWith(right); |
| 292 | + HashingStorage intersectedStorage = getUnionNode().execute(left.getDictStorage(), rightSet.getDictStorage()); |
| 293 | + return factory().createSet(intersectedStorage); |
| 294 | + } |
| 295 | + |
| 296 | + @Specialization |
| 297 | + PBaseSet doPBaseSet(PFrozenSet left, PDictView right, |
| 298 | + @Cached("create()") SetNodes.ConstructSetNode constructSetNode) { |
| 299 | + PSet rightSet = constructSetNode.executeWith(right); |
| 300 | + HashingStorage intersectedStorage = getUnionNode().execute(left.getDictStorage(), rightSet.getDictStorage()); |
| 301 | + return factory().createSet(intersectedStorage); |
| 302 | + } |
| 303 | + |
271 | 304 | @Fallback
|
272 |
| - Object doAnd(Object self, Object other) { |
| 305 | + Object doOr(Object self, Object other) { |
273 | 306 | throw raise(PythonErrorType.TypeError, "unsupported operand type(s) for |: '%p' and '%p'", self, other);
|
274 | 307 | }
|
275 | 308 | }
|
|
0 commit comments