comparison src/eval.c @ 49600:23a1cea22d13

Trailing whitespace deleted.
author Juanma Barranquero <lekktu@gmail.com>
date Tue, 04 Feb 2003 14:56:31 +0000
parents 9cd789fbff75
children aa54553dad6b
comparison
equal deleted inserted replaced
49599:5ade352e8d1c 49600:23a1cea22d13
232 Lisp_Object arg; 232 Lisp_Object arg;
233 { 233 {
234 int debug_while_redisplaying; 234 int debug_while_redisplaying;
235 int count = SPECPDL_INDEX (); 235 int count = SPECPDL_INDEX ();
236 Lisp_Object val; 236 Lisp_Object val;
237 237
238 if (lisp_eval_depth + 20 > max_lisp_eval_depth) 238 if (lisp_eval_depth + 20 > max_lisp_eval_depth)
239 max_lisp_eval_depth = lisp_eval_depth + 20; 239 max_lisp_eval_depth = lisp_eval_depth + 20;
240 240
241 if (specpdl_size + 40 > max_specpdl_size) 241 if (specpdl_size + 40 > max_specpdl_size)
242 max_specpdl_size = specpdl_size + 40; 242 max_specpdl_size = specpdl_size + 40;
243 243
244 #ifdef HAVE_X_WINDOWS 244 #ifdef HAVE_X_WINDOWS
245 if (display_hourglass_p) 245 if (display_hourglass_p)
246 cancel_hourglass (); 246 cancel_hourglass ();
247 #endif 247 #endif
248 248
259 259
260 #if 0 /* Binding this prevents execution of Lisp code during 260 #if 0 /* Binding this prevents execution of Lisp code during
261 redisplay, which necessarily leads to display problems. */ 261 redisplay, which necessarily leads to display problems. */
262 specbind (Qinhibit_eval_during_redisplay, Qt); 262 specbind (Qinhibit_eval_during_redisplay, Qt);
263 #endif 263 #endif
264 264
265 val = apply1 (Vdebugger, arg); 265 val = apply1 (Vdebugger, arg);
266 266
267 /* Interrupting redisplay and resuming it later is not safe under 267 /* Interrupting redisplay and resuming it later is not safe under
268 all circumstances. So, when the debugger returns, abort the 268 all circumstances. So, when the debugger returns, abort the
269 interrupted redisplay by going back to the top-level. */ 269 interrupted redisplay by going back to the top-level. */
533 while (!NILP(args_left)); 533 while (!NILP(args_left));
534 534
535 UNGCPRO; 535 UNGCPRO;
536 return val; 536 return val;
537 } 537 }
538 538
539 DEFUN ("quote", Fquote, Squote, 1, UNEVALLED, 0, 539 DEFUN ("quote", Fquote, Squote, 1, UNEVALLED, 0,
540 doc: /* Return the argument, without evaluating it. `(quote x)' yields `x'. 540 doc: /* Return the argument, without evaluating it. `(quote x)' yields `x'.
541 usage: (quote ARG) */) 541 usage: (quote ARG) */)
542 (args) 542 (args)
543 Lisp_Object args; 543 Lisp_Object args;
544 { 544 {
545 return Fcar (args); 545 return Fcar (args);
546 } 546 }
547 547
548 DEFUN ("function", Ffunction, Sfunction, 1, UNEVALLED, 0, 548 DEFUN ("function", Ffunction, Sfunction, 1, UNEVALLED, 0,
549 doc: /* Like `quote', but preferred for objects which are functions. 549 doc: /* Like `quote', but preferred for objects which are functions.
550 In byte compilation, `function' causes its argument to be compiled. 550 In byte compilation, `function' causes its argument to be compiled.
551 `quote' cannot do that. 551 `quote' cannot do that.
552 usage: (function ARG) */) 552 usage: (function ARG) */)
612 Fbytecode at the top. If this frame is for a built-in function 612 Fbytecode at the top. If this frame is for a built-in function
613 (such as load or eval-region) return nil. */ 613 (such as load or eval-region) return nil. */
614 fun = Findirect_function (*btp->function); 614 fun = Findirect_function (*btp->function);
615 if (exclude_subrs_p && SUBRP (fun)) 615 if (exclude_subrs_p && SUBRP (fun))
616 return 0; 616 return 0;
617 617
618 /* btp points to the frame of a Lisp function that called interactive-p. 618 /* btp points to the frame of a Lisp function that called interactive-p.
619 Return t if that function was called interactively. */ 619 Return t if that function was called interactively. */
620 if (btp && btp->next && EQ (*btp->next->function, Qcall_interactively)) 620 if (btp && btp->next && EQ (*btp->next->function, Qcall_interactively))
621 return 1; 621 return 1;
622 return 0; 622 return 0;
692 struct gcpro gcpro1; 692 struct gcpro gcpro1;
693 GCPRO1 (args); 693 GCPRO1 (args);
694 call2 (Vmacro_declaration_function, fn_name, Fcar (tail)); 694 call2 (Vmacro_declaration_function, fn_name, Fcar (tail));
695 UNGCPRO; 695 UNGCPRO;
696 } 696 }
697 697
698 tail = Fcdr (tail); 698 tail = Fcdr (tail);
699 } 699 }
700 700
701 if (NILP (doc)) 701 if (NILP (doc))
702 tail = Fcons (lambda_list, tail); 702 tail = Fcons (lambda_list, tail);
703 else 703 else
704 tail = Fcons (lambda_list, Fcons (doc, tail)); 704 tail = Fcons (lambda_list, Fcons (doc, tail));
705 defn = Fcons (Qmacro, Fcons (Qlambda, tail)); 705 defn = Fcons (Qmacro, Fcons (Qlambda, tail));
706 706
707 if (!NILP (Vpurify_flag)) 707 if (!NILP (Vpurify_flag))
708 defn = Fpurecopy (defn); 708 defn = Fpurecopy (defn);
709 if (CONSP (XSYMBOL (fn_name)->function) 709 if (CONSP (XSYMBOL (fn_name)->function)
710 && EQ (XCAR (XSYMBOL (fn_name)->function), Qautoload)) 710 && EQ (XCAR (XSYMBOL (fn_name)->function), Qautoload))
711 LOADHIST_ATTACH (Fcons (Qt, fn_name)); 711 LOADHIST_ATTACH (Fcons (Qt, fn_name));
833 value of `standard-value' or of `custom-autoload' on its property list). */) 833 value of `standard-value' or of `custom-autoload' on its property list). */)
834 (variable) 834 (variable)
835 Lisp_Object variable; 835 Lisp_Object variable;
836 { 836 {
837 Lisp_Object documentation; 837 Lisp_Object documentation;
838 838
839 if (!SYMBOLP (variable)) 839 if (!SYMBOLP (variable))
840 return Qnil; 840 return Qnil;
841 841
842 documentation = Fget (variable, Qvariable_documentation); 842 documentation = Fget (variable, Qvariable_documentation);
843 if (INTEGERP (documentation) && XINT (documentation) < 0) 843 if (INTEGERP (documentation) && XINT (documentation) < 0)
854 /* Customizable? See `custom-variable-p'. */ 854 /* Customizable? See `custom-variable-p'. */
855 if ((!NILP (Fget (variable, intern ("standard-value")))) 855 if ((!NILP (Fget (variable, intern ("standard-value"))))
856 || (!NILP (Fget (variable, intern ("custom-autoload"))))) 856 || (!NILP (Fget (variable, intern ("custom-autoload")))))
857 return Qt; 857 return Qt;
858 return Qnil; 858 return Qnil;
859 } 859 }
860 860
861 DEFUN ("let*", FletX, SletX, 1, UNEVALLED, 0, 861 DEFUN ("let*", FletX, SletX, 1, UNEVALLED, 0,
862 doc: /* Bind variables according to VARLIST then eval BODY. 862 doc: /* Bind variables according to VARLIST then eval BODY.
863 The value of the last form in BODY is returned. 863 The value of the last form in BODY is returned.
864 Each element of VARLIST is a symbol (which is bound to nil) 864 Each element of VARLIST is a symbol (which is bound to nil)
1166 else 1166 else
1167 gcpro_level = 0; 1167 gcpro_level = 0;
1168 #endif 1168 #endif
1169 backtrace_list = catch->backlist; 1169 backtrace_list = catch->backlist;
1170 lisp_eval_depth = catch->lisp_eval_depth; 1170 lisp_eval_depth = catch->lisp_eval_depth;
1171 1171
1172 _longjmp (catch->jmp, 1); 1172 _longjmp (catch->jmp, 1);
1173 } 1173 }
1174 1174
1175 DEFUN ("throw", Fthrow, Sthrow, 2, 2, 0, 1175 DEFUN ("throw", Fthrow, Sthrow, 2, 2, 0,
1176 doc: /* Throw to the catch for TAG and return VALUE from it. 1176 doc: /* Throw to the catch for TAG and return VALUE from it.
1205 Lisp_Object val; 1205 Lisp_Object val;
1206 int count = SPECPDL_INDEX (); 1206 int count = SPECPDL_INDEX ();
1207 1207
1208 record_unwind_protect (0, Fcdr (args)); 1208 record_unwind_protect (0, Fcdr (args));
1209 val = Feval (Fcar (args)); 1209 val = Feval (Fcar (args));
1210 return unbind_to (count, val); 1210 return unbind_to (count, val);
1211 } 1211 }
1212 1212
1213 /* Chain of condition handlers currently in effect. 1213 /* Chain of condition handlers currently in effect.
1214 The elements of this chain are contained in the stack frames 1214 The elements of this chain are contained in the stack frames
1215 of Fcondition_case and internal_condition_case. 1215 of Fcondition_case and internal_condition_case.
1286 unbind_to (c.pdlcount, Qnil); 1286 unbind_to (c.pdlcount, Qnil);
1287 return val; 1287 return val;
1288 } 1288 }
1289 c.next = catchlist; 1289 c.next = catchlist;
1290 catchlist = &c; 1290 catchlist = &c;
1291 1291
1292 h.var = var; 1292 h.var = var;
1293 h.handler = handlers; 1293 h.handler = handlers;
1294 h.next = handlerlist; 1294 h.next = handlerlist;
1295 h.tag = &c; 1295 h.tag = &c;
1296 handlerlist = &h; 1296 handlerlist = &h;
1484 but it is surely wrong for an error that is handled. */ 1484 but it is surely wrong for an error that is handled. */
1485 #ifdef HAVE_X_WINDOWS 1485 #ifdef HAVE_X_WINDOWS
1486 if (display_hourglass_p) 1486 if (display_hourglass_p)
1487 cancel_hourglass (); 1487 cancel_hourglass ();
1488 #endif 1488 #endif
1489 #endif 1489 #endif
1490 1490
1491 /* This hook is used by edebug. */ 1491 /* This hook is used by edebug. */
1492 if (! NILP (Vsignal_hook_function) 1492 if (! NILP (Vsignal_hook_function)
1493 && ! NILP (error_symbol)) 1493 && ! NILP (error_symbol))
1494 call2 (Vsignal_hook_function, error_symbol, data); 1494 call2 (Vsignal_hook_function, error_symbol, data);
1510 } 1510 }
1511 1511
1512 for (; handlerlist; handlerlist = handlerlist->next) 1512 for (; handlerlist; handlerlist = handlerlist->next)
1513 { 1513 {
1514 register Lisp_Object clause; 1514 register Lisp_Object clause;
1515 1515
1516 if (lisp_eval_depth + 20 > max_lisp_eval_depth) 1516 if (lisp_eval_depth + 20 > max_lisp_eval_depth)
1517 max_lisp_eval_depth = lisp_eval_depth + 20; 1517 max_lisp_eval_depth = lisp_eval_depth + 20;
1518 1518
1519 if (specpdl_size + 40 > max_specpdl_size) 1519 if (specpdl_size + 40 > max_specpdl_size)
1520 max_specpdl_size = specpdl_size + 40; 1520 max_specpdl_size = specpdl_size + 40;
1521 1521
1522 clause = find_handler_clause (handlerlist->handler, conditions, 1522 clause = find_handler_clause (handlerlist->handler, conditions,
1523 error_symbol, data, &debugger_value); 1523 error_symbol, data, &debugger_value);
1524 1524
1525 if (EQ (clause, Qlambda)) 1525 if (EQ (clause, Qlambda))
1526 { 1526 {
1606 if (first_string) 1606 if (first_string)
1607 { 1607 {
1608 error_message = Ferror_message_string (data); 1608 error_message = Ferror_message_string (data);
1609 first_string = 0; 1609 first_string = 0;
1610 } 1610 }
1611 1611
1612 if (fast_string_match (XCAR (tail), error_message) >= 0) 1612 if (fast_string_match (XCAR (tail), error_message) >= 0)
1613 return 1; 1613 return 1;
1614 } 1614 }
1615 else 1615 else
1616 { 1616 {
1931 CHECK_SYMBOL (funname); 1931 CHECK_SYMBOL (funname);
1932 GCPRO3 (fun, funname, fundef); 1932 GCPRO3 (fun, funname, fundef);
1933 1933
1934 /* Preserve the match data. */ 1934 /* Preserve the match data. */
1935 record_unwind_protect (Fset_match_data, Fmatch_data (Qnil, Qnil)); 1935 record_unwind_protect (Fset_match_data, Fmatch_data (Qnil, Qnil));
1936 1936
1937 /* Value saved here is to be restored into Vautoload_queue. */ 1937 /* Value saved here is to be restored into Vautoload_queue. */
1938 record_unwind_protect (un_autoload, Vautoload_queue); 1938 record_unwind_protect (un_autoload, Vautoload_queue);
1939 Vautoload_queue = Qt; 1939 Vautoload_queue = Qt;
1940 Fload (Fcar (Fcdr (fundef)), Qnil, noninteractive ? Qt : Qnil, Qnil, Qt); 1940 Fload (Fcar (Fcdr (fundef)), Qnil, noninteractive ? Qt : Qnil, Qnil, Qt);
1941 1941
1979 struct backtrace backtrace; 1979 struct backtrace backtrace;
1980 struct gcpro gcpro1, gcpro2, gcpro3; 1980 struct gcpro gcpro1, gcpro2, gcpro3;
1981 1981
1982 if (handling_signal) 1982 if (handling_signal)
1983 abort (); 1983 abort ();
1984 1984
1985 if (SYMBOLP (form)) 1985 if (SYMBOLP (form))
1986 return Fsymbol_value (form); 1986 return Fsymbol_value (form);
1987 if (!CONSP (form)) 1987 if (!CONSP (form))
1988 return form; 1988 return form;
1989 1989
2160 val = call_debugger (Fcons (Qexit, Fcons (val, Qnil))); 2160 val = call_debugger (Fcons (Qexit, Fcons (val, Qnil)));
2161 backtrace_list = backtrace.next; 2161 backtrace_list = backtrace.next;
2162 2162
2163 #ifdef HAVE_CARBON 2163 #ifdef HAVE_CARBON
2164 mac_check_for_quit_char(); 2164 mac_check_for_quit_char();
2165 #endif 2165 #endif
2166 return val; 2166 return val;
2167 } 2167 }
2168 2168
2169 DEFUN ("apply", Fapply, Sapply, 2, MANY, 0, 2169 DEFUN ("apply", Fapply, Sapply, 2, MANY, 0,
2170 doc: /* Call FUNCTION with our remaining args, using our last arg as list of args. 2170 doc: /* Call FUNCTION with our remaining args, using our last arg as list of args.
2183 2183
2184 fun = args [0]; 2184 fun = args [0];
2185 funcall_args = 0; 2185 funcall_args = 0;
2186 spread_arg = args [nargs - 1]; 2186 spread_arg = args [nargs - 1];
2187 CHECK_LIST (spread_arg); 2187 CHECK_LIST (spread_arg);
2188 2188
2189 numargs = XINT (Flength (spread_arg)); 2189 numargs = XINT (Flength (spread_arg));
2190 2190
2191 if (numargs == 0) 2191 if (numargs == 0)
2192 return Ffuncall (nargs - 1, args); 2192 return Ffuncall (nargs - 1, args);
2193 else if (numargs == 1) 2193 else if (numargs == 1)
2278 run_hook_with_args (1, hook, to_completion); 2278 run_hook_with_args (1, hook, to_completion);
2279 } 2279 }
2280 2280
2281 return Qnil; 2281 return Qnil;
2282 } 2282 }
2283 2283
2284 DEFUN ("run-hook-with-args", Frun_hook_with_args, 2284 DEFUN ("run-hook-with-args", Frun_hook_with_args,
2285 Srun_hook_with_args, 1, MANY, 0, 2285 Srun_hook_with_args, 1, MANY, 0,
2286 doc: /* Run HOOK with the specified arguments ARGS. 2286 doc: /* Run HOOK with the specified arguments ARGS.
2287 HOOK should be a symbol, a hook variable. If HOOK has a non-nil 2287 HOOK should be a symbol, a hook variable. If HOOK has a non-nil
2288 value, that value may be a function or a list of functions to be 2288 value, that value may be a function or a list of functions to be
2521 call1 (fn, arg1) 2521 call1 (fn, arg1)
2522 Lisp_Object fn, arg1; 2522 Lisp_Object fn, arg1;
2523 { 2523 {
2524 struct gcpro gcpro1; 2524 struct gcpro gcpro1;
2525 #ifdef NO_ARG_ARRAY 2525 #ifdef NO_ARG_ARRAY
2526 Lisp_Object args[2]; 2526 Lisp_Object args[2];
2527 2527
2528 args[0] = fn; 2528 args[0] = fn;
2529 args[1] = arg1; 2529 args[1] = arg1;
2530 GCPRO1 (args[0]); 2530 GCPRO1 (args[0]);
2531 gcpro1.nvars = 2; 2531 gcpro1.nvars = 2;
2777 goto done; 2777 goto done;
2778 2778
2779 default: 2779 default:
2780 2780
2781 /* If a subr takes more than 8 arguments without using MANY 2781 /* If a subr takes more than 8 arguments without using MANY
2782 or UNEVALLED, we need to extend this function to support it. 2782 or UNEVALLED, we need to extend this function to support it.
2783 Until this is done, there is no way to call the function. */ 2783 Until this is done, there is no way to call the function. */
2784 abort (); 2784 abort ();
2785 } 2785 }
2786 } 2786 }
2787 if (COMPILEDP (fun)) 2787 if (COMPILEDP (fun))
2885 2885
2886 i = optional = rest = 0; 2886 i = optional = rest = 0;
2887 for (; CONSP (syms_left); syms_left = XCDR (syms_left)) 2887 for (; CONSP (syms_left); syms_left = XCDR (syms_left))
2888 { 2888 {
2889 QUIT; 2889 QUIT;
2890 2890
2891 next = XCAR (syms_left); 2891 next = XCAR (syms_left);
2892 while (!SYMBOLP (next)) 2892 while (!SYMBOLP (next))
2893 next = Fsignal (Qinvalid_function, Fcons (fun, Qnil)); 2893 next = Fsignal (Qinvalid_function, Fcons (fun, Qnil));
2894 2894
2895 if (EQ (next, Qand_rest)) 2895 if (EQ (next, Qand_rest))
2896 rest = 1; 2896 rest = 1;
2897 else if (EQ (next, Qand_optional)) 2897 else if (EQ (next, Qand_optional))
2898 optional = 1; 2898 optional = 1;
2899 else if (rest) 2899 else if (rest)
2926 Ffetch_bytecode (fun); 2926 Ffetch_bytecode (fun);
2927 val = Fbyte_code (AREF (fun, COMPILED_BYTECODE), 2927 val = Fbyte_code (AREF (fun, COMPILED_BYTECODE),
2928 AREF (fun, COMPILED_CONSTANTS), 2928 AREF (fun, COMPILED_CONSTANTS),
2929 AREF (fun, COMPILED_STACK_DEPTH)); 2929 AREF (fun, COMPILED_STACK_DEPTH));
2930 } 2930 }
2931 2931
2932 return unbind_to (count, val); 2932 return unbind_to (count, val);
2933 } 2933 }
2934 2934
2935 DEFUN ("fetch-bytecode", Ffetch_bytecode, Sfetch_bytecode, 2935 DEFUN ("fetch-bytecode", Ffetch_bytecode, Sfetch_bytecode,
2936 1, 1, 0, 2936 1, 1, 0,
3004 SET_SYMBOL_VALUE (symbol, value); 3004 SET_SYMBOL_VALUE (symbol, value);
3005 } 3005 }
3006 else 3006 else
3007 { 3007 {
3008 Lisp_Object valcontents; 3008 Lisp_Object valcontents;
3009 3009
3010 ovalue = find_symbol_value (symbol); 3010 ovalue = find_symbol_value (symbol);
3011 specpdl_ptr->func = 0; 3011 specpdl_ptr->func = 0;
3012 specpdl_ptr->old_value = ovalue; 3012 specpdl_ptr->old_value = ovalue;
3013 3013
3014 valcontents = XSYMBOL (symbol)->value; 3014 valcontents = XSYMBOL (symbol)->value;
3018 || BUFFER_OBJFWDP (valcontents)) 3018 || BUFFER_OBJFWDP (valcontents))
3019 { 3019 {
3020 Lisp_Object where, current_buffer; 3020 Lisp_Object where, current_buffer;
3021 3021
3022 current_buffer = Fcurrent_buffer (); 3022 current_buffer = Fcurrent_buffer ();
3023 3023
3024 /* For a local variable, record both the symbol and which 3024 /* For a local variable, record both the symbol and which
3025 buffer's or frame's value we are saving. */ 3025 buffer's or frame's value we are saving. */
3026 if (!NILP (Flocal_variable_p (symbol, Qnil))) 3026 if (!NILP (Flocal_variable_p (symbol, Qnil)))
3027 where = current_buffer; 3027 where = current_buffer;
3028 else if (!BUFFER_OBJFWDP (valcontents) 3028 else if (!BUFFER_OBJFWDP (valcontents)
3110 3110
3111 if (NILP (where)) 3111 if (NILP (where))
3112 Fset_default (symbol, specpdl_ptr->old_value); 3112 Fset_default (symbol, specpdl_ptr->old_value);
3113 else if (BUFFERP (where)) 3113 else if (BUFFERP (where))
3114 set_internal (symbol, specpdl_ptr->old_value, XBUFFER (where), 1); 3114 set_internal (symbol, specpdl_ptr->old_value, XBUFFER (where), 1);
3115 else 3115 else
3116 set_internal (symbol, specpdl_ptr->old_value, NULL, 1); 3116 set_internal (symbol, specpdl_ptr->old_value, NULL, 1);
3117 } 3117 }
3118 else 3118 else
3119 { 3119 {
3120 /* If variable has a trivial value (no forwarding), we can 3120 /* If variable has a trivial value (no forwarding), we can
3124 SET_SYMBOL_VALUE (specpdl_ptr->symbol, specpdl_ptr->old_value); 3124 SET_SYMBOL_VALUE (specpdl_ptr->symbol, specpdl_ptr->old_value);
3125 else 3125 else
3126 set_internal (specpdl_ptr->symbol, specpdl_ptr->old_value, 0, 1); 3126 set_internal (specpdl_ptr->symbol, specpdl_ptr->old_value, 0, 1);
3127 } 3127 }
3128 } 3128 }
3129 3129
3130 if (NILP (Vquit_flag) && quitf) 3130 if (NILP (Vquit_flag) && quitf)
3131 Vquit_flag = Qt; 3131 Vquit_flag = Qt;
3132 3132
3133 UNGCPRO; 3133 UNGCPRO;
3134 return value; 3134 return value;
3298 Qmacro = intern ("macro"); 3298 Qmacro = intern ("macro");
3299 staticpro (&Qmacro); 3299 staticpro (&Qmacro);
3300 3300
3301 Qdeclare = intern ("declare"); 3301 Qdeclare = intern ("declare");
3302 staticpro (&Qdeclare); 3302 staticpro (&Qdeclare);
3303 3303
3304 /* Note that the process handling also uses Qexit, but we don't want 3304 /* Note that the process handling also uses Qexit, but we don't want
3305 to staticpro it twice, so we just do it here. */ 3305 to staticpro it twice, so we just do it here. */
3306 Qexit = intern ("exit"); 3306 Qexit = intern ("exit");
3307 staticpro (&Qexit); 3307 staticpro (&Qexit);
3308 3308