|
11 | 11 |
|
12 | 12 | import java.util.Set;
|
13 | 13 |
|
14 |
| -import com.oracle.truffle.api.CompilerDirectives; |
15 |
| -import com.oracle.truffle.api.dsl.Cached; |
16 | 14 | import com.oracle.truffle.api.dsl.CachedContext;
|
17 | 15 | import com.oracle.truffle.api.interop.ExceptionType;
|
18 | 16 | import com.oracle.truffle.api.interop.InteropLibrary;
|
19 |
| -import com.oracle.truffle.api.interop.UnsupportedMessageException; |
20 |
| -import com.oracle.truffle.api.library.CachedLibrary; |
21 | 17 | import com.oracle.truffle.api.library.ExportLibrary;
|
22 | 18 | import com.oracle.truffle.api.library.ExportMessage;
|
23 | 19 | import com.oracle.truffle.api.nodes.Node;
|
24 |
| -import com.oracle.truffle.api.object.DynamicObjectLibrary; |
25 |
| -import com.oracle.truffle.api.source.SourceSection; |
26 | 20 | import org.truffleruby.RubyContext;
|
27 | 21 | import org.truffleruby.RubyLanguage;
|
28 | 22 | import org.truffleruby.core.VMPrimitiveNodes.VMRaiseExceptionNode;
|
|
34 | 28 | import org.truffleruby.language.Nil;
|
35 | 29 | import org.truffleruby.language.RubyDynamicObject;
|
36 | 30 | import org.truffleruby.language.backtrace.Backtrace;
|
37 |
| -import org.truffleruby.language.objects.IsANode; |
38 | 31 | import org.truffleruby.language.objects.ObjectGraph;
|
39 | 32 | import org.truffleruby.language.objects.ObjectGraphNode;
|
40 | 33 |
|
@@ -100,78 +93,9 @@ public RuntimeException throwException(
|
100 | 93 | throw VMRaiseExceptionNode.reRaiseException(context, this);
|
101 | 94 | }
|
102 | 95 |
|
103 |
| - // TODO (eregon, 01 Nov 2020): these message implementations would be nicer with separate subclasses for SystemExit and SyntaxError. |
104 |
| - |
105 |
| - @ExportMessage |
106 |
| - public ExceptionType getExceptionType( |
107 |
| - @Cached IsANode isANode) { |
108 |
| - // @CachedContext does not work here when running "mx tck" |
109 |
| - final RubyContext context = getMetaClass().fields.getContext(); |
110 |
| - if (isANode.executeIsA(this, context.getCoreLibrary().systemExitClass)) { |
111 |
| - return ExceptionType.EXIT; |
112 |
| - } else if (isANode.executeIsA(this, context.getCoreLibrary().syntaxErrorClass)) { |
113 |
| - return ExceptionType.PARSE_ERROR; |
114 |
| - } else { |
115 |
| - return ExceptionType.RUNTIME_ERROR; |
116 |
| - } |
117 |
| - } |
118 |
| - |
119 |
| - @ExportMessage |
120 |
| - public int getExceptionExitStatus( |
121 |
| - @CachedLibrary("this") InteropLibrary interopLibrary, |
122 |
| - @CachedLibrary("this") DynamicObjectLibrary objectLibrary) throws UnsupportedMessageException { |
123 |
| - if (interopLibrary.getExceptionType(this) == ExceptionType.EXIT) { |
124 |
| - return (int) objectLibrary.getOrDefault(this, "@status", 1); |
125 |
| - } else { |
126 |
| - throw UnsupportedMessageException.create(); |
127 |
| - } |
128 |
| - } |
129 |
| - |
130 |
| - @ExportMessage |
131 |
| - public boolean isExceptionIncompleteSource( |
132 |
| - @CachedLibrary("this") InteropLibrary interopLibrary) throws UnsupportedMessageException { |
133 |
| - if (interopLibrary.getExceptionType(this) == ExceptionType.PARSE_ERROR) { |
134 |
| - return false; // Unknown |
135 |
| - } else { |
136 |
| - throw UnsupportedMessageException.create(); |
137 |
| - } |
138 |
| - } |
139 |
| - |
140 |
| - @TruffleBoundary |
141 |
| - @ExportMessage |
142 |
| - public boolean hasSourceLocation( |
143 |
| - @CachedLibrary("this") InteropLibrary interopLibrary) { |
144 |
| - try { |
145 |
| - if (interopLibrary.getExceptionType(this) == ExceptionType.PARSE_ERROR && |
146 |
| - backtrace != null && |
147 |
| - backtrace.getSourceLocation() != null) { |
148 |
| - return true; |
149 |
| - } else { |
150 |
| - final Node location = getLocation(); |
151 |
| - return location != null && location.getEncapsulatingSourceSection() != null; |
152 |
| - } |
153 |
| - } catch (UnsupportedMessageException e) { |
154 |
| - throw CompilerDirectives.shouldNotReachHere(e); |
155 |
| - } |
156 |
| - } |
157 |
| - |
158 |
| - @TruffleBoundary |
159 | 96 | @ExportMessage
|
160 |
| - public SourceSection getSourceLocation( |
161 |
| - @CachedLibrary("this") InteropLibrary interopLibrary) throws UnsupportedMessageException { |
162 |
| - if (interopLibrary.getExceptionType(this) == ExceptionType.PARSE_ERROR && |
163 |
| - backtrace != null && |
164 |
| - backtrace.getSourceLocation() != null) { |
165 |
| - return backtrace.getSourceLocation(); |
166 |
| - } else { |
167 |
| - final Node location = getLocation(); |
168 |
| - SourceSection sourceSection = location != null ? location.getEncapsulatingSourceSection() : null; |
169 |
| - if (sourceSection != null) { |
170 |
| - return sourceSection; |
171 |
| - } else { |
172 |
| - throw UnsupportedMessageException.create(); |
173 |
| - } |
174 |
| - } |
| 97 | + public ExceptionType getExceptionType() { |
| 98 | + return ExceptionType.RUNTIME_ERROR; |
175 | 99 | }
|
176 | 100 | // endregion
|
177 | 101 |
|
|
0 commit comments