29
29
30
30
import java .util .List ;
31
31
32
- import com .oracle .graal .python .annotations .Slot ;
33
- import com .oracle .graal .python .annotations .Slot .SlotKind ;
34
32
import com .oracle .graal .python .builtins .Builtin ;
35
33
import com .oracle .graal .python .builtins .CoreFunctions ;
36
34
import com .oracle .graal .python .builtins .PythonBuiltinClassType ;
49
47
import com .oracle .graal .python .builtins .objects .common .HashingStorageNodes .HashingStorageIteratorKey ;
50
48
import com .oracle .graal .python .builtins .objects .common .HashingStorageNodes .HashingStorageIteratorNext ;
51
49
import com .oracle .graal .python .builtins .objects .common .HashingStorageNodes .HashingStorageXor ;
52
- import com .oracle .graal .python .builtins .objects .type .TpSlots ;
53
- import com .oracle .graal .python .builtins .objects .type .slots .TpSlotBinaryOp .BinaryOpBuiltinNode ;
54
50
import com .oracle .graal .python .lib .PyObjectHashNode ;
55
- import com .oracle .graal .python .nodes .ErrorMessages ;
56
51
import com .oracle .graal .python .nodes .PGuards ;
57
- import com .oracle .graal .python .nodes .PRaiseNode ;
58
52
import com .oracle .graal .python .nodes .function .PythonBuiltinBaseNode ;
59
53
import com .oracle .graal .python .nodes .function .PythonBuiltinNode ;
60
54
import com .oracle .graal .python .nodes .function .builtins .PythonUnaryBuiltinNode ;
61
55
import com .oracle .graal .python .nodes .object .BuiltinClassProfiles .IsAnyBuiltinObjectProfile ;
62
- import com .oracle .graal .python .runtime .exception .PythonErrorType ;
63
56
import com .oracle .graal .python .runtime .object .PythonObjectFactory ;
64
57
import com .oracle .truffle .api .dsl .Bind ;
65
58
import com .oracle .truffle .api .dsl .Cached ;
66
59
import com .oracle .truffle .api .dsl .Cached .Shared ;
67
60
import com .oracle .truffle .api .dsl .Fallback ;
68
61
import com .oracle .truffle .api .dsl .GenerateNodeFactory ;
69
- import com .oracle .truffle .api .dsl .ImportStatic ;
70
62
import com .oracle .truffle .api .dsl .NodeFactory ;
71
63
import com .oracle .truffle .api .dsl .Specialization ;
72
64
import com .oracle .truffle .api .frame .VirtualFrame ;
73
65
import com .oracle .truffle .api .nodes .Node ;
74
- import com .oracle .truffle .api .profiles .InlinedConditionProfile ;
75
66
76
67
/**
77
68
* binary operations are implemented in {@link BaseSetBuiltins}
78
69
*/
79
70
@ CoreFunctions (extendClasses = {PythonBuiltinClassType .PFrozenSet })
80
71
public final class FrozenSetBuiltins extends PythonBuiltins {
81
72
82
- public static final TpSlots SLOTS = FrozenSetBuiltinsSlotsGen .SLOTS ;
83
-
84
73
@ Override
85
74
protected List <? extends NodeFactory <? extends PythonBuiltinBaseNode >> getNodeFactories () {
86
75
return FrozenSetBuiltinsFactory .getFactories ();
@@ -103,33 +92,6 @@ static PFrozenSet subFrozensetIdentity(PFrozenSet arg,
103
92
}
104
93
}
105
94
106
- @ Slot (value = SlotKind .nb_and , isComplex = true )
107
- @ GenerateNodeFactory
108
- @ ImportStatic (PGuards .class )
109
- abstract static class AndNode extends BinaryOpBuiltinNode {
110
-
111
- @ Specialization (guards = "canDoSetBinOp(right)" )
112
- static PBaseSet doPBaseSet (@ SuppressWarnings ("unused" ) VirtualFrame frame , PFrozenSet left , Object right ,
113
- @ Bind ("this" ) Node inliningTarget ,
114
- @ Cached InlinedConditionProfile rightIsSetProfile ,
115
- @ Cached GetSetStorageNode getSetStorageNode ,
116
- @ Cached HashingStorageIntersect intersectNode ,
117
- @ Cached PythonObjectFactory factory ) {
118
- HashingStorage storage = intersectNode .execute (frame , inliningTarget , left .getDictStorage (), getSetStorageNode .execute (frame , inliningTarget , right ));
119
- if (rightIsSetProfile .profile (inliningTarget , right instanceof PBaseSet )) {
120
- return factory .createFrozenSet (storage );
121
- } else {
122
- return factory .createSet (storage );
123
- }
124
- }
125
-
126
- @ Fallback
127
- static Object doAnd (Object self , Object other ,
128
- @ Cached PRaiseNode raiseNode ) {
129
- throw raiseNode .raise (PythonErrorType .TypeError , ErrorMessages .UNSUPPORTED_OPERAND_TYPES_FOR_S_P_AND_P , "&" , self , other );
130
- }
131
- }
132
-
133
95
@ Builtin (name = "intersection" , minNumOfPositionalArgs = 1 , takesVarArgs = true )
134
96
@ GenerateNodeFactory
135
97
public abstract static class IntersectNode extends PythonBuiltinNode {
@@ -184,62 +146,6 @@ static PFrozenSet doSet(@SuppressWarnings("unused") VirtualFrame frame, PFrozenS
184
146
}
185
147
}
186
148
187
- @ Slot (value = SlotKind .nb_or , isComplex = true )
188
- @ GenerateNodeFactory
189
- @ ImportStatic (PGuards .class )
190
- abstract static class OrNode extends BinaryOpBuiltinNode {
191
-
192
- @ Specialization (guards = "canDoSetBinOp(right)" )
193
- static PBaseSet doPBaseSet (@ SuppressWarnings ("unused" ) VirtualFrame frame , PFrozenSet left , Object right ,
194
- @ Bind ("this" ) Node inliningTarget ,
195
- @ Cached InlinedConditionProfile rightIsSetProfile ,
196
- @ Cached HashingCollectionNodes .GetSetStorageNode getSetStorageNode ,
197
- @ Cached HashingStorageCopy copyNode ,
198
- @ Cached HashingStorageAddAllToOther addAllToOther ,
199
- @ Cached PythonObjectFactory factory ) {
200
- HashingStorage storage = left .getDictStorage ().union (inliningTarget , getSetStorageNode .execute (frame , inliningTarget , right ), copyNode , addAllToOther );
201
- if (rightIsSetProfile .profile (inliningTarget , right instanceof PBaseSet )) {
202
- return factory .createFrozenSet (storage );
203
- } else {
204
- return factory .createSet (storage );
205
- }
206
- }
207
-
208
- @ Fallback
209
- static Object doOr (Object self , Object other ,
210
- @ Cached PRaiseNode raiseNode ) {
211
- throw raiseNode .raise (PythonErrorType .TypeError , ErrorMessages .UNSUPPORTED_OPERAND_TYPES_FOR_S_P_AND_P , "|" , self , other );
212
- }
213
- }
214
-
215
- @ Slot (value = SlotKind .nb_xor , isComplex = true )
216
- @ GenerateNodeFactory
217
- @ ImportStatic (PGuards .class )
218
- abstract static class XorNode extends BinaryOpBuiltinNode {
219
-
220
- @ Specialization (guards = "canDoSetBinOp(right)" )
221
- static PBaseSet doPBaseSet (@ SuppressWarnings ("unused" ) VirtualFrame frame , PFrozenSet left , Object right ,
222
- @ Bind ("this" ) Node inliningTarget ,
223
- @ Cached InlinedConditionProfile rightIsSetProfile ,
224
- @ Cached GetSetStorageNode getSetStorageNode ,
225
- @ Cached HashingStorageXor xorNode ,
226
- @ Cached PythonObjectFactory factory ) {
227
- HashingStorage rightStorage = getSetStorageNode .execute (frame , inliningTarget , right );
228
- HashingStorage storage = xorNode .execute (frame , inliningTarget , left .getDictStorage (), rightStorage );
229
- if (rightIsSetProfile .profile (inliningTarget , right instanceof PBaseSet )) {
230
- return factory .createFrozenSet (storage );
231
- } else {
232
- return factory .createSet (storage );
233
- }
234
- }
235
-
236
- @ Fallback
237
- static Object doOr (Object self , Object other ,
238
- @ Cached PRaiseNode raiseNode ) {
239
- throw raiseNode .raise (PythonErrorType .TypeError , ErrorMessages .UNSUPPORTED_OPERAND_TYPES_FOR_S_P_AND_P , "^" , self , other );
240
- }
241
- }
242
-
243
149
@ Builtin (name = "symmetric_difference" , minNumOfPositionalArgs = 2 )
244
150
@ GenerateNodeFactory
245
151
public abstract static class SymmetricDifferenceNode extends PythonBuiltinNode {
0 commit comments