47
47
import com .oracle .graal .python .builtins .objects .PNotImplemented ;
48
48
import com .oracle .graal .python .builtins .objects .cext .CExtNodes .GetNativeClassNode ;
49
49
import com .oracle .graal .python .builtins .objects .cext .PythonNativeObject ;
50
- import com .oracle .graal .python .builtins .objects .floats .PFloat ;
51
50
import com .oracle .graal .python .builtins .objects .getsetdescriptor .GetSetDescriptor ;
52
- import com .oracle .graal .python .builtins .objects .ints .PInt ;
53
51
import com .oracle .graal .python .builtins .objects .object .PythonObject ;
54
- import com .oracle .graal .python .builtins .objects .str .PString ;
55
- import com .oracle .graal .python .builtins .objects .type .PythonBuiltinClass ;
56
52
import com .oracle .graal .python .builtins .objects .type .PythonClass ;
57
53
import com .oracle .graal .python .nodes .BuiltinNames ;
58
54
import com .oracle .graal .python .nodes .PGuards ;
@@ -78,18 +74,9 @@ public static GetClassNode create() {
78
74
79
75
public abstract PythonClass execute (Object object );
80
76
81
- private PythonBuiltinClass cacheClass (Class <?> klass ) {
82
- return getCore ().lookupType (klass );
83
- }
84
-
85
77
@ Specialization
86
- protected PythonClass getIt (@ SuppressWarnings ("unused" ) GetSetDescriptor object ,
87
- @ Cached ("cacheGetSet()" ) PythonBuiltinClass klass ) {
88
- return klass ;
89
- }
90
-
91
- PythonBuiltinClass cacheGetSet () {
92
- return cacheClass (GetSetDescriptor .class );
78
+ protected PythonClass getIt (@ SuppressWarnings ("unused" ) GetSetDescriptor object ) {
79
+ return getCore ().lookupType (PythonBuiltinClassType .GetSetDescriptor );
93
80
}
94
81
95
82
@ Specialization (guards = "!isNone(object)" )
@@ -98,87 +85,51 @@ protected PythonClass getIt(PythonObject object,
98
85
return profile .profile (object .getPythonClass ());
99
86
}
100
87
101
- PythonBuiltinClass cacheNone () {
102
- return cacheClass (PNone .class );
103
- }
104
-
105
88
@ Specialization
106
- protected PythonClass getIt (@ SuppressWarnings ("unused" ) PNone object ,
107
- @ Cached ("cacheNone()" ) PythonBuiltinClass klass ) {
108
- return klass ;
109
- }
110
-
111
- PythonBuiltinClass cacheNotImplemented () {
112
- return cacheClass (PNotImplemented .class );
89
+ protected PythonClass getIt (@ SuppressWarnings ("unused" ) PNone object ) {
90
+ return getCore ().lookupType (PythonBuiltinClassType .PNone );
113
91
}
114
92
115
93
@ SuppressWarnings ("unused" )
116
94
@ Specialization
117
- protected PythonClass getIt (PNotImplemented object ,
118
- @ Cached ("cacheNotImplemented()" ) PythonBuiltinClass klass ) {
119
- return klass ;
120
- }
121
-
122
- PythonBuiltinClass cacheEllipsis () {
123
- return cacheClass (PEllipsis .class );
95
+ protected PythonClass getIt (PNotImplemented object ) {
96
+ return getCore ().lookupType (PythonBuiltinClassType .PNotImplemented );
124
97
}
125
98
126
99
@ SuppressWarnings ("unused" )
127
100
@ Specialization
128
- protected PythonClass getIt (PEllipsis object ,
129
- @ Cached ("cacheEllipsis()" ) PythonBuiltinClass klass ) {
130
- return klass ;
131
- }
132
-
133
- PythonBuiltinClass cacheBool () {
134
- return cacheClass (Boolean .class );
101
+ protected PythonClass getIt (PEllipsis object ) {
102
+ return getCore ().lookupType (PythonBuiltinClassType .PEllipsis );
135
103
}
136
104
137
105
@ SuppressWarnings ("unused" )
138
106
@ Specialization
139
- protected PythonClass getIt (boolean object ,
140
- @ Cached ("cacheBool()" ) PythonBuiltinClass klass ) {
141
- return klass ;
142
- }
143
-
144
- PythonBuiltinClass cacheInt () {
145
- return cacheClass (PInt .class );
107
+ protected PythonClass getIt (boolean object ) {
108
+ return getCore ().lookupType (PythonBuiltinClassType .Boolean );
146
109
}
147
110
148
111
@ SuppressWarnings ("unused" )
149
112
@ Specialization
150
- protected PythonClass getIt (int object ,
151
- @ Cached ("cacheInt()" ) PythonBuiltinClass klass ) {
152
- return klass ;
113
+ protected PythonClass getIt (int object ) {
114
+ return getCore ().lookupType (PythonBuiltinClassType .PInt );
153
115
}
154
116
155
117
@ SuppressWarnings ("unused" )
156
118
@ Specialization
157
- protected PythonClass getIt (long object ,
158
- @ Cached ("cacheInt()" ) PythonBuiltinClass klass ) {
159
- return klass ;
160
- }
161
-
162
- PythonBuiltinClass cacheFloat () {
163
- return cacheClass (PFloat .class );
119
+ protected PythonClass getIt (long object ) {
120
+ return getCore ().lookupType (PythonBuiltinClassType .PInt );
164
121
}
165
122
166
123
@ SuppressWarnings ("unused" )
167
124
@ Specialization
168
- protected PythonClass getIt (double object ,
169
- @ Cached ("cacheFloat()" ) PythonBuiltinClass klass ) {
170
- return klass ;
171
- }
172
-
173
- PythonBuiltinClass cacheString () {
174
- return cacheClass (PString .class );
125
+ protected PythonClass getIt (double object ) {
126
+ return getCore ().lookupType (PythonBuiltinClassType .PFloat );
175
127
}
176
128
177
129
@ SuppressWarnings ("unused" )
178
130
@ Specialization
179
- protected PythonClass getIt (String object ,
180
- @ Cached ("cacheString()" ) PythonBuiltinClass klass ) {
181
- return klass ;
131
+ protected PythonClass getIt (String object ) {
132
+ return getCore ().lookupType (PythonBuiltinClassType .PString );
182
133
}
183
134
184
135
@ Specialization
@@ -192,15 +143,10 @@ protected PythonClass getIt(PythonNativeObject object,
192
143
return getNativeClassNode .execute (object );
193
144
}
194
145
195
- PythonBuiltinClass cacheForeign () {
196
- return getCore ().lookupType (PythonBuiltinClassType .TruffleObject );
197
- }
198
-
199
146
@ SuppressWarnings ("unused" )
200
147
@ Specialization (guards = "isForeignObject(object)" )
201
- protected PythonClass getIt (TruffleObject object ,
202
- @ Cached ("cacheForeign()" ) PythonBuiltinClass klass ) {
203
- return klass ;
148
+ protected PythonClass getIt (TruffleObject object ) {
149
+ return getCore ().lookupType (PythonBuiltinClassType .TruffleObject );
204
150
}
205
151
206
152
@ TruffleBoundary
0 commit comments