@@ -967,12 +967,12 @@ private static BigInteger asciiToBigInteger(String str, int possibleBase, boolea
967
967
968
968
public abstract Object executeWith (Object cls , Object arg , Object keywordArg );
969
969
970
- protected boolean isPrimitiveInt (PythonClass cls ) {
970
+ protected boolean isPrimitiveInt (LazyPythonClass cls ) {
971
971
return isPrimitiveProfile .profileClass (cls , PythonBuiltinClassType .PInt );
972
972
}
973
973
974
974
@ Specialization
975
- Object parseInt (PythonClass cls , boolean arg , @ SuppressWarnings ("unused" ) PNone keywordArg ) {
975
+ Object parseInt (LazyPythonClass cls , boolean arg , @ SuppressWarnings ("unused" ) PNone keywordArg ) {
976
976
if (isPrimitiveInt (cls )) {
977
977
return arg ? 1 : 0 ;
978
978
} else {
@@ -981,15 +981,15 @@ Object parseInt(PythonClass cls, boolean arg, @SuppressWarnings("unused") PNone
981
981
}
982
982
983
983
@ Specialization (guards = "isNoValue(keywordArg)" )
984
- public Object createInt (PythonClass cls , int arg , @ SuppressWarnings ("unused" ) PNone keywordArg ) {
984
+ public Object createInt (LazyPythonClass cls , int arg , @ SuppressWarnings ("unused" ) PNone keywordArg ) {
985
985
if (isPrimitiveInt (cls )) {
986
986
return arg ;
987
987
}
988
988
return factory ().createInt (cls , arg );
989
989
}
990
990
991
991
@ Specialization (guards = "isNoValue(keywordArg)" )
992
- public Object createInt (PythonClass cls , long arg , @ SuppressWarnings ("unused" ) PNone keywordArg ,
992
+ public Object createInt (LazyPythonClass cls , long arg , @ SuppressWarnings ("unused" ) PNone keywordArg ,
993
993
@ Cached ("createBinaryProfile()" ) ConditionProfile isIntProfile ) {
994
994
if (isPrimitiveInt (cls )) {
995
995
int intValue = (int ) arg ;
@@ -1003,7 +1003,7 @@ public Object createInt(PythonClass cls, long arg, @SuppressWarnings("unused") P
1003
1003
}
1004
1004
1005
1005
@ Specialization (guards = "isNoValue(keywordArg)" )
1006
- public Object createInt (PythonClass cls , double arg , @ SuppressWarnings ("unused" ) PNone keywordArg ,
1006
+ public Object createInt (LazyPythonClass cls , double arg , @ SuppressWarnings ("unused" ) PNone keywordArg ,
1007
1007
@ Cached ("createBinaryProfile()" ) ConditionProfile isIntProfile ) {
1008
1008
if (isPrimitiveInt (cls ) && isIntProfile .profile (arg >= Integer .MIN_VALUE && arg <= Integer .MAX_VALUE )) {
1009
1009
return (int ) arg ;
@@ -1012,15 +1012,15 @@ public Object createInt(PythonClass cls, double arg, @SuppressWarnings("unused")
1012
1012
}
1013
1013
1014
1014
@ Specialization
1015
- public Object createInt (PythonClass cls , @ SuppressWarnings ("unused" ) PNone none , @ SuppressWarnings ("unused" ) PNone keywordArg ) {
1015
+ public Object createInt (LazyPythonClass cls , @ SuppressWarnings ("unused" ) PNone none , @ SuppressWarnings ("unused" ) PNone keywordArg ) {
1016
1016
if (isPrimitiveInt (cls )) {
1017
1017
return 0 ;
1018
1018
}
1019
1019
return factory ().createInt (cls , 0 );
1020
1020
}
1021
1021
1022
1022
@ Specialization (guards = "isNoValue(keywordArg)" )
1023
- public Object createInt (PythonClass cls , String arg , @ SuppressWarnings ("unused" ) PNone keywordArg ) {
1023
+ public Object createInt (LazyPythonClass cls , String arg , @ SuppressWarnings ("unused" ) PNone keywordArg ) {
1024
1024
try {
1025
1025
Object value = stringToInt (arg , 10 );
1026
1026
if (isPrimitiveInt (cls )) {
@@ -1035,18 +1035,18 @@ public Object createInt(PythonClass cls, String arg, @SuppressWarnings("unused")
1035
1035
1036
1036
@ Specialization (guards = "isPrimitiveInt(cls)" , rewriteOn = NumberFormatException .class )
1037
1037
@ TruffleBoundary
1038
- int parseInt (PythonClass cls , PIBytesLike arg , int keywordArg ) throws NumberFormatException {
1038
+ int parseInt (LazyPythonClass cls , PIBytesLike arg , int keywordArg ) throws NumberFormatException {
1039
1039
return parseInt (cls , toString (arg ), keywordArg );
1040
1040
}
1041
1041
1042
1042
@ Specialization (guards = "isPrimitiveInt(cls)" , rewriteOn = NumberFormatException .class )
1043
1043
@ TruffleBoundary
1044
- long parseLong (PythonClass cls , PIBytesLike arg , int keywordArg ) throws NumberFormatException {
1044
+ long parseLong (LazyPythonClass cls , PIBytesLike arg , int keywordArg ) throws NumberFormatException {
1045
1045
return parseLong (cls , toString (arg ), keywordArg );
1046
1046
}
1047
1047
1048
1048
@ Specialization
1049
- Object parseBytesError (PythonClass cls , PIBytesLike arg , int base ,
1049
+ Object parseBytesError (LazyPythonClass cls , PIBytesLike arg , int base ,
1050
1050
@ Cached ("create()" ) BranchProfile errorProfile ) {
1051
1051
try {
1052
1052
return parsePInt (cls , toString (arg ), base );
@@ -1057,46 +1057,46 @@ Object parseBytesError(PythonClass cls, PIBytesLike arg, int base,
1057
1057
}
1058
1058
1059
1059
@ Specialization (guards = "isNoValue(base)" )
1060
- Object parseBytesError (PythonClass cls , PIBytesLike arg , @ SuppressWarnings ("unused" ) PNone base ,
1060
+ Object parseBytesError (LazyPythonClass cls , PIBytesLike arg , @ SuppressWarnings ("unused" ) PNone base ,
1061
1061
@ Cached ("create()" ) BranchProfile errorProfile ) {
1062
1062
return parseBytesError (cls , arg , 10 , errorProfile );
1063
1063
}
1064
1064
1065
1065
@ Specialization (guards = "isPrimitiveInt(cls)" , rewriteOn = NumberFormatException .class )
1066
- int parseInt (PythonClass cls , PString arg , int keywordArg ) throws NumberFormatException {
1066
+ int parseInt (LazyPythonClass cls , PString arg , int keywordArg ) throws NumberFormatException {
1067
1067
return parseInt (cls , arg .getValue (), keywordArg );
1068
1068
}
1069
1069
1070
1070
@ Specialization (guards = "isPrimitiveInt(cls)" , rewriteOn = NumberFormatException .class )
1071
1071
@ TruffleBoundary
1072
- long parseLong (PythonClass cls , PString arg , int keywordArg ) throws NumberFormatException {
1072
+ long parseLong (LazyPythonClass cls , PString arg , int keywordArg ) throws NumberFormatException {
1073
1073
return parseLong (cls , arg .getValue (), keywordArg );
1074
1074
}
1075
1075
1076
1076
@ Specialization
1077
- Object parsePInt (PythonClass cls , PString arg , int keywordArg ) {
1077
+ Object parsePInt (LazyPythonClass cls , PString arg , int keywordArg ) {
1078
1078
return parsePInt (cls , arg .getValue (), keywordArg );
1079
1079
}
1080
1080
1081
1081
@ Specialization (guards = "isNoValue(base)" )
1082
- Object parsePInt (PythonClass cls , PString arg , PNone base ) {
1082
+ Object parsePInt (LazyPythonClass cls , PString arg , PNone base ) {
1083
1083
return createInt (cls , arg .getValue (), base );
1084
1084
}
1085
1085
1086
1086
@ Specialization (guards = "isPrimitiveInt(cls)" , rewriteOn = NumberFormatException .class )
1087
1087
@ TruffleBoundary
1088
- int parseInt (@ SuppressWarnings ("unused" ) PythonClass cls , String arg , int keywordArg ) throws NumberFormatException {
1088
+ int parseInt (@ SuppressWarnings ("unused" ) LazyPythonClass cls , String arg , int keywordArg ) throws NumberFormatException {
1089
1089
return Integer .parseInt (arg , keywordArg );
1090
1090
}
1091
1091
1092
1092
@ Specialization (guards = "isPrimitiveInt(cls)" , rewriteOn = NumberFormatException .class )
1093
1093
@ TruffleBoundary
1094
- long parseLong (@ SuppressWarnings ("unused" ) PythonClass cls , String arg , int keywordArg ) throws NumberFormatException {
1094
+ long parseLong (@ SuppressWarnings ("unused" ) LazyPythonClass cls , String arg , int keywordArg ) throws NumberFormatException {
1095
1095
return Long .parseLong (arg , keywordArg );
1096
1096
}
1097
1097
1098
1098
@ Specialization (rewriteOn = NumberFormatException .class )
1099
- Object parsePInt (PythonClass cls , String arg , int base ) {
1099
+ Object parsePInt (LazyPythonClass cls , String arg , int base ) {
1100
1100
Object int2 = toInt (arg , base );
1101
1101
if (int2 instanceof BigInteger ) {
1102
1102
return factory ().createInt (cls , (BigInteger ) int2 );
@@ -1109,7 +1109,7 @@ Object parsePInt(PythonClass cls, String arg, int base) {
1109
1109
}
1110
1110
1111
1111
@ Specialization (replaces = "parsePInt" )
1112
- Object parsePIntError (PythonClass cls , String arg , int base ) {
1112
+ Object parsePIntError (LazyPythonClass cls , String arg , int base ) {
1113
1113
try {
1114
1114
return parsePInt (cls , arg , base );
1115
1115
} catch (NumberFormatException e ) {
@@ -1118,7 +1118,7 @@ Object parsePIntError(PythonClass cls, String arg, int base) {
1118
1118
}
1119
1119
1120
1120
@ Specialization
1121
- public Object createInt (PythonClass cls , String arg , Object keywordArg ) {
1121
+ public Object createInt (LazyPythonClass cls , String arg , Object keywordArg ) {
1122
1122
if (keywordArg instanceof PNone ) {
1123
1123
Object value = toInt (arg );
1124
1124
if (value == null ) {
@@ -1138,12 +1138,12 @@ public Object createInt(PythonClass cls, String arg, Object keywordArg) {
1138
1138
1139
1139
@ SuppressWarnings ("unused" )
1140
1140
@ Specialization (guards = {"!isString(arg)" , "!isNoValue(keywordArg)" })
1141
- Object fail (PythonClass cls , Object arg , Object keywordArg ) {
1141
+ Object fail (LazyPythonClass cls , Object arg , Object keywordArg ) {
1142
1142
throw raise (TypeError , "int() can't convert non-string with explicit base" );
1143
1143
}
1144
1144
1145
1145
@ Specialization (guards = {"isNoValue(keywordArg)" , "!isNoValue(obj)" , "!isHandledType(obj)" })
1146
- public Object createInt (PythonClass cls , Object obj , PNone keywordArg ,
1146
+ public Object createInt (LazyPythonClass cls , Object obj , PNone keywordArg ,
1147
1147
@ Cached ("create(__INT__)" ) LookupAndCallUnaryNode callIntNode ,
1148
1148
@ Cached ("create(__TRUNC__)" ) LookupAndCallUnaryNode callTruncNode ,
1149
1149
@ Cached ("createBinaryProfile()" ) ConditionProfile isIntProfile ) {
0 commit comments