Mercurial > emacs
comparison src/eval.c @ 71976:66a9a086ddbb
* 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.
author | Kim F. Storm <storm@cua.dk> |
---|---|
date | Tue, 18 Jul 2006 13:26:38 +0000 |
parents | b20203b004f8 |
children | da0099bc0ba4 |
comparison
equal
deleted
inserted
replaced
71975:6d29dff081c5 | 71976:66a9a086ddbb |
---|---|
981 QUIT; | 981 QUIT; |
982 elt = Fcar (varlist); | 982 elt = Fcar (varlist); |
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))); |
992 specbind (Fcar (elt), val); | 990 specbind (Fcar (elt), val); |
993 } | 991 } |
1030 QUIT; | 1028 QUIT; |
1031 elt = Fcar (varlist); | 1029 elt = Fcar (varlist); |
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; |
1041 } | 1037 } |
1042 UNGCPRO; | 1038 UNGCPRO; |
1293 for (c = catchlist; c; c = c->next) | 1289 for (c = catchlist; c; c = c->next) |
1294 { | 1290 { |
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 |
1303 DEFUN ("unwind-protect", Funwind_protect, Sunwind_protect, 1, UNEVALLED, 0, | 1298 DEFUN ("unwind-protect", Funwind_protect, Sunwind_protect, 1, UNEVALLED, 0, |
1304 doc: /* Do BODYFORM, protecting with UNWINDFORMS. | 1299 doc: /* Do BODYFORM, protecting with UNWINDFORMS. |
1702 | 1697 |
1703 string = Ferror_message_string (data); | 1698 string = Ferror_message_string (data); |
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 |
1710 static int | 1777 static int |
1711 wants_debugger (list, conditions) | 1778 wants_debugger (list, conditions) |
1916 | 1983 |
1917 string = build_string (buffer); | 1984 string = build_string (buffer); |
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, |
1926 doc: /* Non-nil if FUNCTION makes provisions for interactive calling. | 1992 doc: /* Non-nil if FUNCTION makes provisions for interactive calling. |
1927 This means it contains a description for how to read arguments to give it. | 1993 This means it contains a description for how to read arguments to give it. |
2183 | 2249 |
2184 CHECK_CONS_LIST (); | 2250 CHECK_CONS_LIST (); |
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 { |
2192 backtrace.evalargs = 0; | 2258 backtrace.evalargs = 0; |
2193 val = (*XSUBR (fun)->function) (args_left); | 2259 val = (*XSUBR (fun)->function) (args_left); |
2287 if (COMPILEDP (fun)) | 2353 if (COMPILEDP (fun)) |
2288 val = apply_lambda (fun, original_args, 1); | 2354 val = apply_lambda (fun, original_args, 1); |
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); |
2301 goto retry; | 2367 goto retry; |
2302 } | 2368 } |
2303 if (EQ (funcar, Qmacro)) | 2369 if (EQ (funcar, Qmacro)) |
2304 val = Feval (apply1 (Fcdr (fun), original_args)); | 2370 val = Feval (apply1 (Fcdr (fun), original_args)); |
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 (); |
2312 | 2378 |
2313 lisp_eval_depth--; | 2379 lisp_eval_depth--; |
2883 { | 2949 { |
2884 if (numargs < XSUBR (fun)->min_args | 2950 if (numargs < XSUBR (fun)->min_args |
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 { |
2896 val = (*XSUBR (fun)->function) (numargs, args + 1); | 2962 val = (*XSUBR (fun)->function) (numargs, args + 1); |
2897 goto done; | 2963 goto done; |
2960 if (COMPILEDP (fun)) | 3026 if (COMPILEDP (fun)) |
2961 val = funcall_lambda (fun, numargs, args + 1); | 3027 val = funcall_lambda (fun, numargs, args + 1); |
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)) |
2974 { | 3040 { |
2975 do_autoload (fun, original_fun); | 3041 do_autoload (fun, original_fun); |
2976 CHECK_CONS_LIST (); | 3042 CHECK_CONS_LIST (); |
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 (); |
2984 lisp_eval_depth--; | 3050 lisp_eval_depth--; |
2985 if (backtrace.debug_on_exit) | 3051 if (backtrace.debug_on_exit) |
3051 { | 3117 { |
3052 syms_left = XCDR (fun); | 3118 syms_left = XCDR (fun); |
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); |
3060 else | 3126 else |
3061 abort (); | 3127 abort (); |
3065 { | 3131 { |
3066 QUIT; | 3132 QUIT; |
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; |
3074 else if (EQ (next, Qand_optional)) | 3140 else if (EQ (next, Qand_optional)) |
3075 optional = 1; | 3141 optional = 1; |
3079 i = nargs; | 3145 i = nargs; |
3080 } | 3146 } |
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))); |
3096 else | 3162 else |
3097 { | 3163 { |
3139 if (specpdl_size >= max_specpdl_size) | 3205 if (specpdl_size >= max_specpdl_size) |
3140 { | 3206 { |
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) |
3149 specpdl_size = max_specpdl_size; | 3214 specpdl_size = max_specpdl_size; |
3150 specpdl = (struct specbinding *) xrealloc (specpdl, specpdl_size * sizeof (struct specbinding)); | 3215 specpdl = (struct specbinding *) xrealloc (specpdl, specpdl_size * sizeof (struct specbinding)); |