1 /* yForth? - A Forth interpreter written in ANSI C
2 * Copyright (C) 2012 Luca Padovani
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 * ------------------------------------------------------------------------
17 * Module name: exceptio.c
18 * Abstract: exception word set
27 /**************************************************************************/
28 /* VARIABLES **************************************************************/
29 /**************************************************************************/
31 struct exception_frame *top_frame; /* ptr to the top of exception stack */
33 /**************************************************************************/
34 /* WORDS ******************************************************************/
35 /**************************************************************************/
38 register struct exception_frame *frame =
39 (struct exception_frame *) malloc(sizeof(struct exception_frame));
42 if ((ret_val = setjmp(frame->catch_buf)) == 0) {
43 /* Executed when "catch" is invoked */
44 save_input_specification();
49 frame->last = top_frame;
51 exec_word((struct word_def *) *sp++);
53 } else *--sp = ret_val;
58 top_frame = frame->last;
60 restore_input_specification();
65 register Cell n = *sp++;
67 if (top_frame) longjmp(top_frame->catch_buf, n);
69 else if (n == -2) _type();
71 longjmp(warm_start_jump, 1);