@@ -203,7 +203,7 @@ protected static boolean isNegativeNumber(InteropLibrary lib, Object right) {
203
203
}
204
204
205
205
protected static boolean isPythonLikeSequence (InteropLibrary lib , Object receiver ) {
206
- return lib .hasArrayElements (receiver ) || lib . isString ( receiver ) ;
206
+ return lib .hasArrayElements (receiver );
207
207
}
208
208
209
209
@ Specialization (guards = {"!reverse" , "lib.isBoolean(left)" })
@@ -236,6 +236,15 @@ Object doComparisonDouble(Object left, Object right,
236
236
}
237
237
}
238
238
239
+ @ Specialization (guards = {"!reverse" , "lib.isString(left)" })
240
+ Object doComparisonString (Object left , Object right ,
241
+ @ CachedLibrary (limit = "3" ) InteropLibrary lib ) {
242
+ try {
243
+ return op .executeObject (lib .asString (left ), right );
244
+ } catch (UnsupportedMessageException e ) {
245
+ return PNotImplemented .NOT_IMPLEMENTED ;
246
+ }
247
+ }
239
248
@ Specialization (guards = {"reverse" , "lib.isBoolean(right)" })
240
249
Object doComparisonBoolR (Object left , Object right ,
241
250
@ CachedLibrary (limit = "3" ) InteropLibrary lib ) {
@@ -266,6 +275,16 @@ Object doComparisonDoubleR(Object left, Object right,
266
275
}
267
276
}
268
277
278
+ @ Specialization (guards = {"reverse" , "lib.isString(right)" })
279
+ Object doComparisonStringR (Object left , Object right ,
280
+ @ CachedLibrary (limit = "3" ) InteropLibrary lib ) {
281
+ try {
282
+ return op .executeObject (left , lib .asString (right ));
283
+ } catch (UnsupportedMessageException e ) {
284
+ return PNotImplemented .NOT_IMPLEMENTED ;
285
+ }
286
+ }
287
+
269
288
@ SuppressWarnings ("unused" )
270
289
@ Specialization (guards = {"!reverse" , "!lib.fitsInDouble(left)" , "!lib.fitsInLong(left)" , "!lib.isBoolean(left)" })
271
290
public PNotImplemented doGeneric (Object left , Object right ,
@@ -327,7 +346,7 @@ abstract static class MulNode extends ForeignBinaryNode {
327
346
super (BinaryArithmetic .Mul .create (), false );
328
347
}
329
348
330
- @ Specialization (insertBefore = "doGeneric " , guards = {"isPythonLikeSequence(lib, left)" , "lib.fitsInInt(right)" })
349
+ @ Specialization (insertBefore = "doComparisonBool " , guards = {"isPythonLikeSequence(lib, left)" , "lib.fitsInInt(right)" })
331
350
static Object doForeignArray (Object left , Object right ,
332
351
@ Cached PRaiseNode raise ,
333
352
@ Cached PythonObjectFactory factory ,
@@ -357,7 +376,7 @@ static Object doForeignArray(Object left, Object right,
357
376
}
358
377
}
359
378
360
- @ Specialization (insertBefore = "doGeneric " , guards = {"isPythonLikeSequence(lib, left)" , "lib.isBoolean(right)" })
379
+ @ Specialization (insertBefore = "doComparisonBool " , guards = {"isPythonLikeSequence(lib, left)" , "lib.isBoolean(right)" })
361
380
static Object doForeignArrayForeignBoolean (Object left , Object right ,
362
381
@ Cached PRaiseNode raise ,
363
382
@ Cached PythonObjectFactory factory ,
@@ -395,7 +414,7 @@ abstract static class RMulNode extends ForeignBinaryNode {
395
414
super (BinaryArithmetic .Mul .create (), true );
396
415
}
397
416
398
- @ Specialization (guards = {"isPythonLikeSequence(lib, right)" , "lib.fitsInInt(left)" })
417
+ @ Specialization (insertBefore = "doComparisonBool" , guards = {"isPythonLikeSequence(lib, right)" , "lib.fitsInInt(left)" })
399
418
Object doForeignArray (Object right , Object left ,
400
419
@ Cached PRaiseNode raise ,
401
420
@ Cached PythonObjectFactory factory ,
@@ -404,7 +423,7 @@ Object doForeignArray(Object right, Object left,
404
423
return MulNode .doForeignArray (right , left , raise , factory , convert , lib );
405
424
}
406
425
407
- @ Specialization (guards = {"isPythonLikeSequence(lib, right)" , "lib.isBoolean(left)" })
426
+ @ Specialization (insertBefore = "doComparisonBool" , guards = {"isPythonLikeSequence(lib, right)" , "lib.isBoolean(left)" })
408
427
Object doForeignArrayForeignBoolean (Object right , Object left ,
409
428
@ Cached PRaiseNode raise ,
410
429
@ Cached PythonObjectFactory factory ,
0 commit comments