Created
May 29, 2010 15:44
-
-
Save jnthn/418336 to your computer and use it in GitHub Desktop.
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
Index: compilers/pct/src/PCT/HLLCompiler.pir | |
=================================================================== | |
--- compilers/pct/src/PCT/HLLCompiler.pir (revision 47073) | |
+++ compilers/pct/src/PCT/HLLCompiler.pir (working copy) | |
@@ -849,11 +849,15 @@ | |
$I0 = adverbs['version'] | |
if $I0 goto version | |
+ .local int can_backtrace | |
+ can_backtrace = can self, 'backtrace' | |
+ unless can_backtrace goto no_push_eh | |
+ push_eh uncaught_exception | |
+ no_push_eh: | |
$S0 = adverbs['e'] | |
$I0 = exists adverbs['e'] | |
if $I0 goto eval_line | |
- | |
.local pmc result | |
result = box '' | |
unless args goto interactive | |
@@ -872,6 +876,9 @@ | |
result = self.'eval'($S0, '-e', args :flat, adverbs :flat :named) | |
save_output: | |
+ unless can_backtrace goto no_pop_eh | |
+ pop_eh | |
+ no_pop_eh: | |
if null result goto end | |
$I0 = defined result | |
unless $I0 goto end | |
@@ -903,6 +910,16 @@ | |
version: | |
self.'version'() | |
goto end | |
+ | |
+ # If we get an uncaught exception in the program and the HLL provides | |
+ # a backtrace method, we end up here. We pass it the exception object | |
+ # so it can render a backtrace. | |
+ uncaught_exception: | |
+ .get_results ($P0) | |
+ pop_eh | |
+ $S0 = self.'backtrace'($P0) | |
+ print $S0 | |
+ exit 1 | |
.end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment