| |
|
| \ Idea and implementation: Bernd Paysan (py) |
\ Idea and implementation: Bernd Paysan (py) |
| |
|
| HEX |
\ Needs: |
| |
|
| |
require ./vars.fs |
| |
|
| |
hex |
| |
|
| \ labels for some code addresses |
\ labels for some code addresses |
| |
|
| true EXIT |
true EXIT |
| THEN |
THEN |
| toupper [char] 0 - dup 9 u> IF |
toupper [char] 0 - dup 9 u> IF |
| [ 'A '9 1 + - ] literal - |
[ char A char 9 1 + - ] literal - |
| dup 9 u<= IF |
dup 9 u<= IF |
| drop false EXIT |
drop false EXIT |
| THEN |
THEN |
| ' noop IS 'catch |
' noop IS 'catch |
| ' noop IS 'throw |
' noop IS 'throw |
| |
|
| |
has? backtrace [IF] |
| Defer store-backtrace |
Defer store-backtrace |
| ' noop IS store-backtrace |
' noop IS store-backtrace |
| |
[THEN] |
| |
|
| : catch ( x1 .. xn xt -- y1 .. ym 0 / z1 .. zn error ) \ exception |
: catch ( x1 .. xn xt -- y1 .. ym 0 / z1 .. zn error ) \ exception |
| 'catch |
'catch |
| [ [THEN] ] |
[ [THEN] ] |
| handler @ >r |
handler @ >r |
| rp@ handler ! |
rp@ handler ! |
| |
[ has? backtrace [IF] ] |
| backtrace-empty on |
backtrace-empty on |
| |
[ [THEN] ] |
| execute |
execute |
| r> handler ! rdrop |
r> handler ! rdrop |
| [ has? floating [IF] ] |
[ has? floating [IF] ] |
| : throw ( y1 .. ym error/0 -- y1 .. ym / z1 .. zn error ) \ exception |
: throw ( y1 .. ym error/0 -- y1 .. ym / z1 .. zn error ) \ exception |
| ?DUP IF |
?DUP IF |
| [ has? header [IF] here 9 cells ! [THEN] ] \ entry point for signal handler |
[ has? header [IF] here 9 cells ! [THEN] ] \ entry point for signal handler |
| |
[ has? backtrace [IF] ] |
| store-backtrace |
store-backtrace |
| |
[ [THEN] ] |
| [ has? interpreter [IF] ] |
[ has? interpreter [IF] ] |
| handler @ dup 0= IF |
handler @ dup 0= IF |
| [ has? os [IF] ] |
[ has? os [IF] ] |
| : bounce ( y1 .. ym error/0 -- y1 .. ym error / y1 .. ym ) \ gforth |
: bounce ( y1 .. ym error/0 -- y1 .. ym error / y1 .. ym ) \ gforth |
| \ a throw without data or fp stack restauration |
\ a throw without data or fp stack restauration |
| ?DUP IF |
?DUP IF |
| |
[ has? backtrace [IF] ] |
| store-backtrace |
store-backtrace |
| |
[ [THEN] ] |
| handler @ rp! |
handler @ rp! |
| r> handler ! |
r> handler ! |
| [ has? glocals [IF] ] |
[ has? glocals [IF] ] |