@@ -237,7 +237,7 @@ private boolean eqInt(PIntRange range, int len, int start, int step) {
237
237
len , start , step );
238
238
}
239
239
240
- private boolean eqInt (int llen , int lstart , int lstep , int rlen , int rstart , int rstep ) {
240
+ private static boolean eqInt (int llen , int lstart , int lstep , int rlen , int rstart , int rstep ) {
241
241
if (llen != rlen ) {
242
242
return false ;
243
243
}
@@ -276,10 +276,6 @@ protected boolean canBeIntRange(PBigRange range, PythonObjectLibrary pol) {
276
276
return pol .canBeIndex (range .getPIntLength ()) && pol .canBeIndex (range .getPIntStart ()) && pol .canBeIndex (range .getPIntStep ());
277
277
}
278
278
279
- protected boolean canBeIntRange (Object len , Object start , Object step , PythonObjectLibrary pol ) {
280
- return pol .canBeIndex (len ) && pol .canBeIndex (start ) && pol .canBeIndex (step );
281
- }
282
-
283
279
@ Specialization
284
280
boolean eqIntInt (PIntRange left , PIntRange right ) {
285
281
if (left == right ) {
@@ -348,16 +344,15 @@ Object doPRangeObj(PRange range, @SuppressWarnings("unused") PObjectSlice slice)
348
344
return range ;
349
345
}
350
346
351
- @ Specialization (guards = "canBeNumber (idx)" )
347
+ @ Specialization (guards = "canBeInteger (idx)" )
352
348
Object doPRange (PIntRange primary , Object idx ) {
353
349
return primary .getIntItemNormalized (normalize .execute (idx , primary .getIntLength ()));
354
350
}
355
351
356
- @ Specialization (guards = "canBeNumber (idx)" )
352
+ @ Specialization (guards = "canBeInteger (idx)" )
357
353
Object doPRange (PBigRange self , Object idx ,
358
354
@ Cached CastToJavaBigIntegerNode toBigInt ) {
359
- BigInteger i = computeBigRangeItem (self , idx , toBigInt );
360
- return factory ().createInt (self .getBigIntItemNormalized (i ));
355
+ return factory ().createInt (self .getBigIntItemNormalized (computeBigRangeItem (self , idx , toBigInt )));
361
356
}
362
357
363
358
@ TruffleBoundary
@@ -411,9 +406,7 @@ Object doPRangeObjWithSlowPath(PIntRange range, PSlice slice,
411
406
SliceInfo info = compute .execute (slice , range .getIntLength ());
412
407
return createRange (info , rStart , rStep , lenOfRangeNode );
413
408
} catch (PException pe ) {
414
- if (!profileError .profileException (pe , PythonBuiltinClassType .OverflowError )) {
415
- throw pe ;
416
- }
409
+ pe .expect (PythonBuiltinClassType .OverflowError , profileError );
417
410
// pass
418
411
} catch (CannotCastException | ArithmeticException e ) {
419
412
// pass
@@ -440,9 +433,7 @@ Object doPRangePSliceSlowPath(PBigRange range, PSlice slice,
440
433
SliceInfo info = compute .execute (slice , lib .asSize (range .getLength ()));
441
434
return createRange (info , rStart , rStep , lenOfRangeNode );
442
435
} catch (PException pe ) {
443
- if (!profileError .profileException (pe , PythonBuiltinClassType .OverflowError )) {
444
- throw pe ;
445
- }
436
+ pe .expect (PythonBuiltinClassType .OverflowError , profileError );
446
437
// pass
447
438
} catch (CannotCastException | ArithmeticException e ) {
448
439
// pass
@@ -610,7 +601,7 @@ boolean containsSlowNum(PBigRange self, PInt other,
610
601
return containsBigInt (self , other .getValue ());
611
602
}
612
603
613
- @ Specialization (guards = "!canBeNumber (elem) || !isBuiltinPInt(elem, isBuiltin)" )
604
+ @ Specialization (guards = "!canBeInteger (elem) || !isBuiltinPInt(elem, isBuiltin)" )
614
605
boolean containsIterator (VirtualFrame frame , PRange self , Object elem ,
615
606
@ Cached ("createBinaryProfile()" ) ConditionProfile hasFrame ,
616
607
@ Cached GetIteratorExpressionNode .GetIteratorNode getIterator ,
@@ -685,7 +676,7 @@ int doFastRange(VirtualFrame frame, PIntRange self, int elem,
685
676
throw raise (ValueError , ErrorMessages .D_IS_NOT_IN_RANGE , elem );
686
677
}
687
678
688
- @ Specialization (guards = "canBeNumber (elem)" , limit = "getCallSiteInlineCacheMaxDepth()" )
679
+ @ Specialization (guards = "canBeInteger (elem)" , limit = "getCallSiteInlineCacheMaxDepth()" )
689
680
Object doFastRangeGeneric (VirtualFrame frame , PIntRange self , Object elem ,
690
681
@ Cached ContainsNode containsNode ,
691
682
@ Cached ("createBinaryProfile()" ) ConditionProfile hasFrame ,
@@ -705,7 +696,7 @@ Object doFastRangeGeneric(VirtualFrame frame, PIntRange self, Object elem,
705
696
throw raise (ValueError , ErrorMessages .IS_NOT_IN_RANGE , elem );
706
697
}
707
698
708
- @ Specialization (guards = "canBeNumber (elem)" )
699
+ @ Specialization (guards = "canBeInteger (elem)" )
709
700
Object doLongRange (VirtualFrame frame , PBigRange self , Object elem ,
710
701
@ Cached ContainsNode containsNode ,
711
702
@ Cached CastToJavaBigIntegerNode castToBigInt ) {
@@ -729,7 +720,7 @@ static boolean maySideEffect(PythonObject o, LookupInheritedAttributeNode.Dynami
729
720
* XXX: (mq) currently sys.maxsize in {@link SysModuleBuiltins#MAXSIZE} is
730
721
* {@link Integer#MAX_VALUE}.
731
722
*/
732
- @ Specialization (guards = "!canBeNumber (elem)" )
723
+ @ Specialization (guards = "!canBeInteger (elem)" )
733
724
Object containsIterator (VirtualFrame frame , PIntRange self , Object elem ,
734
725
@ Cached ("createBinaryProfile()" ) ConditionProfile hasFrame ,
735
726
@ Cached GetIteratorExpressionNode .GetIteratorNode getIterator ,
0 commit comments