@@ -141,54 +141,27 @@ protected List<? extends NodeFactory<? extends PythonBuiltinBaseNode>> getNodeFa
141
141
@ Builtin (name = __BOOL__ , minNumOfPositionalArgs = 1 )
142
142
@ GenerateNodeFactory
143
143
abstract static class BoolNode extends PythonUnaryBuiltinNode {
144
- @ Specialization (guards = "lib.isBoolean(receiver)" , limit = "getCallSiteInlineCacheMaxDepth()" )
144
+ @ Specialization (limit = "getCallSiteInlineCacheMaxDepth()" )
145
145
static boolean bool (Object receiver ,
146
146
@ CachedLibrary ("receiver" ) InteropLibrary lib ) {
147
147
try {
148
- return lib .asBoolean (receiver );
149
- } catch (UnsupportedMessageException e ) {
150
- throw CompilerDirectives .shouldNotReachHere (e );
151
- }
152
- }
153
-
154
- @ Specialization (guards = "lib.fitsInLong(receiver)" , limit = "getCallSiteInlineCacheMaxDepth()" )
155
- static boolean integer (Object receiver ,
156
- @ CachedLibrary ("receiver" ) InteropLibrary lib ) {
157
- try {
158
- return lib .asLong (receiver ) != 0 ;
159
- } catch (UnsupportedMessageException e ) {
160
- throw CompilerDirectives .shouldNotReachHere (e );
161
- }
162
- }
163
-
164
- @ Specialization (guards = "lib.fitsInDouble(receiver)" , limit = "getCallSiteInlineCacheMaxDepth()" )
165
- static boolean floatingPoint (Object receiver ,
166
- @ CachedLibrary ("receiver" ) InteropLibrary lib ) {
167
- try {
168
- return lib .asDouble (receiver ) != 0.0 ;
169
- } catch (UnsupportedMessageException e ) {
170
- throw CompilerDirectives .shouldNotReachHere (e );
171
- }
172
- }
173
-
174
- @ Specialization (guards = "lib.hasArrayElements(receiver)" , limit = "getCallSiteInlineCacheMaxDepth()" )
175
- static boolean array (Object receiver ,
176
- @ CachedLibrary ("receiver" ) InteropLibrary lib ) {
177
- try {
178
- return lib .getArraySize (receiver ) > 0 ;
148
+ if (lib .isBoolean (receiver )) {
149
+ return lib .asBoolean (receiver );
150
+ }
151
+ if (lib .fitsInLong (receiver )) {
152
+ return lib .asLong (receiver ) != 0 ;
153
+ }
154
+ if (lib .fitsInDouble (receiver )) {
155
+ return lib .asDouble (receiver ) != 0.0 ;
156
+ }
157
+ if (lib .hasArrayElements (receiver )) {
158
+ return lib .getArraySize (receiver ) != 0 ;
159
+ }
160
+ return !lib .isNull (receiver );
179
161
} catch (UnsupportedMessageException e ) {
180
162
throw CompilerDirectives .shouldNotReachHere (e );
181
163
}
182
164
}
183
-
184
- @ Specialization (guards = {
185
- "!lib.isBoolean(receiver)" , "!lib.fitsInLong(receiver)" ,
186
- "!lib.fitsInDouble(receiver)" , "!lib.hasArrayElements(receiver)"
187
- }, limit = "getCallSiteInlineCacheMaxDepth()" )
188
- static boolean generic (Object receiver ,
189
- @ CachedLibrary ("receiver" ) InteropLibrary lib ) {
190
- return !lib .isNull (receiver );
191
- }
192
165
}
193
166
194
167
static Object [] unpackForeignArray (Object left , InteropLibrary lib , PForeignToPTypeNode convert ) {
0 commit comments