@@ -202,10 +202,6 @@ protected static boolean isNegativeNumber(InteropLibrary lib, Object right) {
202
202
return false ;
203
203
}
204
204
205
- protected static boolean isPythonLikeSequence (InteropLibrary lib , Object receiver ) {
206
- return lib .hasArrayElements (receiver );
207
- }
208
-
209
205
@ Specialization (guards = {"!reverse" , "lib.isBoolean(left)" })
210
206
Object doComparisonBool (Object left , Object right ,
211
207
@ CachedLibrary (limit = "3" ) InteropLibrary lib ) {
@@ -245,59 +241,52 @@ Object doComparisonString(Object left, Object right,
245
241
return PNotImplemented .NOT_IMPLEMENTED ;
246
242
}
247
243
}
248
- @ Specialization (guards = {"reverse" , "lib.isBoolean(right )" })
244
+ @ Specialization (guards = {"reverse" , "lib.isBoolean(left )" })
249
245
Object doComparisonBoolR (Object left , Object right ,
250
246
@ CachedLibrary (limit = "3" ) InteropLibrary lib ) {
251
247
try {
252
- return op .executeObject (left , lib .asBoolean (right ));
248
+ return op .executeObject (right , lib .asBoolean (left ));
253
249
} catch (UnsupportedMessageException e ) {
254
250
return PNotImplemented .NOT_IMPLEMENTED ;
255
251
}
256
252
}
257
253
258
- @ Specialization (guards = {"reverse" , "lib.fitsInLong(right )" })
254
+ @ Specialization (guards = {"reverse" , "lib.fitsInLong(left )" })
259
255
Object doComparisonLongR (Object left , Object right ,
260
256
@ CachedLibrary (limit = "3" ) InteropLibrary lib ) {
261
257
try {
262
- return op .executeObject (left , lib .asLong (right ));
258
+ return op .executeObject (right , lib .asLong (left ));
263
259
} catch (UnsupportedMessageException e ) {
264
260
return PNotImplemented .NOT_IMPLEMENTED ;
265
261
}
266
262
}
267
263
268
- @ Specialization (guards = {"reverse" , "lib.fitsInDouble(right )" })
264
+ @ Specialization (guards = {"reverse" , "lib.fitsInDouble(left )" })
269
265
Object doComparisonDoubleR (Object left , Object right ,
270
266
@ CachedLibrary (limit = "3" ) InteropLibrary lib ) {
271
267
try {
272
- return op .executeObject (left , lib .asDouble (right ));
268
+ return op .executeObject (right , lib .asDouble (left ));
273
269
} catch (UnsupportedMessageException e ) {
274
270
return PNotImplemented .NOT_IMPLEMENTED ;
275
271
}
276
272
}
277
273
278
- @ Specialization (guards = {"reverse" , "lib.isString(right )" })
274
+ @ Specialization (guards = {"reverse" , "lib.isString(left )" })
279
275
Object doComparisonStringR (Object left , Object right ,
280
276
@ CachedLibrary (limit = "3" ) InteropLibrary lib ) {
281
277
try {
282
- return op .executeObject (left , lib .asString (right ));
278
+ return op .executeObject (right , lib .asString (left ));
283
279
} catch (UnsupportedMessageException e ) {
284
280
return PNotImplemented .NOT_IMPLEMENTED ;
285
281
}
286
282
}
287
283
288
284
@ SuppressWarnings ("unused" )
289
- @ Specialization (guards = {"!reverse" , "! lib.fitsInDouble(left)" , "!lib.fitsInLong(left)" , "!lib.isBoolean(left)" })
285
+ @ Specialization (guards = {"!lib.fitsInDouble(left)" , "!lib.fitsInLong(left)" , "!lib.isBoolean(left)" })
290
286
public PNotImplemented doGeneric (Object left , Object right ,
291
287
@ CachedLibrary (limit = "3" ) InteropLibrary lib ) {
292
288
return PNotImplemented .NOT_IMPLEMENTED ;
293
289
}
294
-
295
- @ SuppressWarnings ("unused" )
296
- @ Specialization (guards = {"reverse" , "!lib.fitsInDouble(right)" , "!lib.fitsInLong(right)" , "!lib.isBoolean(right)" })
297
- public PNotImplemented doGenericReverse (Object left , Object right ,
298
- @ CachedLibrary (limit = "3" ) InteropLibrary lib ) {
299
- return PNotImplemented .NOT_IMPLEMENTED ;
300
- }
301
290
}
302
291
303
292
@ Builtin (name = __ADD__ , minNumOfPositionalArgs = 2 )
@@ -346,6 +335,10 @@ abstract static class MulNode extends ForeignBinaryNode {
346
335
super (BinaryArithmetic .Mul .create (), false );
347
336
}
348
337
338
+ protected static boolean isPythonLikeSequence (InteropLibrary lib , Object receiver ) {
339
+ return lib .hasArrayElements (receiver );
340
+ }
341
+
349
342
@ Specialization (insertBefore = "doComparisonBool" , guards = {"isPythonLikeSequence(lib, left)" , "lib.fitsInInt(right)" })
350
343
static Object doForeignArray (Object left , Object right ,
351
344
@ Cached PRaiseNode raise ,
@@ -365,7 +358,7 @@ static Object doForeignArray(Object left, Object right,
365
358
366
359
// repeat data
367
360
for (int i = 0 ; i < repeatedData .length ; i ++) {
368
- repeatedData [i ] = unpackForeignArray [i % rightInt ];
361
+ repeatedData [i ] = unpackForeignArray [i % unpackForeignArray . length ];
369
362
}
370
363
371
364
return factory .createList (repeatedData );
@@ -409,39 +402,7 @@ PNotImplemented doForeignGeneric(Object left, Object right,
409
402
410
403
@ Builtin (name = __RMUL__ , minNumOfPositionalArgs = 2 )
411
404
@ GenerateNodeFactory
412
- abstract static class RMulNode extends ForeignBinaryNode {
413
- RMulNode () {
414
- super (BinaryArithmetic .Mul .create (), true );
415
- }
416
-
417
- @ Specialization (insertBefore = "doComparisonBool" , guards = {"isPythonLikeSequence(lib, right)" , "lib.fitsInInt(left)" })
418
- Object doForeignArray (Object right , Object left ,
419
- @ Cached PRaiseNode raise ,
420
- @ Cached PythonObjectFactory factory ,
421
- @ Cached PForeignToPTypeNode convert ,
422
- @ CachedLibrary (limit = "1" ) InteropLibrary lib ) {
423
- return MulNode .doForeignArray (right , left , raise , factory , convert , lib );
424
- }
425
-
426
- @ Specialization (insertBefore = "doComparisonBool" , guards = {"isPythonLikeSequence(lib, right)" , "lib.isBoolean(left)" })
427
- Object doForeignArrayForeignBoolean (Object right , Object left ,
428
- @ Cached PRaiseNode raise ,
429
- @ Cached PythonObjectFactory factory ,
430
- @ Cached PForeignToPTypeNode convert ,
431
- @ CachedLibrary (limit = "1" ) InteropLibrary lib ) {
432
- try {
433
- return MulNode .doForeignArray (right , lib .asBoolean (left ) ? 1 : 0 , raise , factory , convert , lib );
434
- } catch (UnsupportedMessageException e ) {
435
- return PNotImplemented .NOT_IMPLEMENTED ;
436
- }
437
- }
438
-
439
- @ SuppressWarnings ("unused" )
440
- @ Specialization (insertBefore = "doGeneric" , guards = {"!lib.fitsInDouble(right)" , "!lib.fitsInLong(right)" , "!lib.isBoolean(right)" , "!isPythonLikeSequence(lib, right)" })
441
- PNotImplemented doForeignGneeric (Object right , Object left ,
442
- @ CachedLibrary (limit = "3" ) InteropLibrary lib ) {
443
- return PNotImplemented .NOT_IMPLEMENTED ;
444
- }
405
+ abstract static class RMulNode extends MulNode {
445
406
}
446
407
447
408
@ Builtin (name = __SUB__ , minNumOfPositionalArgs = 2 )
0 commit comments