1 | #include "custom_exception.h"
|
2 |
|
3 | union anyException lastException;
|
4 | struct exception* exception;
|
5 |
|
6 | jmp_buf* exception_jmp_buf;
|
7 |
|
8 | void beginTry( struct exceptionJmpStorage* s ){
|
9 | exception = 0;
|
10 | s->last = exception_jmp_buf;
|
11 | exception_jmp_buf = &s->current;
|
12 | }
|
13 |
|
14 | bool endTry( struct exceptionJmpStorage* s ){
|
15 | exception_jmp_buf = s->last;
|
16 | return false;
|
17 | }
|
18 |
|
19 | bool catchMatch( int type ){
|
20 | if( !exception || exception == (void*)1 )
|
21 | return false;
|
22 | return type == exception->type;
|
23 | }
|
24 |
|
25 | bool finallyBefore( void ){
|
26 | return exception != (void*)1;
|
27 | }
|
28 |
|
29 | void finallyAfter( void ){
|
30 | exception = 0;
|
31 | }
|