|
5 | 5 | */
|
6 | 6 | package com.oracle.graal.python.builtins.modules;
|
7 | 7 |
|
| 8 | +import static com.oracle.graal.python.runtime.exception.PythonErrorType.OverflowError; |
| 9 | +import static com.oracle.graal.python.runtime.exception.PythonErrorType.ValueError; |
| 10 | + |
| 11 | +import java.util.List; |
| 12 | + |
8 | 13 | import com.oracle.graal.python.builtins.Builtin;
|
9 | 14 | import com.oracle.graal.python.builtins.CoreFunctions;
|
10 | 15 | import com.oracle.graal.python.builtins.PythonBuiltins;
|
11 | 16 | import com.oracle.graal.python.builtins.objects.PNone;
|
12 | 17 | import com.oracle.graal.python.builtins.objects.complex.ComplexBuiltins;
|
13 | 18 | import com.oracle.graal.python.builtins.objects.complex.PComplex;
|
14 |
| -import com.oracle.graal.python.builtins.objects.object.PythonObjectLibrary; |
15 | 19 | import com.oracle.graal.python.builtins.objects.tuple.PTuple;
|
| 20 | +import com.oracle.graal.python.lib.PyFloatAsDoubleNode; |
16 | 21 | import com.oracle.graal.python.nodes.ErrorMessages;
|
17 | 22 | import com.oracle.graal.python.nodes.PGuards;
|
18 | 23 | import com.oracle.graal.python.nodes.function.PythonBuiltinBaseNode;
|
|
32 | 37 | import com.oracle.truffle.api.dsl.Specialization;
|
33 | 38 | import com.oracle.truffle.api.dsl.TypeSystemReference;
|
34 | 39 | import com.oracle.truffle.api.frame.VirtualFrame;
|
35 |
| -import com.oracle.truffle.api.library.CachedLibrary; |
36 |
| - |
37 |
| -import java.util.List; |
38 |
| - |
39 |
| -import static com.oracle.graal.python.runtime.exception.PythonErrorType.OverflowError; |
40 |
| -import static com.oracle.graal.python.runtime.exception.PythonErrorType.ValueError; |
41 | 40 |
|
42 | 41 | @CoreFunctions(defineModule = "cmath")
|
43 | 42 | public class CmathModuleBuiltins extends PythonBuiltins {
|
@@ -338,11 +337,11 @@ PComplex doDD(double r, double phi) {
|
338 | 337 | return rect(r, phi);
|
339 | 338 | }
|
340 | 339 |
|
341 |
| - @Specialization(limit = "2") |
342 |
| - PComplex doGeneral(Object r, Object phi, |
343 |
| - @CachedLibrary("r") PythonObjectLibrary rLib, |
344 |
| - @CachedLibrary("phi") PythonObjectLibrary phiLib) { |
345 |
| - return rect(rLib.asJavaDouble(r), phiLib.asJavaDouble(phi)); |
| 340 | + @Specialization |
| 341 | + PComplex doGeneral(VirtualFrame frame, Object r, Object phi, |
| 342 | + @Cached PyFloatAsDoubleNode rAsDoubleNode, |
| 343 | + @Cached PyFloatAsDoubleNode phiAsDoubleNode) { |
| 344 | + return rect(rAsDoubleNode.execute(frame, r), phiAsDoubleNode.execute(frame, phi)); |
346 | 345 | }
|
347 | 346 |
|
348 | 347 | @TruffleBoundary
|
@@ -1015,16 +1014,16 @@ boolean doCCNN(PComplex a, PComplex b, PNone relTolObj, PNone absTolObj) {
|
1015 | 1014 | return isClose(a, b, DEFAULT_REL_TOL, DEFAULT_ABS_TOL);
|
1016 | 1015 | }
|
1017 | 1016 |
|
1018 |
| - @Specialization(limit = "2") |
| 1017 | + @Specialization |
1019 | 1018 | boolean doGeneral(VirtualFrame frame, Object aObj, Object bObj, Object relTolObj, Object absTolObj,
|
1020 | 1019 | @Cached CoerceToComplexNode coerceAToComplex,
|
1021 | 1020 | @Cached CoerceToComplexNode coerceBToComplex,
|
1022 |
| - @CachedLibrary("relTolObj") PythonObjectLibrary relTolLib, |
1023 |
| - @CachedLibrary("absTolObj") PythonObjectLibrary absTolLib) { |
| 1021 | + @Cached PyFloatAsDoubleNode relAsDoubleNode, |
| 1022 | + @Cached PyFloatAsDoubleNode absAsDoubleNode) { |
1024 | 1023 | PComplex a = coerceAToComplex.execute(frame, aObj);
|
1025 | 1024 | PComplex b = coerceBToComplex.execute(frame, bObj);
|
1026 |
| - double relTol = PGuards.isNoValue(relTolObj) ? DEFAULT_REL_TOL : relTolLib.asJavaDouble(relTolObj); |
1027 |
| - double absTol = PGuards.isPNone(absTolObj) ? DEFAULT_ABS_TOL : absTolLib.asJavaDouble(absTolObj); |
| 1025 | + double relTol = PGuards.isNoValue(relTolObj) ? DEFAULT_REL_TOL : relAsDoubleNode.execute(frame, relTolObj); |
| 1026 | + double absTol = PGuards.isPNone(absTolObj) ? DEFAULT_ABS_TOL : absAsDoubleNode.execute(frame, absTolObj); |
1028 | 1027 | return isClose(a, b, relTol, absTol);
|
1029 | 1028 | }
|
1030 | 1029 |
|
|
0 commit comments