|
129 | 129 | import com.oracle.truffle.api.nodes.UnexpectedResultException;
|
130 | 130 | import com.oracle.truffle.api.profiles.InlinedConditionProfile;
|
131 | 131 | import com.oracle.truffle.api.strings.TruffleString;
|
| 132 | +import com.oracle.truffle.api.strings.TruffleString.FromJavaStringNode; |
132 | 133 |
|
133 | 134 | @CoreFunctions(extendClasses = PythonBuiltinClassType.PFloat)
|
134 | 135 | public final class FloatBuiltins extends PythonBuiltins {
|
@@ -863,10 +864,21 @@ private static String makeHexNumber(double value) {
|
863 | 864 | }
|
864 | 865 |
|
865 | 866 | @Specialization
|
866 |
| - public static TruffleString hexD(double value, |
867 |
| - @Cached TruffleString.FromJavaStringNode fromJavaStringNode) { |
| 867 | + static TruffleString doDouble(double value, |
| 868 | + @Shared @Cached FromJavaStringNode fromJavaStringNode) { |
868 | 869 | return fromJavaStringNode.execute(makeHexNumber(value), TS_ENCODING);
|
869 | 870 | }
|
| 871 | + |
| 872 | + @Specialization |
| 873 | + TruffleString doNative(VirtualFrame frame, PythonAbstractNativeObject value, |
| 874 | + @Shared @Cached FromJavaStringNode fromJavaStringNode, |
| 875 | + @Cached FromNativeSubclassNode fromNativeSubclassNode) { |
| 876 | + Double dvalue = fromNativeSubclassNode.execute(frame, value); |
| 877 | + if (dvalue != null) { |
| 878 | + return fromJavaStringNode.execute(makeHexNumber(dvalue), TS_ENCODING); |
| 879 | + } |
| 880 | + throw raise(PythonBuiltinClassType.TypeError, ErrorMessages.DESCR_S_FOR_P_OBJ_DOESNT_APPLY_TO_P, "hex", 1.0, value); |
| 881 | + } |
870 | 882 | }
|
871 | 883 |
|
872 | 884 | @Builtin(name = J___RMOD__, minNumOfPositionalArgs = 2, reverseOperation = true)
|
|
0 commit comments