@@ -315,7 +315,7 @@ static Object doForeignArray(Object left, Object right,
315
315
Object [] repeatedData = new Object [Math .max (0 , Math .multiplyExact (unpackForeignArray .length , rightInt ))];
316
316
317
317
// repeat data
318
- for (int i = 0 ; i < unpackForeignArray .length ; i ++) {
318
+ for (int i = 0 ; i < repeatedData .length ; i ++) {
319
319
repeatedData [i ] = unpackForeignArray [i % rightInt ];
320
320
}
321
321
@@ -340,12 +340,40 @@ static Object doForeignArrayForeignBoolean(Object left, Object right,
340
340
}
341
341
}
342
342
343
+ @ SuppressWarnings ("unused" )
344
+ @ Specialization (insertBefore = "doGeneric" , guards = {"lib.hasArrayElements(left)" , "isNegativeNumber(lib, right)" })
345
+ static Object doForeignArrayNegativeMult (Object left , Object right ,
346
+ @ Cached PythonObjectFactory factory ,
347
+ @ CachedLibrary (limit = "3" ) InteropLibrary lib ) {
348
+
349
+ return factory .createList ();
350
+ }
351
+
343
352
@ SuppressWarnings ("unused" )
344
353
@ Specialization (insertBefore = "doGeneric" , guards = {"!lib.fitsInDouble(left)" , "!lib.fitsInLong(left)" , "!lib.isBoolean(left)" , "!lib.hasArrayElements(left)" })
345
354
PNotImplemented doForeignGeneric (Object left , Object right ,
346
355
@ CachedLibrary (limit = "3" ) InteropLibrary lib ) {
347
356
return PNotImplemented .NOT_IMPLEMENTED ;
348
357
}
358
+
359
+ protected static boolean isNegativeNumber (InteropLibrary lib , Object right ) {
360
+ long val = 0 ;
361
+ try {
362
+ if (lib .fitsInByte (right )) {
363
+ val = lib .asByte (right );
364
+ } else if (lib .fitsInShort (right )) {
365
+ val = lib .asShort (right );
366
+ } else if (lib .fitsInInt (right )) {
367
+ val = lib .asInt (right );
368
+ } else if (lib .fitsInLong (right )) {
369
+ val = lib .asLong (right );
370
+ }
371
+ return val < 0 ;
372
+ } catch (UnsupportedMessageException e ) {
373
+ // fall through
374
+ }
375
+ return false ;
376
+ }
349
377
}
350
378
351
379
@ Builtin (name = __RMUL__ , minNumOfPositionalArgs = 2 )
0 commit comments