diff options
| author | Kim F. Storm | 2006-07-18 13:26:38 +0000 |
|---|---|---|
| committer | Kim F. Storm | 2006-07-18 13:26:38 +0000 |
| commit | 734d55a2bd7fa9e9d122cf8aa1090adb52197763 (patch) | |
| tree | c6d8f669a5c85d598dd153e9d4ae4bded2255aba /src/eval.c | |
| parent | 8a0ff74421535f810ca457712c80a867146d7d19 (diff) | |
| download | emacs-734d55a2bd7fa9e9d122cf8aa1090adb52197763.tar.gz emacs-734d55a2bd7fa9e9d122cf8aa1090adb52197763.zip | |
* eval.c (xsignal): New func. Like Fsignal, but marked no-return.
(xsignal0, xsignal1, xsignal2, xsignal3): New no-return functions.
(signal_error): New no-return function (from xfaces.c).
(Fthrow): Use xsignal2 instead of Fsignal + abort.
(error): Use xsignal1 instead of Fsignal + abort.
(FletX, Flet, grow_specpdl): Use signal_error.
(Feval, Ffuncall, funcall_lambda): Use xsignal1, xsignal2.
* xfaces.c (signal_error): Move to eval.c.
(resolve_face_name): Use xsignal1.
Diffstat (limited to 'src/eval.c')
| -rw-r--r-- | src/eval.c | 125 |
1 files changed, 95 insertions, 30 deletions
diff --git a/src/eval.c b/src/eval.c index a07ab32e76b..37c245234fc 100644 --- a/src/eval.c +++ b/src/eval.c | |||
| @@ -983,9 +983,7 @@ usage: (let* VARLIST BODY...) */) | |||
| 983 | if (SYMBOLP (elt)) | 983 | if (SYMBOLP (elt)) |
| 984 | specbind (elt, Qnil); | 984 | specbind (elt, Qnil); |
| 985 | else if (! NILP (Fcdr (Fcdr (elt)))) | 985 | else if (! NILP (Fcdr (Fcdr (elt)))) |
| 986 | Fsignal (Qerror, | 986 | signal_error ("`let' bindings can have only one value-form", elt); |
| 987 | Fcons (build_string ("`let' bindings can have only one value-form"), | ||
| 988 | elt)); | ||
| 989 | else | 987 | else |
| 990 | { | 988 | { |
| 991 | val = Feval (Fcar (Fcdr (elt))); | 989 | val = Feval (Fcar (Fcdr (elt))); |
| @@ -1032,9 +1030,7 @@ usage: (let VARLIST BODY...) */) | |||
| 1032 | if (SYMBOLP (elt)) | 1030 | if (SYMBOLP (elt)) |
| 1033 | temps [argnum++] = Qnil; | 1031 | temps [argnum++] = Qnil; |
| 1034 | else if (! NILP (Fcdr (Fcdr (elt)))) | 1032 | else if (! NILP (Fcdr (Fcdr (elt)))) |
| 1035 | Fsignal (Qerror, | 1033 | signal_error ("`let' bindings can have only one value-form", elt); |
| 1036 | Fcons (build_string ("`let' bindings can have only one value-form"), | ||
| 1037 | elt)); | ||
| 1038 | else | 1034 | else |
| 1039 | temps [argnum++] = Feval (Fcar (Fcdr (elt))); | 1035 | temps [argnum++] = Feval (Fcar (Fcdr (elt))); |
| 1040 | gcpro2.nvars = argnum; | 1036 | gcpro2.nvars = argnum; |
| @@ -1295,8 +1291,7 @@ Both TAG and VALUE are evalled. */) | |||
| 1295 | if (EQ (c->tag, tag)) | 1291 | if (EQ (c->tag, tag)) |
| 1296 | unwind_to_catch (c, value); | 1292 | unwind_to_catch (c, value); |
| 1297 | } | 1293 | } |
| 1298 | Fsignal (Qno_catch, list2 (tag, value)); | 1294 | xsignal2 (Qno_catch, tag, value); |
| 1299 | abort (); | ||
| 1300 | } | 1295 | } |
| 1301 | 1296 | ||
| 1302 | 1297 | ||
| @@ -1704,6 +1699,78 @@ See also the function `condition-case'. */) | |||
| 1704 | fatal ("%s", SDATA (string), 0); | 1699 | fatal ("%s", SDATA (string), 0); |
| 1705 | } | 1700 | } |
| 1706 | 1701 | ||
| 1702 | /* Internal version of Fsignal that never returns. | ||
| 1703 | Used for anything but Qquit (which can return from Fsignal). */ | ||
| 1704 | |||
| 1705 | void | ||
| 1706 | xsignal (error_symbol, data) | ||
| 1707 | Lisp_Object error_symbol, data; | ||
| 1708 | { | ||
| 1709 | Fsignal (error_symbol, data); | ||
| 1710 | abort (); | ||
| 1711 | } | ||
| 1712 | |||
| 1713 | /* Like xsignal, but takes 0, 1, 2, or 3 args instead of a list. */ | ||
| 1714 | |||
| 1715 | void | ||
| 1716 | xsignal0 (error_symbol) | ||
| 1717 | Lisp_Object error_symbol; | ||
| 1718 | { | ||
| 1719 | xsignal (error_symbol, Qnil); | ||
| 1720 | } | ||
| 1721 | |||
| 1722 | void | ||
| 1723 | xsignal1 (error_symbol, arg) | ||
| 1724 | Lisp_Object error_symbol, arg; | ||
| 1725 | { | ||
| 1726 | xsignal (error_symbol, list1 (arg)); | ||
| 1727 | } | ||
| 1728 | |||
| 1729 | void | ||
| 1730 | xsignal2 (error_symbol, arg1, arg2) | ||
| 1731 | Lisp_Object error_symbol, arg1, arg2; | ||
| 1732 | { | ||
| 1733 | xsignal (error_symbol, list2 (arg1, arg2)); | ||
| 1734 | } | ||
| 1735 | |||
| 1736 | void | ||
| 1737 | xsignal3 (error_symbol, arg1, arg2, arg3) | ||
| 1738 | Lisp_Object error_symbol, arg1, arg2, arg3; | ||
| 1739 | { | ||
| 1740 | xsignal (error_symbol, list3 (arg1, arg2, arg3)); | ||
| 1741 | } | ||
| 1742 | |||
| 1743 | /* Signal `error' with message S, and additional arg ARG. | ||
| 1744 | If ARG is not a genuine list, make it a one-element list. */ | ||
| 1745 | |||
| 1746 | void | ||
| 1747 | signal_error (s, arg) | ||
| 1748 | char *s; | ||
| 1749 | Lisp_Object arg; | ||
| 1750 | { | ||
| 1751 | Lisp_Object tortoise, hare; | ||
| 1752 | |||
| 1753 | hare = tortoise = arg; | ||
| 1754 | while (CONSP (hare)) | ||
| 1755 | { | ||
| 1756 | hare = XCDR (hare); | ||
| 1757 | if (!CONSP (hare)) | ||
| 1758 | break; | ||
| 1759 | |||
| 1760 | hare = XCDR (hare); | ||
| 1761 | tortoise = XCDR (tortoise); | ||
| 1762 | |||
| 1763 | if (EQ (hare, tortoise)) | ||
| 1764 | break; | ||
| 1765 | } | ||
| 1766 | |||
| 1767 | if (!NILP (hare)) | ||
| 1768 | arg = Fcons (arg, Qnil); /* Make it a list. */ | ||
| 1769 | |||
| 1770 | xsignal (Qerror, Fcons (build_string (s), arg)); | ||
| 1771 | } | ||
| 1772 | |||
| 1773 | |||
| 1707 | /* Return nonzero iff LIST is a non-nil atom or | 1774 | /* Return nonzero iff LIST is a non-nil atom or |
| 1708 | a list containing one of CONDITIONS. */ | 1775 | a list containing one of CONDITIONS. */ |
| 1709 | 1776 | ||
| @@ -1918,8 +1985,7 @@ error (m, a1, a2, a3) | |||
| 1918 | if (allocated) | 1985 | if (allocated) |
| 1919 | xfree (buffer); | 1986 | xfree (buffer); |
| 1920 | 1987 | ||
| 1921 | Fsignal (Qerror, Fcons (string, Qnil)); | 1988 | xsignal1 (Qerror, string); |
| 1922 | abort (); | ||
| 1923 | } | 1989 | } |
| 1924 | 1990 | ||
| 1925 | DEFUN ("commandp", Fcommandp, Scommandp, 1, 2, 0, | 1991 | DEFUN ("commandp", Fcommandp, Scommandp, 1, 2, 0, |
| @@ -2185,7 +2251,7 @@ DEFUN ("eval", Feval, Seval, 1, 1, 0, | |||
| 2185 | 2251 | ||
| 2186 | if (XINT (numargs) < XSUBR (fun)->min_args || | 2252 | if (XINT (numargs) < XSUBR (fun)->min_args || |
| 2187 | (XSUBR (fun)->max_args >= 0 && XSUBR (fun)->max_args < XINT (numargs))) | 2253 | (XSUBR (fun)->max_args >= 0 && XSUBR (fun)->max_args < XINT (numargs))) |
| 2188 | Fsignal (Qwrong_number_of_arguments, list2 (original_fun, numargs)); | 2254 | xsignal2 (Qwrong_number_of_arguments, original_fun, numargs); |
| 2189 | 2255 | ||
| 2190 | if (XSUBR (fun)->max_args == UNEVALLED) | 2256 | if (XSUBR (fun)->max_args == UNEVALLED) |
| 2191 | { | 2257 | { |
| @@ -2289,12 +2355,12 @@ DEFUN ("eval", Feval, Seval, 1, 1, 0, | |||
| 2289 | else | 2355 | else |
| 2290 | { | 2356 | { |
| 2291 | if (EQ (fun, Qunbound)) | 2357 | if (EQ (fun, Qunbound)) |
| 2292 | Fsignal (Qvoid_function, Fcons (original_fun, Qnil)); | 2358 | xsignal1 (Qvoid_function, original_fun); |
| 2293 | if (!CONSP (fun)) | 2359 | if (!CONSP (fun)) |
| 2294 | Fsignal (Qinvalid_function, Fcons (original_fun, Qnil)); | 2360 | xsignal1 (Qinvalid_function, original_fun); |
| 2295 | funcar = Fcar (fun); | 2361 | funcar = XCAR (fun); |
| 2296 | if (!SYMBOLP (funcar)) | 2362 | if (!SYMBOLP (funcar)) |
| 2297 | Fsignal (Qinvalid_function, Fcons (original_fun, Qnil)); | 2363 | xsignal1 (Qinvalid_function, original_fun); |
| 2298 | if (EQ (funcar, Qautoload)) | 2364 | if (EQ (funcar, Qautoload)) |
| 2299 | { | 2365 | { |
| 2300 | do_autoload (fun, original_fun); | 2366 | do_autoload (fun, original_fun); |
| @@ -2305,7 +2371,7 @@ DEFUN ("eval", Feval, Seval, 1, 1, 0, | |||
| 2305 | else if (EQ (funcar, Qlambda)) | 2371 | else if (EQ (funcar, Qlambda)) |
| 2306 | val = apply_lambda (fun, original_args, 1); | 2372 | val = apply_lambda (fun, original_args, 1); |
| 2307 | else | 2373 | else |
| 2308 | Fsignal (Qinvalid_function, Fcons (original_fun, Qnil)); | 2374 | xsignal1 (Qinvalid_function, original_fun); |
| 2309 | } | 2375 | } |
| 2310 | done: | 2376 | done: |
| 2311 | CHECK_CONS_LIST (); | 2377 | CHECK_CONS_LIST (); |
| @@ -2885,11 +2951,11 @@ usage: (funcall FUNCTION &rest ARGUMENTS) */) | |||
| 2885 | || (XSUBR (fun)->max_args >= 0 && XSUBR (fun)->max_args < numargs)) | 2951 | || (XSUBR (fun)->max_args >= 0 && XSUBR (fun)->max_args < numargs)) |
| 2886 | { | 2952 | { |
| 2887 | XSETFASTINT (lisp_numargs, numargs); | 2953 | XSETFASTINT (lisp_numargs, numargs); |
| 2888 | Fsignal (Qwrong_number_of_arguments, list2 (original_fun, lisp_numargs)); | 2954 | xsignal2 (Qwrong_number_of_arguments, original_fun, lisp_numargs); |
| 2889 | } | 2955 | } |
| 2890 | 2956 | ||
| 2891 | if (XSUBR (fun)->max_args == UNEVALLED) | 2957 | if (XSUBR (fun)->max_args == UNEVALLED) |
| 2892 | Fsignal (Qinvalid_function, Fcons (original_fun, Qnil)); | 2958 | xsignal1 (Qinvalid_function, original_fun); |
| 2893 | 2959 | ||
| 2894 | if (XSUBR (fun)->max_args == MANY) | 2960 | if (XSUBR (fun)->max_args == MANY) |
| 2895 | { | 2961 | { |
| @@ -2962,12 +3028,12 @@ usage: (funcall FUNCTION &rest ARGUMENTS) */) | |||
| 2962 | else | 3028 | else |
| 2963 | { | 3029 | { |
| 2964 | if (EQ (fun, Qunbound)) | 3030 | if (EQ (fun, Qunbound)) |
| 2965 | Fsignal (Qvoid_function, Fcons (original_fun, Qnil)); | 3031 | xsignal1 (Qvoid_function, original_fun); |
| 2966 | if (!CONSP (fun)) | 3032 | if (!CONSP (fun)) |
| 2967 | Fsignal (Qinvalid_function, Fcons (original_fun, Qnil)); | 3033 | xsignal1 (Qinvalid_function, original_fun); |
| 2968 | funcar = Fcar (fun); | 3034 | funcar = XCAR (fun); |
| 2969 | if (!SYMBOLP (funcar)) | 3035 | if (!SYMBOLP (funcar)) |
| 2970 | Fsignal (Qinvalid_function, Fcons (original_fun, Qnil)); | 3036 | xsignal1 (Qinvalid_function, original_fun); |
| 2971 | if (EQ (funcar, Qlambda)) | 3037 | if (EQ (funcar, Qlambda)) |
| 2972 | val = funcall_lambda (fun, numargs, args + 1); | 3038 | val = funcall_lambda (fun, numargs, args + 1); |
| 2973 | else if (EQ (funcar, Qautoload)) | 3039 | else if (EQ (funcar, Qautoload)) |
| @@ -2977,7 +3043,7 @@ usage: (funcall FUNCTION &rest ARGUMENTS) */) | |||
| 2977 | goto retry; | 3043 | goto retry; |
| 2978 | } | 3044 | } |
| 2979 | else | 3045 | else |
| 2980 | Fsignal (Qinvalid_function, Fcons (original_fun, Qnil)); | 3046 | xsignal1 (Qinvalid_function, original_fun); |
| 2981 | } | 3047 | } |
| 2982 | done: | 3048 | done: |
| 2983 | CHECK_CONS_LIST (); | 3049 | CHECK_CONS_LIST (); |
| @@ -3053,7 +3119,7 @@ funcall_lambda (fun, nargs, arg_vector) | |||
| 3053 | if (CONSP (syms_left)) | 3119 | if (CONSP (syms_left)) |
| 3054 | syms_left = XCAR (syms_left); | 3120 | syms_left = XCAR (syms_left); |
| 3055 | else | 3121 | else |
| 3056 | Fsignal (Qinvalid_function, Fcons (fun, Qnil)); | 3122 | xsignal1 (Qinvalid_function, fun); |
| 3057 | } | 3123 | } |
| 3058 | else if (COMPILEDP (fun)) | 3124 | else if (COMPILEDP (fun)) |
| 3059 | syms_left = AREF (fun, COMPILED_ARGLIST); | 3125 | syms_left = AREF (fun, COMPILED_ARGLIST); |
| @@ -3067,7 +3133,7 @@ funcall_lambda (fun, nargs, arg_vector) | |||
| 3067 | 3133 | ||
| 3068 | next = XCAR (syms_left); | 3134 | next = XCAR (syms_left); |
| 3069 | if (!SYMBOLP (next)) | 3135 | if (!SYMBOLP (next)) |
| 3070 | Fsignal (Qinvalid_function, Fcons (fun, Qnil)); | 3136 | xsignal1 (Qinvalid_function, fun); |
| 3071 | 3137 | ||
| 3072 | if (EQ (next, Qand_rest)) | 3138 | if (EQ (next, Qand_rest)) |
| 3073 | rest = 1; | 3139 | rest = 1; |
| @@ -3081,15 +3147,15 @@ funcall_lambda (fun, nargs, arg_vector) | |||
| 3081 | else if (i < nargs) | 3147 | else if (i < nargs) |
| 3082 | specbind (next, arg_vector[i++]); | 3148 | specbind (next, arg_vector[i++]); |
| 3083 | else if (!optional) | 3149 | else if (!optional) |
| 3084 | Fsignal (Qwrong_number_of_arguments, list2 (fun, make_number (nargs))); | 3150 | xsignal2 (Qwrong_number_of_arguments, fun, make_number (nargs)); |
| 3085 | else | 3151 | else |
| 3086 | specbind (next, Qnil); | 3152 | specbind (next, Qnil); |
| 3087 | } | 3153 | } |
| 3088 | 3154 | ||
| 3089 | if (!NILP (syms_left)) | 3155 | if (!NILP (syms_left)) |
| 3090 | Fsignal (Qinvalid_function, Fcons (fun, Qnil)); | 3156 | xsignal1 (Qinvalid_function, fun); |
| 3091 | else if (i < nargs) | 3157 | else if (i < nargs) |
| 3092 | Fsignal (Qwrong_number_of_arguments, list2 (fun, make_number (nargs))); | 3158 | xsignal2 (Qwrong_number_of_arguments, fun, make_number (nargs)); |
| 3093 | 3159 | ||
| 3094 | if (CONSP (fun)) | 3160 | if (CONSP (fun)) |
| 3095 | val = Fprogn (XCDR (XCDR (fun))); | 3161 | val = Fprogn (XCDR (XCDR (fun))); |
| @@ -3141,8 +3207,7 @@ grow_specpdl () | |||
| 3141 | if (max_specpdl_size < 400) | 3207 | if (max_specpdl_size < 400) |
| 3142 | max_specpdl_size = 400; | 3208 | max_specpdl_size = 400; |
| 3143 | if (specpdl_size >= max_specpdl_size) | 3209 | if (specpdl_size >= max_specpdl_size) |
| 3144 | Fsignal (Qerror, | 3210 | signal_error ("Variable binding depth exceeds max-specpdl-size", Qnil); |
| 3145 | Fcons (build_string ("Variable binding depth exceeds max-specpdl-size"), Qnil)); | ||
| 3146 | } | 3211 | } |
| 3147 | specpdl_size *= 2; | 3212 | specpdl_size *= 2; |
| 3148 | if (specpdl_size > max_specpdl_size) | 3213 | if (specpdl_size > max_specpdl_size) |