diff options
| author | Philipp Stephani | 2015-11-16 00:31:56 +0100 |
|---|---|---|
| committer | Ted Zlatanov | 2015-11-18 14:23:41 -0500 |
| commit | 7cdc5d628a737e2153c38d0d285c9879071beaa7 (patch) | |
| tree | 58d21223b8d1b7de7230449dfb24d85efcab86f5 /src/eval.c | |
| parent | 133ad3e2006d136a6153a75140a880f8ff16ea65 (diff) | |
| download | emacs-7cdc5d628a737e2153c38d0d285c9879071beaa7.tar.gz emacs-7cdc5d628a737e2153c38d0d285c9879071beaa7.zip | |
Add catch-all & no-signal version of PUSH_HANDLER
Ground work for modules. Add a non-signaling version of PUSH_HANDLER and
a new "catch-all" handler type.
* src/eval.c (init_handler, push_handler, push_handler_nosignal): New
functions.
* src/fns.c (hash_remove_from_table): Expose function public.
* src/lisp.h: New handler type, define macro to push_handler call.
Diffstat (limited to 'src/eval.c')
| -rw-r--r-- | src/eval.c | 53 |
1 files changed, 52 insertions, 1 deletions
diff --git a/src/eval.c b/src/eval.c index 3ee07a71c69..396ca84a71d 100644 --- a/src/eval.c +++ b/src/eval.c | |||
| @@ -1145,7 +1145,9 @@ Both TAG and VALUE are evalled. */ | |||
| 1145 | if (!NILP (tag)) | 1145 | if (!NILP (tag)) |
| 1146 | for (c = handlerlist; c; c = c->next) | 1146 | for (c = handlerlist; c; c = c->next) |
| 1147 | { | 1147 | { |
| 1148 | if (c->type == CATCHER && EQ (c->tag_or_ch, tag)) | 1148 | if (c->type == CATCHER_ALL) |
| 1149 | unwind_to_catch (c, Fcons (tag, value)); | ||
| 1150 | if (c->type == CATCHER && EQ (c->tag_or_ch, tag)) | ||
| 1149 | unwind_to_catch (c, value); | 1151 | unwind_to_catch (c, value); |
| 1150 | } | 1152 | } |
| 1151 | xsignal2 (Qno_catch, tag, value); | 1153 | xsignal2 (Qno_catch, tag, value); |
| @@ -1394,6 +1396,55 @@ internal_condition_case_n (Lisp_Object (*bfun) (ptrdiff_t, Lisp_Object *), | |||
| 1394 | return val; | 1396 | return val; |
| 1395 | } | 1397 | } |
| 1396 | 1398 | ||
| 1399 | static void init_handler (struct handler *c, Lisp_Object tag_ch_val, | ||
| 1400 | enum handlertype handlertype); | ||
| 1401 | |||
| 1402 | void push_handler (struct handler **const c, const Lisp_Object tag_ch_val, | ||
| 1403 | const enum handlertype handlertype) | ||
| 1404 | { | ||
| 1405 | if (handlerlist->nextfree) | ||
| 1406 | *c = handlerlist->nextfree; | ||
| 1407 | else | ||
| 1408 | { | ||
| 1409 | *c = xmalloc (sizeof (struct handler)); | ||
| 1410 | (*c)->nextfree = NULL; | ||
| 1411 | handlerlist->nextfree = *c; | ||
| 1412 | } | ||
| 1413 | init_handler (*c, tag_ch_val, handlertype); | ||
| 1414 | } | ||
| 1415 | |||
| 1416 | bool push_handler_nosignal (struct handler **const c, const Lisp_Object tag_ch_val, | ||
| 1417 | const enum handlertype handlertype) | ||
| 1418 | { | ||
| 1419 | if (handlerlist->nextfree) | ||
| 1420 | *c = handlerlist->nextfree; | ||
| 1421 | else | ||
| 1422 | { | ||
| 1423 | struct handler *const h = malloc (sizeof (struct handler)); | ||
| 1424 | if (! h) return false; | ||
| 1425 | *c = h; | ||
| 1426 | h->nextfree = NULL; | ||
| 1427 | handlerlist->nextfree = h; | ||
| 1428 | } | ||
| 1429 | init_handler (*c, tag_ch_val, handlertype); | ||
| 1430 | return true; | ||
| 1431 | } | ||
| 1432 | |||
| 1433 | static void init_handler (struct handler *const c, const Lisp_Object tag_ch_val, | ||
| 1434 | const enum handlertype handlertype) | ||
| 1435 | { | ||
| 1436 | c->type = handlertype; | ||
| 1437 | c->tag_or_ch = tag_ch_val; | ||
| 1438 | c->val = Qnil; | ||
| 1439 | c->next = handlerlist; | ||
| 1440 | c->lisp_eval_depth = lisp_eval_depth; | ||
| 1441 | c->pdlcount = SPECPDL_INDEX (); | ||
| 1442 | c->poll_suppress_count = poll_suppress_count; | ||
| 1443 | c->interrupt_input_blocked = interrupt_input_blocked; | ||
| 1444 | c->byte_stack = byte_stack_list; | ||
| 1445 | handlerlist = c; | ||
| 1446 | } | ||
| 1447 | |||
| 1397 | 1448 | ||
| 1398 | static Lisp_Object find_handler_clause (Lisp_Object, Lisp_Object); | 1449 | static Lisp_Object find_handler_clause (Lisp_Object, Lisp_Object); |
| 1399 | static bool maybe_call_debugger (Lisp_Object conditions, Lisp_Object sig, | 1450 | static bool maybe_call_debugger (Lisp_Object conditions, Lisp_Object sig, |