Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Truffle] Make a node for the top-level handler.
- Loading branch information
Showing
5 changed files
with
97 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
core/src/main/java/org/jruby/truffle/nodes/TopLevelRaiseHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* | ||
* Copyright (c) 2014 Oracle and/or its affiliates. All rights reserved. This | ||
* code is released under a tri EPL/GPL/LGPL license. You can use it, | ||
* redistribute it and/or modify it under the terms of the: | ||
* | ||
* Eclipse Public License version 1.0 | ||
* GNU General Public License version 2 | ||
* GNU Lesser General Public License version 2.1 | ||
*/ | ||
package org.jruby.truffle.nodes; | ||
|
||
import com.oracle.truffle.api.frame.VirtualFrame; | ||
import com.oracle.truffle.api.source.SourceSection; | ||
import org.jruby.truffle.runtime.RubyContext; | ||
import org.jruby.truffle.runtime.backtrace.Backtrace; | ||
import org.jruby.truffle.runtime.control.RaiseException; | ||
import org.jruby.truffle.runtime.control.ThreadExitException; | ||
import org.jruby.truffle.runtime.core.RubyException; | ||
|
||
public class TopLevelRaiseHandler extends RubyNode { | ||
|
||
@Child protected RubyNode body; | ||
|
||
public TopLevelRaiseHandler(RubyContext context, SourceSection sourceSection, RubyNode body) { | ||
super(context, sourceSection); | ||
this.body = body; | ||
} | ||
|
||
@Override | ||
public Object execute(VirtualFrame frame) { | ||
try { | ||
return body.execute(frame); | ||
} catch (RaiseException e) { | ||
// TODO(CS): what's this cast about? | ||
final RubyException rubyException = (RubyException) e.getRubyException(); | ||
|
||
for (String line : Backtrace.DISPLAY_FORMATTER.format(getContext(), rubyException, rubyException.getBacktrace())) { | ||
System.err.println(line); | ||
} | ||
} catch (ThreadExitException e) { | ||
// Ignore | ||
} | ||
|
||
return getContext().getCoreLibrary().getNilObject(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters