添加try catch 原理注释
This commit is contained in:
@@ -66,13 +66,16 @@ typedef struct{
|
||||
}\
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
try 的时候保存当前回溯点,如果setjmp返回不为0 则已经产生异常回溯了,
|
||||
这时最后一个回溯点的使命已经完成,所以删除最后一个回溯点
|
||||
*/
|
||||
#define __try(){\
|
||||
exception_def *f=exception();\
|
||||
jmp_fram **h=&f->jmp_head;\
|
||||
int ret;\
|
||||
jmp_next(h);\
|
||||
ret= setjmp(((*h)->fram));\
|
||||
ret = setjmp(((*h)->fram));\
|
||||
if(ret){\
|
||||
jmp_clear(h);\
|
||||
}\
|
||||
@@ -80,6 +83,11 @@ typedef struct{
|
||||
}
|
||||
|
||||
#define try_ __try();if(exception()->ret==0){
|
||||
|
||||
/*
|
||||
如果try一直执行到这里则不会产生回溯了,最后一个回溯点的使命也已经完成了,
|
||||
所以这里删除最后一个回溯点
|
||||
*/
|
||||
#define catch_ {\
|
||||
exception_def *f=exception();\
|
||||
jmp_fram **h=&f->jmp_head;\
|
||||
|
Reference in New Issue
Block a user