diff options
| author | Joakim Verona | 2011-07-15 04:39:29 +0200 |
|---|---|---|
| committer | Joakim Verona | 2011-07-15 04:39:29 +0200 |
| commit | 4f616a2e7ed1db28da98df90266e9751a8ae9ee1 (patch) | |
| tree | 74a9dcbe13e945e712ae04a4a94c2202ca720591 /src/eval.c | |
| parent | ff2be00005c3aeda6e11d7ed264ce86f02b60958 (diff) | |
| parent | ec2bc542a4d0127425625e8cb458684bd825675a (diff) | |
| download | emacs-4f616a2e7ed1db28da98df90266e9751a8ae9ee1.tar.gz emacs-4f616a2e7ed1db28da98df90266e9751a8ae9ee1.zip | |
merge from upstream
Diffstat (limited to 'src/eval.c')
| -rw-r--r-- | src/eval.c | 50 |
1 files changed, 11 insertions, 39 deletions
diff --git a/src/eval.c b/src/eval.c index 6ca8eacb100..90d0df61858 100644 --- a/src/eval.c +++ b/src/eval.c | |||
| @@ -32,25 +32,14 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | |||
| 32 | #include "xterm.h" | 32 | #include "xterm.h" |
| 33 | #endif | 33 | #endif |
| 34 | 34 | ||
| 35 | /* This definition is duplicated in alloc.c and keyboard.c. */ | ||
| 36 | /* Putting it in lisp.h makes cc bomb out! */ | ||
| 37 | |||
| 38 | struct backtrace | 35 | struct backtrace |
| 39 | { | 36 | { |
| 40 | struct backtrace *next; | 37 | struct backtrace *next; |
| 41 | Lisp_Object *function; | 38 | Lisp_Object *function; |
| 42 | Lisp_Object *args; /* Points to vector of args. */ | 39 | Lisp_Object *args; /* Points to vector of args. */ |
| 43 | #define NARGS_BITS (BITS_PER_INT - 2) | 40 | ptrdiff_t nargs; /* Length of vector. */ |
| 44 | /* Let's not use size_t because we want to allow negative values (for | ||
| 45 | UNEVALLED). Also let's steal 2 bits so we save a word (or more for | ||
| 46 | alignment). In any case I doubt Emacs would survive a function call with | ||
| 47 | more than 500M arguments. */ | ||
| 48 | int nargs : NARGS_BITS; /* Length of vector. | ||
| 49 | If nargs is UNEVALLED, args points | ||
| 50 | to slot holding list of unevalled args. */ | ||
| 51 | char evalargs : 1; | ||
| 52 | /* Nonzero means call value of debugger when done with this operation. */ | 41 | /* Nonzero means call value of debugger when done with this operation. */ |
| 53 | char debug_on_exit : 1; | 42 | unsigned int debug_on_exit : 1; |
| 54 | }; | 43 | }; |
| 55 | 44 | ||
| 56 | static struct backtrace *backtrace_list; | 45 | static struct backtrace *backtrace_list; |
| @@ -1651,8 +1640,7 @@ internal_condition_case_n (Lisp_Object (*bfun) (ptrdiff_t, Lisp_Object *), | |||
| 1651 | } | 1640 | } |
| 1652 | 1641 | ||
| 1653 | 1642 | ||
| 1654 | static Lisp_Object find_handler_clause (Lisp_Object, Lisp_Object, | 1643 | static Lisp_Object find_handler_clause (Lisp_Object, Lisp_Object); |
| 1655 | Lisp_Object, Lisp_Object); | ||
| 1656 | static int maybe_call_debugger (Lisp_Object conditions, Lisp_Object sig, | 1644 | static int maybe_call_debugger (Lisp_Object conditions, Lisp_Object sig, |
| 1657 | Lisp_Object data); | 1645 | Lisp_Object data); |
| 1658 | 1646 | ||
| @@ -1728,8 +1716,7 @@ See also the function `condition-case'. */) | |||
| 1728 | 1716 | ||
| 1729 | for (h = handlerlist; h; h = h->next) | 1717 | for (h = handlerlist; h; h = h->next) |
| 1730 | { | 1718 | { |
| 1731 | clause = find_handler_clause (h->handler, conditions, | 1719 | clause = find_handler_clause (h->handler, conditions); |
| 1732 | error_symbol, data); | ||
| 1733 | if (!NILP (clause)) | 1720 | if (!NILP (clause)) |
| 1734 | break; | 1721 | break; |
| 1735 | } | 1722 | } |
| @@ -1900,8 +1887,10 @@ skip_debugger (Lisp_Object conditions, Lisp_Object data) | |||
| 1900 | } | 1887 | } |
| 1901 | 1888 | ||
| 1902 | /* Call the debugger if calling it is currently enabled for CONDITIONS. | 1889 | /* Call the debugger if calling it is currently enabled for CONDITIONS. |
| 1903 | SIG and DATA describe the signal, as in find_handler_clause. */ | 1890 | SIG and DATA describe the signal. There are two ways to pass them: |
| 1904 | 1891 | = SIG is the error symbol, and DATA is the rest of the data. | |
| 1892 | = SIG is nil, and DATA is (SYMBOL . REST-OF-DATA). | ||
| 1893 | This is for memory-full errors only. */ | ||
| 1905 | static int | 1894 | static int |
| 1906 | maybe_call_debugger (Lisp_Object conditions, Lisp_Object sig, Lisp_Object data) | 1895 | maybe_call_debugger (Lisp_Object conditions, Lisp_Object sig, Lisp_Object data) |
| 1907 | { | 1896 | { |
| @@ -1928,19 +1917,8 @@ maybe_call_debugger (Lisp_Object conditions, Lisp_Object sig, Lisp_Object data) | |||
| 1928 | return 0; | 1917 | return 0; |
| 1929 | } | 1918 | } |
| 1930 | 1919 | ||
| 1931 | /* Value of Qlambda means we have called debugger and user has continued. | ||
| 1932 | There are two ways to pass SIG and DATA: | ||
| 1933 | = SIG is the error symbol, and DATA is the rest of the data. | ||
| 1934 | = SIG is nil, and DATA is (SYMBOL . REST-OF-DATA). | ||
| 1935 | This is for memory-full errors only. | ||
| 1936 | |||
| 1937 | We need to increase max_specpdl_size temporarily around | ||
| 1938 | anything we do that can push on the specpdl, so as not to get | ||
| 1939 | a second error here in case we're handling specpdl overflow. */ | ||
| 1940 | |||
| 1941 | static Lisp_Object | 1920 | static Lisp_Object |
| 1942 | find_handler_clause (Lisp_Object handlers, Lisp_Object conditions, | 1921 | find_handler_clause (Lisp_Object handlers, Lisp_Object conditions) |
| 1943 | Lisp_Object sig, Lisp_Object data) | ||
| 1944 | { | 1922 | { |
| 1945 | register Lisp_Object h; | 1923 | register Lisp_Object h; |
| 1946 | 1924 | ||
| @@ -2291,7 +2269,6 @@ eval_sub (Lisp_Object form) | |||
| 2291 | backtrace.function = &original_fun; /* This also protects them from gc. */ | 2269 | backtrace.function = &original_fun; /* This also protects them from gc. */ |
| 2292 | backtrace.args = &original_args; | 2270 | backtrace.args = &original_args; |
| 2293 | backtrace.nargs = UNEVALLED; | 2271 | backtrace.nargs = UNEVALLED; |
| 2294 | backtrace.evalargs = 1; | ||
| 2295 | backtrace.debug_on_exit = 0; | 2272 | backtrace.debug_on_exit = 0; |
| 2296 | 2273 | ||
| 2297 | if (debug_on_next_call) | 2274 | if (debug_on_next_call) |
| @@ -2325,10 +2302,7 @@ eval_sub (Lisp_Object form) | |||
| 2325 | xsignal2 (Qwrong_number_of_arguments, original_fun, numargs); | 2302 | xsignal2 (Qwrong_number_of_arguments, original_fun, numargs); |
| 2326 | 2303 | ||
| 2327 | else if (XSUBR (fun)->max_args == UNEVALLED) | 2304 | else if (XSUBR (fun)->max_args == UNEVALLED) |
| 2328 | { | 2305 | val = (XSUBR (fun)->function.aUNEVALLED) (args_left); |
| 2329 | backtrace.evalargs = 0; | ||
| 2330 | val = (XSUBR (fun)->function.aUNEVALLED) (args_left); | ||
| 2331 | } | ||
| 2332 | else if (XSUBR (fun)->max_args == MANY) | 2306 | else if (XSUBR (fun)->max_args == MANY) |
| 2333 | { | 2307 | { |
| 2334 | /* Pass a vector of evaluated arguments. */ | 2308 | /* Pass a vector of evaluated arguments. */ |
| @@ -2984,7 +2958,6 @@ usage: (funcall FUNCTION &rest ARGUMENTS) */) | |||
| 2984 | backtrace.function = &args[0]; | 2958 | backtrace.function = &args[0]; |
| 2985 | backtrace.args = &args[1]; | 2959 | backtrace.args = &args[1]; |
| 2986 | backtrace.nargs = nargs - 1; | 2960 | backtrace.nargs = nargs - 1; |
| 2987 | backtrace.evalargs = 0; | ||
| 2988 | backtrace.debug_on_exit = 0; | 2961 | backtrace.debug_on_exit = 0; |
| 2989 | 2962 | ||
| 2990 | if (debug_on_next_call) | 2963 | if (debug_on_next_call) |
| @@ -3141,7 +3114,6 @@ apply_lambda (Lisp_Object fun, Lisp_Object args) | |||
| 3141 | 3114 | ||
| 3142 | backtrace_list->args = arg_vector; | 3115 | backtrace_list->args = arg_vector; |
| 3143 | backtrace_list->nargs = i; | 3116 | backtrace_list->nargs = i; |
| 3144 | backtrace_list->evalargs = 0; | ||
| 3145 | tem = funcall_lambda (fun, numargs, arg_vector); | 3117 | tem = funcall_lambda (fun, numargs, arg_vector); |
| 3146 | 3118 | ||
| 3147 | /* Do the debug-on-exit now, while arg_vector still exists. */ | 3119 | /* Do the debug-on-exit now, while arg_vector still exists. */ |
| @@ -3190,7 +3162,7 @@ funcall_lambda (Lisp_Object fun, ptrdiff_t nargs, | |||
| 3190 | shouldn't bind any arguments, instead just call the byte-code | 3162 | shouldn't bind any arguments, instead just call the byte-code |
| 3191 | interpreter directly; it will push arguments as necessary. | 3163 | interpreter directly; it will push arguments as necessary. |
| 3192 | 3164 | ||
| 3193 | Byte-code objects with either a non-existant, or a nil value for | 3165 | Byte-code objects with either a non-existent, or a nil value for |
| 3194 | the `push args' slot (the default), have dynamically-bound | 3166 | the `push args' slot (the default), have dynamically-bound |
| 3195 | arguments, and use the argument-binding code below instead (as do | 3167 | arguments, and use the argument-binding code below instead (as do |
| 3196 | all interpreted functions, even lexically bound ones). */ | 3168 | all interpreted functions, even lexically bound ones). */ |