94
94
95
95
import java .nio .charset .CharsetEncoder ;
96
96
import java .nio .charset .StandardCharsets ;
97
- import java .util .Set ;
98
97
99
98
import com .oracle .graal .python .builtins .PythonBuiltinClassType ;
100
99
import com .oracle .graal .python .builtins .modules .cext .PythonCextBuiltins .CApiBinaryBuiltinNode ;
118
117
import com .oracle .graal .python .builtins .objects .cext .structs .CStructs ;
119
118
import com .oracle .graal .python .builtins .objects .common .DynamicObjectStorage ;
120
119
import com .oracle .graal .python .builtins .objects .common .HashingStorage ;
121
- import com .oracle .graal .python .builtins .objects .common .HashingStorageNodes .HashingStorageForEach ;
122
- import com .oracle .graal .python .builtins .objects .common .HashingStorageNodes .HashingStorageForEachCallback ;
123
- import com .oracle .graal .python .builtins .objects .common .HashingStorageNodes .HashingStorageGetItemWithHash ;
124
120
import com .oracle .graal .python .builtins .objects .common .HashingStorageNodes .HashingStorageGetIterator ;
125
121
import com .oracle .graal .python .builtins .objects .common .HashingStorageNodes .HashingStorageIterator ;
126
122
import com .oracle .graal .python .builtins .objects .common .HashingStorageNodes .HashingStorageIteratorKey ;
127
- import com .oracle .graal .python .builtins .objects .common .HashingStorageNodes .HashingStorageIteratorKeyHash ;
128
123
import com .oracle .graal .python .builtins .objects .common .HashingStorageNodes .HashingStorageIteratorNext ;
129
124
import com .oracle .graal .python .builtins .objects .common .HashingStorageNodes .HashingStorageIteratorValue ;
130
125
import com .oracle .graal .python .builtins .objects .common .HashingStorageNodes .HashingStorageLen ;
143
138
import com .oracle .graal .python .builtins .objects .str .PString ;
144
139
import com .oracle .graal .python .builtins .objects .str .StringNodes .StringLenNode ;
145
140
import com .oracle .graal .python .builtins .objects .str .StringNodes .StringMaterializeNode ;
146
- import com .oracle .graal .python .builtins .objects .type .PythonAbstractClass ;
147
- import com .oracle .graal .python .builtins .objects .type .PythonClass ;
148
141
import com .oracle .graal .python .builtins .objects .type .PythonManagedClass ;
149
142
import com .oracle .graal .python .builtins .objects .type .TypeBuiltins ;
150
143
import com .oracle .graal .python .builtins .objects .type .TypeNodes ;
151
- import com .oracle .graal .python .builtins .objects .type .TypeNodes .GetSubclassesNode ;
152
144
import com .oracle .graal .python .lib .PyObjectLookupAttr ;
153
145
import com .oracle .graal .python .nodes .PGuards ;
154
146
import com .oracle .graal .python .nodes .SpecialAttributeNames ;
170
162
import com .oracle .truffle .api .dsl .Cached ;
171
163
import com .oracle .truffle .api .dsl .Cached .Exclusive ;
172
164
import com .oracle .truffle .api .dsl .Fallback ;
173
- import com .oracle .truffle .api .dsl .GenerateUncached ;
174
165
import com .oracle .truffle .api .dsl .Specialization ;
175
- import com .oracle .truffle .api .frame .Frame ;
176
166
import com .oracle .truffle .api .library .CachedLibrary ;
177
167
import com .oracle .truffle .api .nodes .Node ;
178
168
import com .oracle .truffle .api .object .DynamicObjectLibrary ;
@@ -856,45 +846,6 @@ static Object doTpDictoffset(PythonManagedClass object, long value,
856
846
857
847
}
858
848
859
- @ CApiBuiltin (ret = Void , args = {PyTypeObject , PyObject }, call = Ignored )
860
- abstract static class Py_set_PyTypeObject_tp_subclasses extends CApiBinaryBuiltinNode {
861
-
862
- @ GenerateUncached
863
- abstract static class EachSubclassAdd extends HashingStorageForEachCallback <Set <PythonAbstractClass >> {
864
-
865
- @ Override
866
- public abstract Set <PythonAbstractClass > execute (Frame frame , Node inliningTarget , HashingStorage storage , HashingStorageIterator it , Set <PythonAbstractClass > subclasses );
867
-
868
- @ Specialization
869
- public Set <PythonAbstractClass > doIt (Frame frame , @ SuppressWarnings ("unused" ) Node inliningTarget , HashingStorage storage , HashingStorageIterator it , Set <PythonAbstractClass > subclasses ,
870
- @ Cached HashingStorageIteratorKey itKey ,
871
- @ Cached HashingStorageIteratorKeyHash itKeyHash ,
872
- @ Cached HashingStorageGetItemWithHash getItemNode ) {
873
- long hash = itKeyHash .execute (inliningTarget , storage , it );
874
- Object key = itKey .execute (inliningTarget , storage , it );
875
- setAdd (subclasses , (PythonClass ) getItemNode .execute (frame , inliningTarget , storage , key , hash ));
876
- return subclasses ;
877
- }
878
-
879
- @ TruffleBoundary
880
- protected static void setAdd (Set <PythonAbstractClass > set , PythonClass cls ) {
881
- set .add (cls );
882
- }
883
- }
884
-
885
- @ Specialization
886
- static Object doTpSubclasses (PythonClass object , PDict dict ,
887
- @ Bind ("this" ) Node inliningTarget ,
888
- @ Cached GetSubclassesNode getSubclassesNode ,
889
- @ Cached EachSubclassAdd eachNode ,
890
- @ Cached HashingStorageForEach forEachNode ) {
891
- HashingStorage storage = dict .getDictStorage ();
892
- Set <PythonAbstractClass > subclasses = getSubclassesNode .execute (inliningTarget , object );
893
- forEachNode .execute (null , inliningTarget , storage , eachNode , subclasses );
894
- return PNone .NO_VALUE ;
895
- }
896
- }
897
-
898
849
@ CApiBuiltin (name = "Py_get_dummy" , ret = Pointer , args = {Pointer }, call = Ignored )
899
850
abstract static class PyGetSlotDummyPtr extends CApiUnaryBuiltinNode {
900
851
@@ -909,6 +860,7 @@ Object get(@SuppressWarnings("unused") Object object) {
909
860
@ CApiBuiltin (name = "Py_set_PyTypeObject_tp_getattro" , ret = Void , args = {PyTypeObject , getattrofunc }, call = Ignored )
910
861
@ CApiBuiltin (name = "Py_set_PyTypeObject_tp_setattr" , ret = Void , args = {PyTypeObject , setattrfunc }, call = Ignored )
911
862
@ CApiBuiltin (name = "Py_set_PyTypeObject_tp_setattro" , ret = Void , args = {PyTypeObject , setattrofunc }, call = Ignored )
863
+ @ CApiBuiltin (name = "Py_set_PyTypeObject_tp_subclasses" , ret = Void , args = {PyTypeObject , PyObject }, call = Ignored )
912
864
@ CApiBuiltin (name = "Py_set_PyTypeObject_tp_finalize" , ret = Void , args = {PyTypeObject , destructor }, call = Ignored )
913
865
@ CApiBuiltin (name = "Py_set_PyTypeObject_tp_iter" , ret = Void , args = {PyTypeObject , getiterfunc }, call = Ignored )
914
866
@ CApiBuiltin (name = "Py_set_PyTypeObject_tp_iternext" , ret = Void , args = {PyTypeObject , iternextfunc }, call = Ignored )
0 commit comments