Skip to content

Commit 3ec2627

Browse files
committed
Port PythonExitException to the new API
1 parent dd4c919 commit 3ec2627

File tree

1 file changed

+24
-11
lines changed

1 file changed

+24
-11
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/exception/PythonExitException.java

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
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.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* The Universal Permissive License (UPL), Version 1.0
@@ -40,7 +40,11 @@
4040
*/
4141
package com.oracle.graal.python.runtime.exception;
4242

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;
4448
import com.oracle.truffle.api.nodes.Node;
4549

4650
/**
@@ -49,25 +53,34 @@
4953
* and leaving the interpreter after the normal <code>SystemExit</code> has been handled.
5054
*/
5155
@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 {
5558
private final int status;
5659

5760
public PythonExitException(Node location, int status) {
58-
this.location = location;
61+
super(location);
5962
this.status = status;
6063
}
6164

62-
public Node getLocation() {
63-
return location;
65+
@ExportMessage
66+
@SuppressWarnings("static-method")
67+
boolean isException() {
68+
return true;
6469
}
6570

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;
6880
}
6981

70-
public int getExitStatus() {
82+
@ExportMessage
83+
public int getExceptionExitStatus() {
7184
return status;
7285
}
7386
}

0 commit comments

Comments
 (0)