|
33 | 33 | import com.oracle.graal.python.builtins.objects.object.PythonObjectLibrary;
|
34 | 34 | import com.oracle.graal.python.builtins.objects.type.PythonBuiltinClass;
|
35 | 35 | import com.oracle.graal.python.nodes.BuiltinNames;
|
| 36 | +import com.oracle.graal.python.nodes.ErrorMessages; |
| 37 | +import com.oracle.graal.python.nodes.PRaiseNode; |
36 | 38 | import com.oracle.graal.python.nodes.classes.IsSubtypeNode;
|
37 | 39 | import com.oracle.graal.python.runtime.PythonContext;
|
38 | 40 | import com.oracle.truffle.api.CompilerAsserts;
|
@@ -525,52 +527,24 @@ static long hashWithState(PythonBuiltinClassType type, ThreadState state,
|
525 | 527 | }
|
526 | 528 |
|
527 | 529 | @ExportMessage
|
528 |
| - static Object asIndexWithState(PythonBuiltinClassType type, ThreadState state, |
529 |
| - @CachedContext(PythonLanguage.class) PythonContext context, |
530 |
| - @CachedLibrary(limit = "1") PythonObjectLibrary lib) { |
531 |
| - return lib.asIndexWithState(context.getCore().lookupType(type), state); |
532 |
| - } |
533 |
| - |
534 |
| - @ExportMessage |
535 |
| - static String asPathWithState(PythonBuiltinClassType type, ThreadState state, |
536 |
| - @CachedContext(PythonLanguage.class) PythonContext context, |
537 |
| - @CachedLibrary(limit = "1") PythonObjectLibrary lib) { |
538 |
| - return lib.asPathWithState(context.getCore().lookupType(type), state); |
539 |
| - } |
540 |
| - |
541 |
| - @ExportMessage |
542 |
| - static int asFileDescriptorWithState(PythonBuiltinClassType type, ThreadState state, |
543 |
| - @CachedContext(PythonLanguage.class) PythonContext context, |
544 |
| - @CachedLibrary(limit = "1") PythonObjectLibrary lib) { |
545 |
| - return lib.asFileDescriptorWithState(context.getCore().lookupType(type), state); |
546 |
| - } |
547 |
| - |
548 |
| - @ExportMessage |
| 530 | + @SuppressWarnings("unused") |
549 | 531 | static double asJavaDoubleWithState(PythonBuiltinClassType type, ThreadState state,
|
550 |
| - @CachedContext(PythonLanguage.class) PythonContext context, |
551 |
| - @CachedLibrary(limit = "1") PythonObjectLibrary lib) { |
552 |
| - return lib.asJavaDoubleWithState(context.getCore().lookupType(type), state); |
| 532 | + @Cached PRaiseNode raiseNode) { |
| 533 | + throw raiseNode.raise(TypeError, ErrorMessages.MUST_BE_REAL_NUMBER, type); |
553 | 534 | }
|
554 | 535 |
|
555 | 536 | @ExportMessage
|
| 537 | + @SuppressWarnings("unused") |
556 | 538 | static Object asPIntWithState(PythonBuiltinClassType type, ThreadState state,
|
557 |
| - @CachedContext(PythonLanguage.class) PythonContext context, |
558 |
| - @CachedLibrary(limit = "1") PythonObjectLibrary lib) { |
559 |
| - return lib.asPIntWithState(context.getCore().lookupType(type), state); |
| 539 | + @Cached PRaiseNode raiseNode) { |
| 540 | + throw raiseNode.raise(TypeError, ErrorMessages.OBJ_CANNOT_BE_INTERPRETED_AS_INTEGER, type); |
560 | 541 | }
|
561 | 542 |
|
562 | 543 | @ExportMessage
|
| 544 | + @SuppressWarnings("unused") |
563 | 545 | static long asJavaLongWithState(PythonBuiltinClassType type, ThreadState state,
|
564 |
| - @CachedContext(PythonLanguage.class) PythonContext context, |
565 |
| - @CachedLibrary(limit = "1") PythonObjectLibrary lib) { |
566 |
| - return lib.asJavaLongWithState(context.getCore().lookupType(type), state); |
567 |
| - } |
568 |
| - |
569 |
| - @ExportMessage |
570 |
| - static int asSizeWithState(PythonBuiltinClassType type, Object errorType, ThreadState state, |
571 |
| - @CachedContext(PythonLanguage.class) PythonContext context, |
572 |
| - @CachedLibrary(limit = "1") PythonObjectLibrary lib) { |
573 |
| - return lib.asSizeWithState(context.getCore().lookupType(type), errorType, state); |
| 546 | + @Cached PRaiseNode raiseNode) { |
| 547 | + throw raiseNode.raise(TypeError, ErrorMessages.MUST_BE_NUMERIC, type); |
574 | 548 | }
|
575 | 549 |
|
576 | 550 | @ExportMessage
|
|
0 commit comments