/* Evaluator for XEmacs Lisp interpreter.
Copyright (C) 1985-1987, 1992-1994 Free Software Foundation, Inc.
Copyright (C) 1995 Sun Microsystems, Inc.
+ Copyright (C) 2000 Ben Wing.
This file is part of XEmacs.
specbind (Qdebug_on_signal, Qnil);
specbind (Qstack_trace_on_signal, Qnil);
- internal_with_output_to_temp_buffer (build_string ("*Backtrace*"),
- backtrace_259,
- Qnil,
- Qnil);
+ if (!noninteractive)
+ internal_with_output_to_temp_buffer (build_string ("*Backtrace*"),
+ backtrace_259,
+ Qnil,
+ Qnil);
+ else /* in batch mode, we want this going to stderr. */
+ backtrace_259 (Qnil);
unbind_to (speccount, Qnil);
*stack_trace_displayed = 1;
}
specbind (Qdebug_on_signal, Qnil);
specbind (Qstack_trace_on_signal, Qnil);
- internal_with_output_to_temp_buffer (build_string ("*Backtrace*"),
- backtrace_259,
- Qnil,
- Qnil);
+ if (!noninteractive)
+ internal_with_output_to_temp_buffer (build_string ("*Backtrace*"),
+ backtrace_259,
+ Qnil,
+ Qnil);
+ else /* in batch mode, we want this going to stderr. */
+ backtrace_259 (Qnil);
unbind_to (speccount, Qnil);
*stack_trace_displayed = 1;
}
(args))
{
/* This function can GC */
- REGISTER Lisp_Object arg, val;
+ REGISTER Lisp_Object val;
LIST_LOOP_2 (arg, args)
{
(args))
{
/* This function can GC */
- REGISTER Lisp_Object arg, val = Qt;
+ REGISTER Lisp_Object val = Qt;
LIST_LOOP_2 (arg, args)
{
(args))
{
/* This function can GC */
- REGISTER Lisp_Object val, clause;
+ REGISTER Lisp_Object val;
LIST_LOOP_2 (clause, args)
{
{
/* This function can GC */
/* Caller must provide a true list in ARGS */
- REGISTER Lisp_Object form, val = Qnil;
+ REGISTER Lisp_Object val = Qnil;
struct gcpro gcpro1;
GCPRO1 (args);
(args))
{
/* This function can GC */
- REGISTER Lisp_Object val, form;
+ REGISTER Lisp_Object val;
struct gcpro gcpro1;
val = Feval (XCAR (args));
(args))
{
/* This function can GC */
- REGISTER Lisp_Object val, form, tail;
+ REGISTER Lisp_Object val;
struct gcpro gcpro1;
Feval (XCAR (args));
GCPRO1 (val);
- LIST_LOOP_3 (form, args, tail)
- Feval (form);
+ {
+ LIST_LOOP_2 (form, args)
+ Feval (form);
+ }
UNGCPRO;
return val;
(args))
{
/* This function can GC */
- Lisp_Object var, tail;
Lisp_Object varlist = XCAR (args);
Lisp_Object body = XCDR (args);
int speccount = specpdl_depth();
(args))
{
/* This function can GC */
- Lisp_Object var, tail;
Lisp_Object varlist = XCAR (args);
Lisp_Object body = XCDR (args);
int speccount = specpdl_depth();
gcpro1.nvars = 0;
idx = 0;
- LIST_LOOP_3 (var, varlist, tail)
- {
- Lisp_Object *value = &temps[idx++];
- if (SYMBOLP (var))
- *value = Qnil;
- else
- {
- Lisp_Object tem;
- CHECK_CONS (var);
- tem = XCDR (var);
- if (NILP (tem))
- *value = Qnil;
- else
- {
- CHECK_CONS (tem);
- *value = Feval (XCAR (tem));
- gcpro1.nvars = idx;
+ {
+ LIST_LOOP_2 (var, varlist)
+ {
+ Lisp_Object *value = &temps[idx++];
+ if (SYMBOLP (var))
+ *value = Qnil;
+ else
+ {
+ Lisp_Object tem;
+ CHECK_CONS (var);
+ tem = XCDR (var);
+ if (NILP (tem))
+ *value = Qnil;
+ else
+ {
+ CHECK_CONS (tem);
+ *value = Feval (XCAR (tem));
+ gcpro1.nvars = idx;
- if (!NILP (XCDR (tem)))
- signal_simple_error
- ("`let' bindings can have only one value-form", var);
- }
- }
- }
+ if (!NILP (XCDR (tem)))
+ signal_simple_error
+ ("`let' bindings can have only one value-form", var);
+ }
+ }
+ }
+ }
idx = 0;
- LIST_LOOP_3 (var, varlist, tail)
- {
- specbind (SYMBOLP (var) ? var : XCAR (var), temps[idx++]);
- }
+ {
+ LIST_LOOP_2 (var, varlist)
+ {
+ specbind (SYMBOLP (var) ? var : XCAR (var), temps[idx++]);
+ }
+ }
UNGCPRO;
buffer-local values are not affected.
INITVALUE and DOCSTRING are optional.
If DOCSTRING starts with *, this variable is identified as a user option.
- This means that M-x set-variable and M-x edit-options recognize it.
+ This means that M-x set-variable recognizes it.
If INITVALUE is missing, SYMBOL's value is not set.
In lisp-interaction-mode defvar is treated as defconst.
buffer-local values are not affected.
DOCSTRING is optional.
If DOCSTRING starts with *, this variable is identified as a user option.
- This means that M-x set-variable and M-x edit-options recognize it.
+ This means that M-x set-variable recognizes it.
Note: do not use `defconst' for user options in libraries that are not
normally loaded, since it is useful for users to be able to specify
Otherwise, the macro is expanded and the expansion is considered
in place of FORM. When a non-macro-call results, it is returned.
-The second optional arg ENVIRONMENT species an environment of macro
+The second optional arg ENVIRONMENT specifies an environment of macro
definitions to shadow the loaded ones for use in file byte-compilation.
*/
- (form, env))
+ (form, environment))
{
/* This function can GC */
/* With cleanups from Hallvard Furuseth. */
{
QUIT;
sym = def;
- tem = Fassq (sym, env);
+ tem = Fassq (sym, environment);
if (NILP (tem))
{
def = XSYMBOL (sym)->function;
}
break;
}
- /* Right now TEM is the result from SYM in ENV,
+ /* Right now TEM is the result from SYM in ENVIRONMENT,
and if TEM is nil then DEF is SYM's function definition. */
if (NILP (tem))
{
- /* SYM is not mentioned in ENV.
+ /* SYM is not mentioned in ENVIRONMENT.
Look at its function definition. */
if (UNBOUNDP (def)
|| !CONSP (def))
condition_case_3 (Lisp_Object bodyform, Lisp_Object var, Lisp_Object handlers)
{
/* This function can GC */
- Lisp_Object handler;
-
EXTERNAL_LIST_LOOP_2 (handler, handlers)
{
if (NILP (handler))
;
else
{
- Lisp_Object condition;
EXTERNAL_LIST_LOOP_2 (condition, conditions)
if (!SYMBOLP (condition))
goto invalid_condition_handler;
/****************** Error functions class 2 ******************/
/* Class 2: Printf-like functions that signal an error.
+ These functions signal an error of a specified type, whose data
+ is a single string, created using the arguments. */
+
+/* dump an error message; called like printf */
+
+DOESNT_RETURN
+type_error (Lisp_Object type, const char *fmt, ...)
+{
+ Lisp_Object obj;
+ va_list args;
+
+ va_start (args, fmt);
+ obj = emacs_doprnt_string_va ((const Bufbyte *) GETTEXT (fmt), Qnil, -1,
+ args);
+ va_end (args);
+
+ /* Fsignal GC-protects its args */
+ signal_error (type, list1 (obj));
+}
+
+void
+maybe_type_error (Lisp_Object type, Lisp_Object class, Error_behavior errb,
+ const char *fmt, ...)
+{
+ Lisp_Object obj;
+ va_list args;
+
+ /* Optimization: */
+ if (ERRB_EQ (errb, ERROR_ME_NOT))
+ return;
+
+ va_start (args, fmt);
+ obj = emacs_doprnt_string_va ((const Bufbyte *) GETTEXT (fmt), Qnil, -1,
+ args);
+ va_end (args);
+
+ /* Fsignal GC-protects its args */
+ maybe_signal_error (type, list1 (obj), class, errb);
+}
+
+Lisp_Object
+continuable_type_error (Lisp_Object type, const char *fmt, ...)
+{
+ Lisp_Object obj;
+ va_list args;
+
+ va_start (args, fmt);
+ obj = emacs_doprnt_string_va ((const Bufbyte *) GETTEXT (fmt), Qnil, -1,
+ args);
+ va_end (args);
+
+ /* Fsignal GC-protects its args */
+ return Fsignal (type, list1 (obj));
+}
+
+Lisp_Object
+maybe_continuable_type_error (Lisp_Object type, Lisp_Object class,
+ Error_behavior errb, const char *fmt, ...)
+{
+ Lisp_Object obj;
+ va_list args;
+
+ /* Optimization: */
+ if (ERRB_EQ (errb, ERROR_ME_NOT))
+ return Qnil;
+
+ va_start (args, fmt);
+ obj = emacs_doprnt_string_va ((const Bufbyte *) GETTEXT (fmt), Qnil, -1,
+ args);
+ va_end (args);
+
+ /* Fsignal GC-protects its args */
+ return maybe_signal_continuable_error (type, list1 (obj), class, errb);
+}
+
+\f
+/****************** Error functions class 3 ******************/
+
+/* Class 3: Signal an error with a string and an associated object.
+ These functions signal an error of a specified type, whose data
+ is two objects, a string and a related Lisp object (usually the object
+ where the error is occurring). */
+
+DOESNT_RETURN
+signal_type_error (Lisp_Object type, const char *reason, Lisp_Object frob)
+{
+ if (UNBOUNDP (frob))
+ signal_error (type, list1 (build_translated_string (reason)));
+ else
+ signal_error (type, list2 (build_translated_string (reason), frob));
+}
+
+void
+maybe_signal_type_error (Lisp_Object type, const char *reason,
+ Lisp_Object frob, Lisp_Object class,
+ Error_behavior errb)
+{
+ /* Optimization: */
+ if (ERRB_EQ (errb, ERROR_ME_NOT))
+ return;
+ maybe_signal_error (type, list2 (build_translated_string (reason), frob),
+ class, errb);
+}
+
+Lisp_Object
+signal_type_continuable_error (Lisp_Object type, const char *reason,
+ Lisp_Object frob)
+{
+ return Fsignal (type, list2 (build_translated_string (reason), frob));
+}
+
+Lisp_Object
+maybe_signal_type_continuable_error (Lisp_Object type, const char *reason,
+ Lisp_Object frob, Lisp_Object class,
+ Error_behavior errb)
+{
+ /* Optimization: */
+ if (ERRB_EQ (errb, ERROR_ME_NOT))
+ return Qnil;
+ return maybe_signal_continuable_error
+ (type, list2 (build_translated_string (reason),
+ frob), class, errb);
+}
+
+\f
+/****************** Error functions class 4 ******************/
+
+/* Class 4: Printf-like functions that signal an error.
+ These functions signal an error of a specified type, whose data
+ is a two objects, a string (created using the arguments) and a
+ Lisp object.
+*/
+
+DOESNT_RETURN
+type_error_with_frob (Lisp_Object type, Lisp_Object frob, const char *fmt, ...)
+{
+ Lisp_Object obj;
+ va_list args;
+
+ va_start (args, fmt);
+ obj = emacs_doprnt_string_va ((const Bufbyte *) GETTEXT (fmt), Qnil, -1,
+ args);
+ va_end (args);
+
+ /* Fsignal GC-protects its args */
+ signal_error (type, list2 (obj, frob));
+}
+
+void
+maybe_type_error_with_frob (Lisp_Object type, Lisp_Object frob,
+ Lisp_Object class, Error_behavior errb,
+ const char *fmt, ...)
+{
+ Lisp_Object obj;
+ va_list args;
+
+ /* Optimization: */
+ if (ERRB_EQ (errb, ERROR_ME_NOT))
+ return;
+
+ va_start (args, fmt);
+ obj = emacs_doprnt_string_va ((const Bufbyte *) GETTEXT (fmt), Qnil, -1,
+ args);
+ va_end (args);
+
+ /* Fsignal GC-protects its args */
+ maybe_signal_error (type, list2 (obj, frob), class, errb);
+}
+
+Lisp_Object
+continuable_type_error_with_frob (Lisp_Object type, Lisp_Object frob,
+ const char *fmt, ...)
+{
+ Lisp_Object obj;
+ va_list args;
+
+ va_start (args, fmt);
+ obj = emacs_doprnt_string_va ((const Bufbyte *) GETTEXT (fmt), Qnil, -1,
+ args);
+ va_end (args);
+
+ /* Fsignal GC-protects its args */
+ return Fsignal (type, list2 (obj, frob));
+}
+
+Lisp_Object
+maybe_continuable_type_error_with_frob (Lisp_Object type, Lisp_Object frob,
+ Lisp_Object class, Error_behavior errb,
+ const char *fmt, ...)
+{
+ Lisp_Object obj;
+ va_list args;
+
+ /* Optimization: */
+ if (ERRB_EQ (errb, ERROR_ME_NOT))
+ return Qnil;
+
+ va_start (args, fmt);
+ obj = emacs_doprnt_string_va ((const Bufbyte *) GETTEXT (fmt), Qnil, -1,
+ args);
+ va_end (args);
+
+ /* Fsignal GC-protects its args */
+ return maybe_signal_continuable_error (type, list2 (obj, frob),
+ class, errb);
+}
+
+\f
+/****************** Error functions class 5 ******************/
+
+/* Class 5: Signal an error with a string and two associated objects.
+ These functions signal an error of a specified type, whose data
+ is three objects, a string and two related Lisp objects. */
+
+DOESNT_RETURN
+signal_type_error_2 (Lisp_Object type, const char *reason,
+ Lisp_Object frob0, Lisp_Object frob1)
+{
+ signal_error (type, list3 (build_translated_string (reason), frob0,
+ frob1));
+}
+
+void
+maybe_signal_type_error_2 (Lisp_Object type, const char *reason,
+ Lisp_Object frob0, Lisp_Object frob1,
+ Lisp_Object class, Error_behavior errb)
+{
+ /* Optimization: */
+ if (ERRB_EQ (errb, ERROR_ME_NOT))
+ return;
+ maybe_signal_error (type, list3 (build_translated_string (reason), frob0,
+ frob1), class, errb);
+}
+
+
+Lisp_Object
+signal_type_continuable_error_2 (Lisp_Object type, const char *reason,
+ Lisp_Object frob0, Lisp_Object frob1)
+{
+ return Fsignal (type, list3 (build_translated_string (reason), frob0,
+ frob1));
+}
+
+Lisp_Object
+maybe_signal_type_continuable_error_2 (Lisp_Object type, const char *reason,
+ Lisp_Object frob0, Lisp_Object frob1,
+ Lisp_Object class, Error_behavior errb)
+{
+ /* Optimization: */
+ if (ERRB_EQ (errb, ERROR_ME_NOT))
+ return Qnil;
+ return maybe_signal_continuable_error
+ (type, list3 (build_translated_string (reason), frob0,
+ frob1),
+ class, errb);
+}
+
+\f
+/****************** Simple error functions class 2 ******************/
+
+/* Simple class 2: Printf-like functions that signal an error.
These functions signal an error of type Qerror, whose data
is a single string, created using the arguments. */
}
\f
-/****************** Error functions class 3 ******************/
+/****************** Simple error functions class 3 ******************/
-/* Class 3: Signal an error with a string and an associated object.
+/* Simple class 3: Signal an error with a string and an associated object.
These functions signal an error of type Qerror, whose data
is two objects, a string and a related Lisp object (usually the object
where the error is occurring). */
}
\f
-/****************** Error functions class 4 ******************/
+/****************** Simple error functions class 4 ******************/
-/* Class 4: Printf-like functions that signal an error.
+/* Simple class 4: Printf-like functions that signal an error.
These functions signal an error of type Qerror, whose data
is a two objects, a string (created using the arguments) and a
Lisp object.
}
\f
-/****************** Error functions class 5 ******************/
+/****************** Simple error functions class 5 ******************/
-/* Class 5: Signal an error with a string and two associated objects.
+/* Simple class 5: Signal an error with a string and two associated objects.
These functions signal an error of type Qerror, whose data
is three objects, a string and two related Lisp objects. */
{
signal_error (Qcircular_property_list, list1 (list));
}
+
+DOESNT_RETURN
+syntax_error (const char *reason, Lisp_Object frob)
+{
+ signal_type_error (Qsyntax_error, reason, frob);
+}
+
+DOESNT_RETURN
+syntax_error_2 (const char *reason, Lisp_Object frob1, Lisp_Object frob2)
+{
+ signal_type_error_2 (Qsyntax_error, reason, frob1, frob2);
+}
+
+DOESNT_RETURN
+invalid_argument (const char *reason, Lisp_Object frob)
+{
+ signal_type_error (Qinvalid_argument, reason, frob);
+}
+
+DOESNT_RETURN
+invalid_argument_2 (const char *reason, Lisp_Object frob1, Lisp_Object frob2)
+{
+ signal_type_error_2 (Qinvalid_argument, reason, frob1, frob2);
+}
+
+DOESNT_RETURN
+invalid_operation (const char *reason, Lisp_Object frob)
+{
+ signal_type_error (Qinvalid_operation, reason, frob);
+}
+
+DOESNT_RETURN
+invalid_operation_2 (const char *reason, Lisp_Object frob1, Lisp_Object frob2)
+{
+ signal_type_error_2 (Qinvalid_operation, reason, frob1, frob2);
+}
+
+DOESNT_RETURN
+invalid_change (const char *reason, Lisp_Object frob)
+{
+ signal_type_error (Qinvalid_change, reason, frob);
+}
+
+DOESNT_RETURN
+invalid_change_2 (const char *reason, Lisp_Object frob1, Lisp_Object frob2)
+{
+ signal_type_error_2 (Qinvalid_change, reason, frob1, frob2);
+}
+
\f
/************************************************************************/
/* User commands */
gcpro1.nvars = 0;
{
- REGISTER Lisp_Object arg;
LIST_LOOP_2 (arg, original_args)
{
*p++ = Feval (arg);
gcpro1.nvars = 0;
{
- REGISTER Lisp_Object arg;
LIST_LOOP_2 (arg, original_args)
{
*p++ = Feval (arg);
gcpro1.nvars = 0;
{
- REGISTER Lisp_Object arg;
LIST_LOOP_2 (arg, original_args)
{
*p++ = Feval (arg);
gcpro1.nvars = 0;
{
- REGISTER Lisp_Object arg;
LIST_LOOP_2 (arg, original_args)
{
*p++ = Feval (arg);
if (SUBRP (function))
{
- return function_min_args_p ?
- Fsubr_min_args (function):
- Fsubr_max_args (function);
+ /* Using return with the ?: operator tickles a DEC CC compiler bug. */
+ if (function_min_args_p)
+ return Fsubr_min_args (function);
+ else
+ return Fsubr_max_args (function);
}
else if (COMPILED_FUNCTIONP (function))
{
}
else if (EQ (funcar, Qautoload))
{
+ struct gcpro gcpro1;
+
+ GCPRO1 (function);
do_autoload (function, orig_function);
+ UNGCPRO;
+ function = orig_function;
goto retry;
}
else if (EQ (funcar, Qlambda))
else
{
invalid_function:
- return signal_invalid_function_error (function);
+ return signal_invalid_function_error (orig_function);
}
{
int argcount = 0;
- Lisp_Object arg;
EXTERNAL_LIST_LOOP_2 (arg, arglist)
{
funcall_lambda (Lisp_Object fun, int nargs, Lisp_Object args[])
{
/* This function can GC */
- Lisp_Object symbol, arglist, body, tail;
+ Lisp_Object arglist, body, tail;
int speccount = specpdl_depth();
REGISTER int i = 0;
{
int optional = 0, rest = 0;
- EXTERNAL_LIST_LOOP_3 (symbol, arglist, tail)
+ EXTERNAL_LIST_LOOP_2 (symbol, arglist)
{
if (!SYMBOLP (symbol))
goto invalid_function;
specpdl = xnew_array (struct specbinding, specpdl_size);
/* XEmacs change: increase these values. */
max_specpdl_size = 3000;
- max_lisp_eval_depth = 500;
+ max_lisp_eval_depth = 1000;
#ifdef DEFEND_AGAINST_THROW_RECURSION
throw_level = 0;
#endif