2
Copyright (C) 1994 M. Hagiya, W. Schelter, T. Yuasa
4
This file is part of GNU Common Lisp, herein referred to as GCL
6
GCL is free software; you can redistribute it and/or modify it under
7
the terms of the GNU LIBRARY GENERAL PUBLIC LICENSE as published by
8
the Free Software Foundation; either version 2, or (at your option)
11
GCL is distributed in the hope that it will be useful, but WITHOUT
12
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13
FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
14
License for more details.
16
You should have received a copy of the GNU Library General Public License
17
along with GCL; see the file COPYING. If not, write to the Free Software
18
Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
26
Top-Level Forms and Declarations
31
object sLcompile, sLload, sLeval, sKcompile_toplevel, sLload_toplevel, sKexecute;
37
object sSAinhibit_macro_specialA;
42
FFN(Fdefun)(object args)
48
if (endp(args) || endp(MMcdr(args)))
49
FEtoo_few_argumentsF(args);
50
if (MMcadr(args) != Cnil && type_of(MMcadr(args)) != t_cons)
51
FEerror("~S is an illegal lambda-list.", 1, MMcadr(args));
53
if (type_of(name) != t_symbol) {
54
if (setf_fn_form(name)) {
56
vs_push(MMcons(sLlambda, MMcdr(args)));
57
putprop(MMcadr(name),vs_base[0],sSsetf_function);
63
if (name->s.s_sfdef != NOT_SPECIAL) {
64
if (name->s.s_mflag) {
65
if (symbol_value(sSAinhibit_macro_specialA) != Cnil)
66
name->s.s_sfdef = NOT_SPECIAL;
67
} else if (symbol_value(sSAinhibit_macro_specialA) != Cnil)
68
FEerror("~S, a special form, cannot be redefined.", 1, name);
70
if (name->s.s_hpack == lisp_package &&
71
name->s.s_gfdef != OBJNULL && initflag) {
72
vs_push(make_simple_string(
73
"~S is being redefined."));
74
ifuncall2(sLwarn, vs_head, name);
78
if (lex_env[0] == Cnil && lex_env[1] == Cnil && lex_env[2] == Cnil) {
79
vs_push(MMcons(sLlambda_block, args));
81
vs_push(MMcons(lex_env[2], args));
82
vs_base[0] = MMcons(lex_env[1], vs_base[0]);
83
vs_base[0] = MMcons(lex_env[0], vs_base[0]);
84
vs_base[0] = MMcons(sLlambda_block_closure, vs_base[0]);
86
{object fname = clear_compiler_properties(name,vs_base[0]);
87
fname->s.s_gfdef = vs_base[0];
88
fname->s.s_mflag = FALSE;}
90
for (body = MMcddr(args); !endp(body); body = body->c.c_cdr) {
91
form = macro_expand(body->c.c_car);
92
if (type_of(form) == t_string) {
93
if (endp(body->c.c_cdr))
99
sSfunction_documentation);
103
if (type_of(form) != t_cons || form->c.c_car != sLdeclare)
109
FFN(siLAmake_special)(void)
112
check_type_symbol(&vs_base[0]);
113
if ((enum stype)vs_base[0]->s.s_stype == stp_constant)
114
FEerror("~S is a constant.", 1, vs_base[0]);
115
vs_base[0]->s.s_stype = (short)stp_special;
119
FFN(siLAmake_constant)(void)
122
check_type_symbol(&vs_base[0]);
123
if ((enum stype)vs_base[0]->s.s_stype == stp_special)
125
"The argument ~S to DEFCONSTANT is a special variable.",
127
vs_base[0]->s.s_stype = (short)stp_constant;
128
vs_base[0]->s.s_dbind = vs_base[1];
133
FFN(Feval_when)(object arg)
136
object *base = vs_base;
141
FEtoo_few_argumentsF(arg);
142
for (ss = MMcar(arg); !endp(ss); ss = MMcdr(ss))
143
if ( (MMcar(ss) == sLeval) || (MMcar(ss) == sKexecute) )
145
else if ( MMcar(ss) != sLload && MMcar(ss) != sLcompile &&
146
MMcar(ss) != sLload_toplevel && MMcar(ss) != sKcompile_toplevel )
147
FEinvalid_form("~S is an undefined situation for EVAL-WHEN.",
150
vs_push(make_cons(sLprogn, MMcdr(arg)));
160
FFN(Fdeclare)(object arg)
162
FEerror("DECLARE appeared in an invalid position.", 0);
166
FFN(Flocally)(object body)
168
object *oldlex = lex_env;
171
body = find_special(body, NULL, NULL);
178
FFN(Fthe)(object args)
183
if(endp(args) || endp(MMcdr(args)))
184
FEtoo_few_argumentsF(args);
185
if(!endp(MMcddr(args)))
186
FEtoo_many_argumentsF(args);
189
if (type_of(args) == t_cons && MMcar(args) == sLvalues) {
191
for (args=MMcdr(args); !endp(args) && vs<vs_top; args=MMcdr(args), vs++)
192
/* { if (vs >= vs_top)
193
FEerror("Too many return values.", 0);*/
194
if (ifuncall2(sLtypep, *vs, MMcar(args)) == Cnil)
195
FEwrong_type_argument(MMcar(args), *vs);
198
FEerror("Too few return values.", 0);*/
199
for (args=MMcdr(args); !endp(args); args=MMcdr(args))
200
if (ifuncall2(sLtypep, Cnil, MMcar(args)) == Cnil)
201
FEwrong_type_argument(MMcar(args), Cnil);
204
if (ifuncall2(sLtypep, vs_base[0], args) == Cnil)
205
FEwrong_type_argument(args, vs_base[0]);
209
DEF_ORDINARY("COMPILE",sLcompile,LISP,"");
210
DEF_ORDINARY("COMPILE-TOPLEVEL",sKcompile_toplevel,KEYWORD,"");
211
DEF_ORDINARY("DECLARE",sLdeclare,LISP,"");
212
DEF_ORDINARY("EVAL",sLeval,LISP,"");
213
DEF_ORDINARY("EXECUTE",sKexecute,KEYWORD,"");
214
DEF_ORDINARY("FUNCTION-DOCUMENTATION",sSfunction_documentation,SI,"");
215
DEF_ORDINARY("LOAD",sLload,LISP,"");
216
DEF_ORDINARY("LOAD-TOPLEVEL",sLload_toplevel,KEYWORD,"");
217
DEF_ORDINARY("PROGN",sLprogn,LISP,"");
218
DEF_ORDINARY("TYPEP",sLtypep,LISP,"");
219
DEF_ORDINARY("VALUES",sLvalues,LISP,"");
220
DEF_ORDINARY("VARIABLE-DOCUMENTATION",sSvariable_documentation,SI,"");
221
DEF_ORDINARY("SETF-FUNCTION",sSsetf_function,SI,"");
222
DEF_ORDINARY("WARN",sLwarn,LISP,"");
225
gcl_init_toplevel(void)
227
make_special_form("DEFUN",Fdefun);
228
make_si_function("*MAKE-SPECIAL", siLAmake_special);
229
make_si_function("*MAKE-CONSTANT", siLAmake_constant);
230
make_special_form("EVAL-WHEN", Feval_when);
231
make_special_form("THE", Fthe);
232
sLdeclare=make_special_form("DECLARE",Fdeclare);
233
make_special_form("LOCALLY",Flocally);