version 1.10, 2006/05/26 21:18:45
|
version 1.14, 2006/12/28 20:53:03
|
Line 76 Defer store-backtrace
|
Line 76 Defer store-backtrace
|
|
|
\ !! explain handler on-stack structure |
\ !! explain handler on-stack structure |
|
|
|
Variable first-throw |
|
: nothrow ( -- ) \ gforth |
|
\G Use this (or the standard sequence @code{['] false catch drop}) |
|
\G after a @code{catch} or @code{endtry} that does not rethrow; |
|
\G this ensures that the next @code{throw} will record a |
|
\G backtrace. |
|
first-throw on ; |
|
|
: (try) ( ahandler -- ) |
: (try) ( ahandler -- ) |
|
first-throw on |
r> |
r> |
swap >r \ recovery address |
swap >r \ recovery address |
rp@ 'catch >r |
rp@ 'catch >r |
Line 125 is catch
|
Line 134 is catch
|
:noname ( y1 .. ym error/0 -- y1 .. ym / z1 .. zn error ) \ exception |
:noname ( y1 .. ym error/0 -- y1 .. ym / z1 .. zn error ) \ exception |
?DUP IF |
?DUP IF |
[ here forthstart 9 cells + ! ] |
[ here forthstart 9 cells + ! ] |
store-backtrace error-stack off |
first-throw @ IF |
|
store-backtrace error-stack off |
|
first-throw off |
|
THEN |
handler @ ?dup-0=-IF |
handler @ ?dup-0=-IF |
>stderr cr ." uncaught exception: " .error cr |
>stderr cr ." uncaught exception: " .error cr |
2 (bye) |
2 (bye) |
Line 139 is catch
|
Line 151 is catch
|
rdrop 'throw r> perform |
rdrop 'throw r> perform |
THEN ; |
THEN ; |
is throw |
is throw |
[IFDEF] throw>error |
[IFDEF] rethrow |
:noname ( y1 .. ym error/0 -- y1 .. ym / z1 .. zn error ) \ exception |
:noname ( y1 .. ym error/0 -- y1 .. ym / z1 .. zn error ) \ exception |
?DUP IF |
?DUP IF |
handler @ ?dup-0=-IF |
handler @ ?dup-0=-IF |
Line 154 is throw
|
Line 166 is throw
|
r> swap >r sp! drop r> |
r> swap >r sp! drop r> |
rdrop 'throw r> perform |
rdrop 'throw r> perform |
THEN ; |
THEN ; |
is throw>error |
|
[THEN] |
|
|
|
|
is rethrow |
|
[THEN] |