@@ -164,17 +164,17 @@ long addLong(long left, long right) {
164
164
165
165
@ Specialization
166
166
PInt addPInt (long left , long right ) {
167
- return factory ().createInt (op (BigInteger . valueOf (left ), BigInteger . valueOf (right )));
167
+ return factory ().createInt (op (PInt . longToBigInteger (left ), PInt . longToBigInteger (right )));
168
168
}
169
169
170
170
@ Specialization
171
171
PInt add (PInt left , long right ) {
172
- return add ( left , factory ().createInt (right ));
172
+ return factory ().createInt (op ( left . getValue (), PInt . longToBigInteger ( right ) ));
173
173
}
174
174
175
175
@ Specialization
176
176
PInt add (long left , PInt right ) {
177
- return add ( factory ().createInt (left ), right );
177
+ return factory ().createInt (op ( PInt . longToBigInteger ( left ), right . getValue ()) );
178
178
}
179
179
180
180
@ Specialization
@@ -221,17 +221,17 @@ long doLL(long x, long y) throws ArithmeticException {
221
221
222
222
@ Specialization
223
223
PInt doLLOvf (long x , long y ) {
224
- return factory ().createInt (op (BigInteger . valueOf (x ), BigInteger . valueOf (y )));
224
+ return factory ().createInt (op (PInt . longToBigInteger (x ), PInt . longToBigInteger (y )));
225
225
}
226
226
227
227
@ Specialization
228
228
PInt doPIntLong (PInt left , long right ) {
229
- return doPIntPInt ( left , factory ().createInt (right ));
229
+ return factory ().createInt (op ( left . getValue (), PInt . longToBigInteger ( right ) ));
230
230
}
231
231
232
232
@ Specialization
233
233
PInt doLongPInt (long left , PInt right ) {
234
- return doPIntPInt ( factory ().createInt (left ), right );
234
+ return factory ().createInt (op ( PInt . longToBigInteger ( left ), right . getValue ()) );
235
235
}
236
236
237
237
@ Specialization
@@ -273,17 +273,17 @@ long doLL(long y, long x) throws ArithmeticException {
273
273
274
274
@ Specialization
275
275
PInt doLLOvf (long y , long x ) {
276
- return factory ().createInt (op (BigInteger . valueOf (x ), BigInteger . valueOf (y )));
276
+ return factory ().createInt (op (PInt . longToBigInteger (x ), PInt . longToBigInteger (y )));
277
277
}
278
278
279
279
@ Specialization
280
280
PInt doPIntLong (PInt right , long left ) {
281
- return doPIntPInt ( factory ().createInt (left ), right );
281
+ return factory ().createInt (op ( PInt . longToBigInteger ( left ), right . getValue ()) );
282
282
}
283
283
284
284
@ Specialization
285
285
PInt doLongPInt (long right , PInt left ) {
286
- return doPIntPInt ( factory ().createInt (right ), left );
286
+ return factory ().createInt (op ( PInt . longToBigInteger ( right ), left . getValue ()) );
287
287
}
288
288
289
289
@ Specialization
@@ -327,15 +327,15 @@ public abstract static class TrueDivNode extends PythonBinaryBuiltinNode {
327
327
328
328
@ Specialization
329
329
double doPI (long left , PInt right ) {
330
- return doPP ( factory (). createInt (left ), right );
330
+ return op ( PInt . longToBigInteger (left ), right . getValue () );
331
331
}
332
332
333
333
@ Specialization
334
334
double doPL (PInt left , long right ) {
335
335
if (right == 0 ) {
336
336
throw raise (PythonErrorType .ZeroDivisionError , "division by zero" );
337
337
}
338
- return doPP (left , factory (). createInt (right ));
338
+ return op (left . getValue (), PInt . longToBigInteger (right ));
339
339
}
340
340
341
341
@ Specialization
@@ -391,7 +391,7 @@ public abstract static class RTrueDivNode extends PythonBinaryBuiltinNode {
391
391
392
392
@ Specialization
393
393
double doPL (PInt right , long left ) {
394
- return doPP (right , factory (). createInt (left ));
394
+ return op (right . getValue (), PInt . longToBigInteger (left ));
395
395
}
396
396
397
397
@ Specialization
@@ -477,13 +477,13 @@ long doLPiOvf(long left, PInt right) {
477
477
@ Specialization
478
478
PInt doPiL (PInt left , int right ) {
479
479
raiseDivisionByZero (right == 0 );
480
- return factory ().createInt (op (left .getValue (), BigInteger . valueOf (right )));
480
+ return factory ().createInt (op (left .getValue (), PInt . longToBigInteger (right )));
481
481
}
482
482
483
483
@ Specialization
484
484
PInt doPiL (PInt left , long right ) {
485
485
raiseDivisionByZero (right == 0 );
486
- return factory ().createInt (op (left .getValue (), BigInteger . valueOf (right )));
486
+ return factory ().createInt (op (left .getValue (), PInt . longToBigInteger (right )));
487
487
}
488
488
489
489
@ Specialization
@@ -530,13 +530,13 @@ long doLL(long right, long left) {
530
530
@ Specialization
531
531
PInt doPiL (PInt right , long left ) {
532
532
raiseDivisionByZero (right .isZero ());
533
- return factory ().createInt (op (BigInteger . valueOf (left ), right .getValue ()));
533
+ return factory ().createInt (op (PInt . longToBigInteger (left ), right .getValue ()));
534
534
}
535
535
536
536
@ Specialization
537
537
PInt doLPi (long right , PInt left ) {
538
538
raiseDivisionByZero (right == 0 );
539
- return factory ().createInt (op (left .getValue (), BigInteger . valueOf (right )));
539
+ return factory ().createInt (op (left .getValue (), PInt . longToBigInteger (right )));
540
540
}
541
541
542
542
@ Specialization
@@ -576,13 +576,13 @@ long doLL(long left, long right) {
576
576
@ Specialization
577
577
PInt doLPi (long left , PInt right ) {
578
578
raiseDivisionByZero (right .isZero ());
579
- return factory ().createInt (op (BigInteger . valueOf (left ), right .getValue ()));
579
+ return factory ().createInt (op (PInt . longToBigInteger (left ), right .getValue ()));
580
580
}
581
581
582
582
@ Specialization (guards = "right >= 0" )
583
583
PInt doPiL (PInt left , long right ) {
584
584
raiseDivisionByZero (right == 0 );
585
- return factory ().createInt (op (left .getValue (), BigInteger . valueOf (right )));
585
+ return factory ().createInt (op (left .getValue (), PInt . longToBigInteger (right )));
586
586
}
587
587
588
588
@ Specialization (guards = "right.isZeroOrPositive()" )
@@ -593,7 +593,7 @@ PInt doPiPi(PInt left, PInt right) {
593
593
594
594
@ Specialization (guards = "right < 0" )
595
595
PInt doPiLNeg (PInt left , long right ) {
596
- return factory ().createInt (opNeg (left .getValue (), BigInteger . valueOf (right )));
596
+ return factory ().createInt (opNeg (left .getValue (), PInt . longToBigInteger (right )));
597
597
}
598
598
599
599
@ Specialization (guards = "!right.isZeroOrPositive()" )
@@ -649,7 +649,7 @@ PInt doLLOvf(long x, long y) {
649
649
if (((ax | ay ) >>> 31 != 0 )) {
650
650
int leadingZeros = Long .numberOfLeadingZeros (ax ) + Long .numberOfLeadingZeros (ay );
651
651
if (leadingZeros < 66 ) {
652
- return factory ().createInt (mul (BigInteger . valueOf (x ), BigInteger . valueOf (y )));
652
+ return factory ().createInt (mul (PInt . longToBigInteger (x ), PInt . longToBigInteger (y )));
653
653
}
654
654
}
655
655
return factory ().createInt (r );
@@ -668,7 +668,7 @@ PInt doPIntLongOne(PInt left, @SuppressWarnings("unused") long right) {
668
668
669
669
@ Specialization (guards = {"right != 0" , "right != 1" })
670
670
PInt doPIntLong (PInt left , long right ) {
671
- return factory ().createInt (mul (left .getValue (), BigInteger . valueOf (right )));
671
+ return factory ().createInt (mul (left .getValue (), PInt . longToBigInteger (right )));
672
672
}
673
673
674
674
@ Specialization
@@ -733,7 +733,7 @@ int doIntegerFast(int left, int right, @SuppressWarnings("unused") PNone none) {
733
733
734
734
@ Specialization (guards = "right >= 0" )
735
735
PInt doInteger (int left , int right , @ SuppressWarnings ("unused" ) PNone none ) {
736
- return factory ().createInt (op (BigInteger . valueOf (left ), right ));
736
+ return factory ().createInt (op (PInt . longToBigInteger (left ), right ));
737
737
}
738
738
739
739
@ Specialization (guards = "right >= 0" , rewriteOn = ArithmeticException .class )
@@ -773,7 +773,7 @@ long doLongFast(long left, long right, @SuppressWarnings("unused") PNone none) {
773
773
774
774
@ Specialization (guards = "right >= 0" )
775
775
PInt doLong (long left , long right , @ SuppressWarnings ("unused" ) PNone none ) {
776
- return factory ().createInt (op (BigInteger . valueOf (left ), right ));
776
+ return factory ().createInt (op (PInt . longToBigInteger (left ), right ));
777
777
}
778
778
779
779
@ Specialization
@@ -839,7 +839,7 @@ private BigInteger op(BigInteger a, long b) {
839
839
} else if (value == 1 ) {
840
840
return BigInteger .ONE ;
841
841
} else if (value == -1 ) {
842
- return (b & 1 ) != 0 ? BigInteger . valueOf (-1 ) : BigInteger .ONE ;
842
+ return (b & 1 ) != 0 ? PInt . longToBigInteger (-1 ) : BigInteger .ONE ;
843
843
}
844
844
} catch (ArithmeticException e ) {
845
845
// fall through to normal computation
@@ -888,9 +888,9 @@ long pos(long arg) {
888
888
PInt posOvf (long arg ) throws IllegalArgumentException {
889
889
long result = Math .abs (arg );
890
890
if (result < 0 ) {
891
- return factory ().createInt (op (BigInteger . valueOf (arg )));
891
+ return factory ().createInt (op (PInt . longToBigInteger (arg )));
892
892
} else {
893
- return factory ().createInt (BigInteger . valueOf (arg ));
893
+ return factory ().createInt (PInt . longToBigInteger (arg ));
894
894
}
895
895
}
896
896
@@ -986,7 +986,7 @@ long neg(long arg) {
986
986
987
987
@ Specialization
988
988
PInt negOvf (long arg ) {
989
- BigInteger value = arg == Long .MIN_VALUE ? negate (BigInteger . valueOf (arg )) : BigInteger . valueOf (-arg );
989
+ BigInteger value = arg == Long .MIN_VALUE ? negate (PInt . longToBigInteger (arg )) : PInt . longToBigInteger (-arg );
990
990
return factory ().createInt (value );
991
991
}
992
992
@@ -1084,7 +1084,7 @@ Object doIIOvf(int left, int right) {
1084
1084
try {
1085
1085
return leftShiftExact (left , right );
1086
1086
} catch (ArithmeticException e ) {
1087
- return doGuardedBiI (BigInteger . valueOf (left ), right );
1087
+ return doGuardedBiI (PInt . longToBigInteger (left ), right );
1088
1088
}
1089
1089
}
1090
1090
@@ -1102,7 +1102,7 @@ Object doLLOvf(long left, long right) {
1102
1102
} catch (ArithmeticException e ) {
1103
1103
int rightI = (int ) right ;
1104
1104
if (rightI == right ) {
1105
- return factory ().createInt (op (BigInteger . valueOf (left ), rightI ));
1105
+ return factory ().createInt (op (PInt . longToBigInteger (left ), rightI ));
1106
1106
} else {
1107
1107
throw raise (PythonErrorType .OverflowError );
1108
1108
}
@@ -1113,7 +1113,7 @@ Object doLLOvf(long left, long right) {
1113
1113
PInt doLPi (long left , PInt right ) {
1114
1114
raiseNegativeShiftCount (!right .isZeroOrPositive ());
1115
1115
try {
1116
- return factory ().createInt (op (BigInteger . valueOf (left ), right .intValue ()));
1116
+ return factory ().createInt (op (PInt . longToBigInteger (left ), right .intValue ()));
1117
1117
} catch (ArithmeticException e ) {
1118
1118
throw raise (PythonErrorType .OverflowError );
1119
1119
}
@@ -1191,13 +1191,13 @@ long doLL(long left, long right) {
1191
1191
@ Specialization
1192
1192
PInt doIPi (int left , PInt right ) {
1193
1193
raiseNegativeShiftCount (!right .isZeroOrPositive ());
1194
- return factory ().createInt (op (BigInteger . valueOf (left ), right .intValue ()));
1194
+ return factory ().createInt (op (PInt . longToBigInteger (left ), right .intValue ()));
1195
1195
}
1196
1196
1197
1197
@ Specialization
1198
1198
PInt doLPi (long left , PInt right ) {
1199
1199
raiseNegativeShiftCount (!right .isZeroOrPositive ());
1200
- return factory ().createInt (op (BigInteger . valueOf (left ), right .intValue ()));
1200
+ return factory ().createInt (op (PInt . longToBigInteger (left ), right .intValue ()));
1201
1201
}
1202
1202
1203
1203
@ Specialization
@@ -1266,12 +1266,12 @@ long doInteger(long left, long right) {
1266
1266
1267
1267
@ Specialization
1268
1268
PInt doPInt (long left , PInt right ) {
1269
- return factory ().createInt (op (BigInteger . valueOf (left ), right .getValue ()));
1269
+ return factory ().createInt (op (PInt . longToBigInteger (left ), right .getValue ()));
1270
1270
}
1271
1271
1272
1272
@ Specialization
1273
1273
PInt doPInt (PInt left , long right ) {
1274
- return factory ().createInt (op (left .getValue (), BigInteger . valueOf (right )));
1274
+ return factory ().createInt (op (left .getValue (), PInt . longToBigInteger (right )));
1275
1275
}
1276
1276
1277
1277
@ Specialization
@@ -1449,10 +1449,10 @@ boolean eqVoidPtrPInt(PythonNativeVoidPtr a, PInt b,
1449
1449
long ptrVal = lib .asPointer (a .object );
1450
1450
if (ptrVal < 0 ) {
1451
1451
// pointers are considered unsigned
1452
- BigInteger bi = BigInteger . valueOf (ptrVal ).add (BigInteger .ONE .shiftLeft (64 ));
1452
+ BigInteger bi = PInt . longToBigInteger (ptrVal ).add (BigInteger .ONE .shiftLeft (64 ));
1453
1453
return bi .equals (b .getValue ());
1454
1454
}
1455
- return BigInteger . valueOf (ptrVal ).equals (b .getValue ());
1455
+ return PInt . longToBigInteger (ptrVal ).equals (b .getValue ());
1456
1456
} catch (UnsupportedMessageException e ) {
1457
1457
// fall through
1458
1458
}
0 commit comments