|
1 | 1 | /*
|
2 |
| - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. |
| 2 | + * Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved. |
3 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
4 | 4 | *
|
5 | 5 | * The Universal Permissive License (UPL), Version 1.0
|
|
40 | 40 | */
|
41 | 41 | package com.oracle.graal.python.runtime.exception;
|
42 | 42 |
|
43 |
| -import com.oracle.truffle.api.TruffleException; |
| 43 | +import com.oracle.truffle.api.exception.AbstractTruffleException; |
| 44 | +import com.oracle.truffle.api.interop.ExceptionType; |
| 45 | +import com.oracle.truffle.api.interop.InteropLibrary; |
| 46 | +import com.oracle.truffle.api.library.ExportLibrary; |
| 47 | +import com.oracle.truffle.api.library.ExportMessage; |
44 | 48 | import com.oracle.truffle.api.nodes.Node;
|
45 | 49 |
|
46 | 50 | /**
|
|
49 | 53 | * and leaving the interpreter after the normal <code>SystemExit</code> has been handled.
|
50 | 54 | */
|
51 | 55 | @SuppressWarnings("serial")
|
52 |
| -public final class PythonExitException extends RuntimeException implements TruffleException { |
53 |
| - |
54 |
| - private final Node location; |
| 56 | +@ExportLibrary(InteropLibrary.class) |
| 57 | +public final class PythonExitException extends AbstractTruffleException { |
55 | 58 | private final int status;
|
56 | 59 |
|
57 | 60 | public PythonExitException(Node location, int status) {
|
58 |
| - this.location = location; |
| 61 | + super(location); |
59 | 62 | this.status = status;
|
60 | 63 | }
|
61 | 64 |
|
62 |
| - public Node getLocation() { |
63 |
| - return location; |
| 65 | + @ExportMessage |
| 66 | + @SuppressWarnings("static-method") |
| 67 | + boolean isException() { |
| 68 | + return true; |
64 | 69 | }
|
65 | 70 |
|
66 |
| - public boolean isExit() { |
67 |
| - return true; |
| 71 | + @ExportMessage |
| 72 | + RuntimeException throwException() { |
| 73 | + throw this; |
| 74 | + } |
| 75 | + |
| 76 | + @ExportMessage |
| 77 | + @SuppressWarnings("static-method") |
| 78 | + ExceptionType getExceptionType() { |
| 79 | + return ExceptionType.EXIT; |
68 | 80 | }
|
69 | 81 |
|
70 |
| - public int getExitStatus() { |
| 82 | + @ExportMessage |
| 83 | + public int getExceptionExitStatus() { |
71 | 84 | return status;
|
72 | 85 | }
|
73 | 86 | }
|
0 commit comments