@@ -222,6 +222,7 @@ boolean bool(double self) {
222
222
}
223
223
224
224
@ Builtin (name = __INT__ , minNumOfPositionalArgs = 1 )
225
+ @ Builtin (name = __TRUNC__ , minNumOfPositionalArgs = 1 )
225
226
@ GenerateNodeFactory
226
227
@ ImportStatic (MathGuards .class )
227
228
@ TypeSystemReference (PythonArithmeticTypes .class )
@@ -1563,44 +1564,6 @@ abstract static class ConjugateNode extends RealNode {
1563
1564
1564
1565
}
1565
1566
1566
- @ Builtin (name = __TRUNC__ , minNumOfPositionalArgs = 1 )
1567
- @ GenerateNodeFactory
1568
- abstract static class TruncNode extends PythonUnaryBuiltinNode {
1569
-
1570
- @ TruffleBoundary
1571
- protected static int truncate (double value ) {
1572
- return (int ) (value < 0 ? Math .ceil (value ) : Math .floor (value ));
1573
- }
1574
-
1575
- @ Specialization
1576
- int trunc (double value ,
1577
- @ Cached ("createBinaryProfile()" ) ConditionProfile nanProfile ,
1578
- @ Cached ("createBinaryProfile()" ) ConditionProfile infProfile ) {
1579
- if (nanProfile .profile (Double .isNaN (value ))) {
1580
- throw raise (PythonErrorType .ValueError , ErrorMessages .CANNOT_CONVERT_S_TO_INT , "float NaN" );
1581
- }
1582
- if (infProfile .profile (Double .isInfinite (value ))) {
1583
- throw raise (PythonErrorType .OverflowError , ErrorMessages .CANNOT_CONVERT_S_TO_INT , "float infinity" );
1584
- }
1585
- return truncate (value );
1586
- }
1587
-
1588
- @ Specialization
1589
- int trunc (PFloat pValue ,
1590
- @ Cached ("createBinaryProfile()" ) ConditionProfile nanProfile ,
1591
- @ Cached ("createBinaryProfile()" ) ConditionProfile infProfile ) {
1592
- double value = pValue .getValue ();
1593
- if (nanProfile .profile (Double .isNaN (value ))) {
1594
- throw raise (PythonErrorType .ValueError , ErrorMessages .CANNOT_CONVERT_S_TO_INT , "float NaN" );
1595
- }
1596
- if (infProfile .profile (Double .isInfinite (value ))) {
1597
- throw raise (PythonErrorType .OverflowError , ErrorMessages .CANNOT_CONVERT_S_TO_INT , "float infinity" );
1598
- }
1599
- return truncate (value );
1600
- }
1601
-
1602
- }
1603
-
1604
1567
@ Builtin (name = __GETFORMAT__ , minNumOfPositionalArgs = 2 , isClassmethod = true )
1605
1568
@ GenerateNodeFactory
1606
1569
@ TypeSystemReference (PythonArithmeticTypes .class )
0 commit comments