|
43 | 43 | import com.oracle.graal.python.builtins.PythonBuiltinClassType;
|
44 | 44 | import com.oracle.graal.python.builtins.modules.MathGuards;
|
45 | 45 | import com.oracle.graal.python.builtins.objects.cext.PythonAbstractNativeObject;
|
| 46 | +import com.oracle.graal.python.builtins.objects.cext.capi.CExtNodes.FromNativeSubclassNode; |
| 47 | +import com.oracle.graal.python.builtins.objects.cext.capi.CExtNodes.ImportCAPISymbolNode; |
| 48 | +import com.oracle.graal.python.builtins.objects.cext.capi.CExtNodes.ToSulongNode; |
46 | 49 | import com.oracle.graal.python.builtins.objects.ints.PInt;
|
47 | 50 | import com.oracle.graal.python.nodes.PNodeWithContext;
|
48 | 51 | import com.oracle.graal.python.nodes.PRaiseNode;
|
49 | 52 | import com.oracle.graal.python.nodes.classes.IsSubtypeNode;
|
50 | 53 | import com.oracle.graal.python.nodes.object.InlinedGetClassNode.GetPythonObjectClassNode;
|
51 | 54 | import com.oracle.graal.python.nodes.truffle.PythonArithmeticTypes;
|
52 |
| -import com.oracle.truffle.api.CompilerDirectives; |
53 | 55 | import com.oracle.truffle.api.dsl.Bind;
|
54 | 56 | import com.oracle.truffle.api.dsl.Cached;
|
55 | 57 | import com.oracle.truffle.api.dsl.GenerateUncached;
|
56 | 58 | import com.oracle.truffle.api.dsl.ImportStatic;
|
57 | 59 | import com.oracle.truffle.api.dsl.Specialization;
|
58 | 60 | import com.oracle.truffle.api.dsl.TypeSystemReference;
|
| 61 | +import com.oracle.truffle.api.interop.InteropLibrary; |
| 62 | +import com.oracle.truffle.api.library.CachedLibrary; |
59 | 63 | import com.oracle.truffle.api.nodes.Node;
|
60 | 64 |
|
61 | 65 | /**
|
@@ -89,10 +93,12 @@ static double toDouble(PInt x,
|
89 | 93 | static double doNativeObject(PythonAbstractNativeObject x,
|
90 | 94 | @Bind("this") Node node,
|
91 | 95 | @Cached GetPythonObjectClassNode getClassNode,
|
92 |
| - @Cached IsSubtypeNode isSubtypeNode) { |
| 96 | + @Cached IsSubtypeNode isSubtypeNode, |
| 97 | + @CachedLibrary(limit = "1") InteropLibrary interopLibrary, |
| 98 | + @Cached ToSulongNode toSulongNode, |
| 99 | + @Cached ImportCAPISymbolNode importSymNode) { |
93 | 100 | if (isSubtypeNode.execute(getClassNode.execute(node, x), PythonBuiltinClassType.PFloat)) {
|
94 |
| - CompilerDirectives.transferToInterpreter(); |
95 |
| - throw new RuntimeException("casting a native float object to a Java double is not implemented yet"); |
| 101 | + return FromNativeSubclassNode.readObFval(x, toSulongNode, interopLibrary, importSymNode); |
96 | 102 | }
|
97 | 103 | // the object's type is not a subclass of 'float'
|
98 | 104 | throw CannotCastException.INSTANCE;
|
|
0 commit comments