27
27
28
28
import static com .oracle .graal .python .nodes .SpecialMethodNames .__AND__ ;
29
29
import static com .oracle .graal .python .nodes .SpecialMethodNames .__HASH__ ;
30
+ import static com .oracle .graal .python .nodes .SpecialMethodNames .__IAND__ ;
30
31
import static com .oracle .graal .python .nodes .SpecialMethodNames .__INIT__ ;
32
+ import static com .oracle .graal .python .nodes .SpecialMethodNames .__IOR__ ;
33
+ import static com .oracle .graal .python .nodes .SpecialMethodNames .__ISUB__ ;
34
+ import static com .oracle .graal .python .nodes .SpecialMethodNames .__IXOR__ ;
31
35
import static com .oracle .graal .python .nodes .SpecialMethodNames .__OR__ ;
32
36
import static com .oracle .graal .python .nodes .SpecialMethodNames .__RAND__ ;
33
37
import static com .oracle .graal .python .nodes .SpecialMethodNames .__ROR__ ;
@@ -183,6 +187,24 @@ Object doOr(Object self, Object other) {
183
187
}
184
188
}
185
189
190
+ @ Builtin (name = __IOR__ , minNumOfPositionalArgs = 2 )
191
+ @ GenerateNodeFactory
192
+ public abstract static class IOrNode extends PythonBinaryBuiltinNode {
193
+ @ Specialization (guards = "canDoSetBinOp(other)" , limit = "3" )
194
+ Object doSet (VirtualFrame frame , PSet self , Object other ,
195
+ @ Cached GetHashingStorageNode getHashingStorageNode ,
196
+ @ CachedLibrary ("self.getDictStorage()" ) HashingStorageLibrary lib ) {
197
+ self .setDictStorage (lib .addAllToOther (self .getDictStorage (), getHashingStorageNode .execute (frame , other )));
198
+ return self ;
199
+ }
200
+
201
+ @ SuppressWarnings ("unused" )
202
+ @ Fallback
203
+ Object doOr (Object self , Object other ) {
204
+ return PNotImplemented .NOT_IMPLEMENTED ;
205
+ }
206
+ }
207
+
186
208
@ Builtin (name = "union" , minNumOfPositionalArgs = 1 , takesVarArgs = true )
187
209
@ GenerateNodeFactory
188
210
abstract static class UnionNode extends PythonBuiltinNode {
@@ -342,7 +364,7 @@ static PNone doSet(VirtualFrame frame, PSet self, Object other,
342
364
@ ImportStatic (PGuards .class )
343
365
public abstract static class AndNode extends PythonBinaryBuiltinNode {
344
366
345
- @ Specialization (guards = "canDoSetBinOp(right)" , limit = "1 " )
367
+ @ Specialization (guards = "canDoSetBinOp(right)" , limit = "3 " )
346
368
PBaseSet doPBaseSet (VirtualFrame frame , PSet left , Object right ,
347
369
@ Cached ConditionProfile hasFrame ,
348
370
@ Cached GetHashingStorageNode getHashingStorageNode ,
@@ -358,6 +380,27 @@ Object doAnd(Object self, Object other) {
358
380
}
359
381
}
360
382
383
+ @ Builtin (name = __IAND__ , minNumOfPositionalArgs = 2 )
384
+ @ GenerateNodeFactory
385
+ public abstract static class IAndNode extends PythonBinaryBuiltinNode {
386
+
387
+ @ Specialization (guards = "canDoSetBinOp(right)" , limit = "3" )
388
+ PBaseSet doPBaseSet (VirtualFrame frame , PSet left , Object right ,
389
+ @ Cached ConditionProfile hasFrame ,
390
+ @ Cached GetHashingStorageNode getHashingStorageNode ,
391
+ @ CachedLibrary ("left.getDictStorage()" ) HashingStorageLibrary leftLib ) {
392
+ HashingStorage storage = leftLib .intersectWithFrame (left .getDictStorage (), getHashingStorageNode .execute (frame , right ), hasFrame , frame );
393
+ left .setDictStorage (storage );
394
+ return left ;
395
+ }
396
+
397
+ @ SuppressWarnings ("unused" )
398
+ @ Fallback
399
+ Object doAnd (Object self , Object other ) {
400
+ return PNotImplemented .NOT_IMPLEMENTED ;
401
+ }
402
+ }
403
+
361
404
@ Builtin (name = "intersection" , minNumOfPositionalArgs = 1 , takesVarArgs = true )
362
405
@ GenerateNodeFactory
363
406
public abstract static class IntersectNode extends PythonBuiltinNode {
@@ -472,6 +515,25 @@ Object doOr(Object self, Object other) {
472
515
}
473
516
}
474
517
518
+ @ Builtin (name = __IXOR__ , minNumOfPositionalArgs = 2 )
519
+ @ GenerateNodeFactory
520
+ public abstract static class IXorNode extends PythonBinaryBuiltinNode {
521
+
522
+ @ Specialization (guards = "canDoSetBinOp(other)" , limit = "3" )
523
+ Object doSet (VirtualFrame frame , PSet self , Object other ,
524
+ @ Cached GetHashingStorageNode getHashingStorageNode ,
525
+ @ CachedLibrary ("self.getDictStorage()" ) HashingStorageLibrary lib ) {
526
+ self .setDictStorage (lib .xor (self .getDictStorage (), getHashingStorageNode .execute (frame , other )));
527
+ return self ;
528
+ }
529
+
530
+ @ SuppressWarnings ("unused" )
531
+ @ Fallback
532
+ Object doOr (Object self , Object other ) {
533
+ return PNotImplemented .NOT_IMPLEMENTED ;
534
+ }
535
+ }
536
+
475
537
@ Builtin (name = "symmetric_difference" , minNumOfPositionalArgs = 2 )
476
538
@ GenerateNodeFactory
477
539
public abstract static class SymmetricDifferenceNode extends PythonBuiltinNode {
@@ -535,7 +597,7 @@ static PNone doSet(VirtualFrame frame, PSet self, Object other,
535
597
@ GenerateNodeFactory
536
598
@ ImportStatic (PGuards .class )
537
599
abstract static class SubNode extends PythonBinaryBuiltinNode {
538
- @ Specialization (guards = "canDoSetBinOp(right)" , limit = "1 " )
600
+ @ Specialization (guards = "canDoSetBinOp(right)" , limit = "3 " )
539
601
PBaseSet doPBaseSet (VirtualFrame frame , PSet left , Object right ,
540
602
@ Cached ConditionProfile hasFrame ,
541
603
@ Cached GetHashingStorageNode getHashingStorageNode ,
@@ -551,6 +613,26 @@ Object doSub(Object self, Object other) {
551
613
}
552
614
}
553
615
616
+ @ Builtin (name = __ISUB__ , minNumOfPositionalArgs = 2 )
617
+ @ GenerateNodeFactory
618
+ abstract static class ISubNode extends PythonBinaryBuiltinNode {
619
+ @ Specialization (guards = "canDoSetBinOp(right)" , limit = "3" )
620
+ PBaseSet doPBaseSet (VirtualFrame frame , PSet left , Object right ,
621
+ @ Cached ConditionProfile hasFrame ,
622
+ @ Cached GetHashingStorageNode getHashingStorageNode ,
623
+ @ CachedLibrary ("left.getDictStorage()" ) HashingStorageLibrary lib ) {
624
+ HashingStorage storage = lib .diffWithFrame (left .getDictStorage (), getHashingStorageNode .execute (frame , right ), hasFrame , frame );
625
+ left .setDictStorage (storage );
626
+ return left ;
627
+ }
628
+
629
+ @ SuppressWarnings ("unused" )
630
+ @ Fallback
631
+ Object doSub (Object self , Object other ) {
632
+ return PNotImplemented .NOT_IMPLEMENTED ;
633
+ }
634
+ }
635
+
554
636
@ Builtin (name = "difference" , minNumOfPositionalArgs = 1 , takesVarArgs = true )
555
637
@ GenerateNodeFactory
556
638
public abstract static class DifferenceNode extends PythonBuiltinNode {
0 commit comments