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.
43
object sLfill_pointer;
53
object sSstructure_access;
58
object sSclear_compiler_properties;
62
object sSAinhibit_macro_specialA;
65
setq(object sym, object val)
70
if(type_of(sym) != t_symbol)
72
type = (enum stype)sym->s.s_stype;
73
if(type == stp_special)
76
if (type == stp_constant)
77
FEinvalid_variable("Cannot assign to the constant ~S.", sym);
79
vd = lex_var_sch(sym);
80
if(MMnull(vd) || endp(MMcdr(vd)))
88
FFN(Fsetq)(object form)
98
if (endp(MMcdr(form)))
99
FEinvalid_form("No value for ~S.", form->c.c_car);
100
setq(MMcar(form),ans=Ieval(MMcadr(form)));
102
} while (!endp(form));
110
FFN(Fpsetq)(object arg)
112
object *old_top = vs_top;
115
for (top = old_top; !endp(arg); arg = MMcddr(arg), top++) {
117
FEinvalid_form("No value for ~S.", arg->c.c_car);
119
top[0] = Ieval(MMcadr(arg));
122
for (arg = argsv, top = old_top; !endp(arg); arg = MMcddr(arg), top++)
123
setq(MMcar(arg),top[0]);
124
vs_base = vs_top = old_top;
128
DEFUNO_NEW("SET",object,fLset,LISP
129
,2,2,NONE,OO,OO,OO,OO,void,Lset,(object symbol,object value),"")
133
if (type_of(symbol) != t_symbol)
134
not_a_symbol(symbol);
135
if ((enum stype)symbol->s.s_stype == stp_constant)
136
FEinvalid_variable("Cannot assign to the constant ~S.",
138
symbol->s.s_dbind = value;
142
DEFUNO_NEW("FSET",object,fSfset,SI
143
,2,2,NONE,OO,OO,OO,OO,void,siLfset,(object sym,object function),"")
147
if (type_of(sym) != t_symbol) {
148
if (setf_fn_form(sym)) {
149
putprop(MMcadr(sym),function,sSsetf_function);
154
if (sym->s.s_sfdef != NOT_SPECIAL) {
155
if (sym->s.s_mflag) {
156
if (symbol_value(sSAinhibit_macro_specialA) != Cnil)
157
sym->s.s_sfdef = NOT_SPECIAL;
158
} else if (symbol_value(sSAinhibit_macro_specialA) != Cnil)
159
FEerror("~S, a special form, cannot be redefined.",
162
sym = clear_compiler_properties(sym,function);
163
if (sym->s.s_hpack == lisp_package &&
164
sym->s.s_gfdef != OBJNULL && initflag) {
165
ifuncall2(sLwarn,make_simple_string("~S is being redefined."),
168
if (type_of(function) == t_cfun ||
169
type_of(function) == t_sfun ||
170
type_of(function) == t_vfun ||
171
type_of(function) == t_gfun ||
172
type_of(function) == t_cclosure||
173
type_of(function) == t_closure ||
174
type_of(function) == t_afun
176
sym->s.s_gfdef = function;
177
sym->s.s_mflag = FALSE;
178
} else if (car(function) == sLspecial)
179
FEerror("Cannot define a special form.", 0);
180
else if (function->c.c_car == sLmacro) {
181
sym->s.s_gfdef = function->c.c_cdr;
182
sym->s.s_mflag = TRUE;
184
sym->s.s_gfdef = function;
185
sym->s.s_mflag = FALSE;
190
#ifdef STATIC_FUNCTION_POINTERS
192
fSfset(object sym,object function) {
193
return FFN(fSfset)(sym,function);
198
FFN(Fmultiple_value_setq)(object form)
203
if (endp(form) || endp(form->c.c_cdr) ||
204
!endp(form->c.c_cdr->c.c_cdr))
205
FEinvalid_form("~S is an illegal argument to MULTIPLE-VALUE-SETQ",
207
vars = form->c.c_car;
209
fcall.values[0]=Ieval(form->c.c_cdr->c.c_car);
212
for (i = 0; !endp(vars); i++, vars = vars->c.c_cdr)
214
setq(vars->c.c_car, fcall.values[i]);
216
setq(vars->c.c_car, Cnil);
217
vs_base[0]=fcall.values[0];
221
DEFUNO_NEW("MAKUNBOUND",object,fLmakunbound,LISP
222
,1,1,NONE,OO,OO,OO,OO,void,Lmakunbound,(object sym),"")
226
if (type_of(sym) != t_symbol)
228
if ((enum stype)sym->s.s_stype == stp_constant)
229
FEinvalid_variable("Cannot unbind the constant ~S.",
231
sym->s.s_dbind = OBJNULL;
237
DEFUNO_NEW("FMAKUNBOUND",object,fLfmakunbound,LISP
238
,1,1,NONE,OO,OO,OO,OO,void,Lfmakunbound,(object sym),"")
242
if(type_of(sym) != t_symbol)
244
if (sym->s.s_sfdef != NOT_SPECIAL) {
245
if (sym->s.s_mflag) {
246
if (symbol_value(sSAinhibit_macro_specialA) != Cnil)
247
sym->s.s_sfdef = NOT_SPECIAL;
248
} else if (symbol_value(sSAinhibit_macro_specialA) != Cnil)
249
FEerror("~S, a special form, cannot be redefined.",
252
remf(&(sym->s.s_plist),sStraced);
253
clear_compiler_properties(sym,Cnil);
254
if (sym->s.s_hpack == lisp_package &&
255
sym->s.s_gfdef != OBJNULL && initflag) {
256
ifuncall2(sLwarn, make_simple_string(
257
"~S is being redefined."), sym);
259
sym->s.s_gfdef = OBJNULL;
260
sym->s.s_mflag = FALSE;
265
FFN(Fsetf)(object form)
267
object result,*t,*t1;
272
object *top = vs_top;
275
if (endp(MMcdr(form)))
276
FEinvalid_form("No value for ~S.", form->c.c_car);
277
result = setf(MMcar(form), MMcadr(form));
279
} while (!endp(form));
282
vs_top = vs_base = top;
289
#define eval_push(form) \
291
object *old_top = vs_top; \
293
*old_top = Ieval(form); \
294
vs_top = old_top + 1; \
298
setf(object place, object form)
306
/* extern void siLaset(void); */
307
/* extern void siLsvset(void); */
308
extern void siLelt_set();
309
extern void siLchar_set();
310
/* extern void siLfill_pointer_set(void); */
311
extern void siLhash_set();
313
if (type_of(place) != t_cons) {
314
setq(place, result=Ieval(form));
318
fun = place->c.c_car;
319
if (type_of(fun) != t_symbol)
321
args = place->c.c_cdr;
324
sym = Ieval(car(args));
326
return (putprop(sym,val,Ieval(car(Mcdr(args)))));
330
if (fun == sLaref) { f = siLaset; goto EVAL; }
331
if (fun == sLsvref) { f = siLsvset; goto EVAL; }
332
if (fun == sLelt) { f = siLelt_set; goto EVAL; }
333
if (fun == sLchar) { f = siLchar_set; goto EVAL; }
334
if (fun == sLschar) { f = siLchar_set; goto EVAL; }
335
if (fun == sLfill_pointer) { f = siLfill_pointer_set; goto EVAL; }
336
if (fun == sLgethash) { f = siLhash_set; goto EVAL; }
338
x = Ieval(Mcar(args));
339
result = Ieval(form);
340
if (type_of(x) != t_cons)
341
FEerror("~S is not a cons.", 1, x);
346
x = Ieval(Mcar(args));
347
result = Ieval(form);
348
if (type_of(x) != t_cons)
349
FEerror("~S is not a cons.", 1, x);
354
/* FIXME should this be removed as it appears to usurp setf-expanders? */
355
if ((x=getf(fun->s.s_plist,sSsetf_function,Cnil))!=Cnil) {
357
/* FIXME do a direct funcall here */
358
y=append(list(1,form),y);
360
y=MMcons(sLfuncall,y);
365
x = getf(fun->s.s_plist, sSstructure_access, Cnil);
366
if (x == Cnil || type_of(x) != t_cons)
368
if (getf(fun->s.s_plist, sSsetf_lambda, Cnil) == Cnil)
370
if (type_of(x->c.c_cdr) != t_fixnum)
378
y = Ieval(Mcar(args));
379
result = Ieval(form);
381
if (type_of(y) != t_vector || i >= y->v.v_fillp)
383
y->v.v_self[i] = result;
384
} else if (x == sLlist) {
385
for (x = y; i > 0; --i)
387
if (type_of(x) != t_cons)
391
structure_set(y, x, i, result);
396
for (; !endp(args); args = args->c.c_cdr) {
397
eval_push(args->c.c_car);
415
#define VS_PUSH_ENV \
417
vs_push(list(3,lex_env[0],lex_env[1],lex_env[2]));} \
418
else {vs_push(Cnil);}
421
if (!sLsetf->s.s_mflag || sLsetf->s.s_gfdef == OBJNULL)
422
FEerror("Where is SETF?", 0);
423
funcall(sLsetf->s.s_gfdef);
424
return Ieval(vs_base[0]);
428
FFN(Fpush)(object form)
432
if (endp(form) || endp(MMcdr(form)))
433
FEtoo_few_argumentsF(form);
434
if (!endp(MMcddr(form)))
435
FEtoo_many_argumentsF(form);
437
if (type_of(var) != t_cons) {
441
vs_base[0] = MMcons(form, vs_base[0]);
442
setq(var, vs_base[0]);
452
if (!sLpush->s.s_mflag || sLpush->s.s_gfdef == OBJNULL)
453
FEerror("Where is PUSH?", 0);
454
funcall(sLpush->s.s_gfdef);
459
FFN(Fpop)(object form)
464
FEtoo_few_argumentsF(form);
465
if (!endp(MMcdr(form)))
466
FEtoo_many_argumentsF(form);
468
if (type_of(var) != t_cons) {
470
setq(var, cdr(vs_base[0]));
471
vs_base[0] = car(vs_base[0]);
481
if (!sLpop->s.s_mflag || sLpop->s.s_gfdef == OBJNULL)
482
FEerror("Where is POP?", 0);
483
funcall(sLpop->s.s_gfdef);
488
FFN(Fincf)(object form)
491
object one_plus(object x), number_plus(object x, object y);
494
FEtoo_few_argumentsF(form);
495
if (!endp(MMcdr(form)) && !endp(MMcddr(form)))
496
FEtoo_many_argumentsF(form);
498
if (type_of(var) != t_cons) {
499
if (endp(MMcdr(form))) {
501
vs_base[0] = one_plus(vs_base[0]);
502
setq(var, vs_base[0]);
508
vs_base[0] = number_plus(vs_base[0], form);
509
setq(var, vs_base[0]);
519
if (!sLincf->s.s_mflag || sLincf->s.s_gfdef == OBJNULL)
520
FEerror("Where is INCF?", 0);
521
funcall(sLincf->s.s_gfdef);
526
FFN(Fdecf)(object form)
529
object one_minus(object x), number_minus(object x, object y);
532
FEtoo_few_argumentsF(form);
533
if (!endp(MMcdr(form)) && !endp(MMcddr(form)))
534
FEtoo_many_argumentsF(form);
536
if (type_of(var) != t_cons) {
537
if (endp(MMcdr(form))) {
539
vs_base[0] = one_minus(vs_base[0]);
540
setq(var, vs_base[0]);
546
vs_base[0] = number_minus(vs_base[0], form);
547
setq(var, vs_base[0]);
557
if (!sLdecf->s.s_mflag || sLdecf->s.s_gfdef == OBJNULL)
558
FEerror("Where is DECF?", 0);
559
funcall(sLdecf->s.s_gfdef);
565
/* clear_compiler_properties(object sym, object code) */
567
/* VFUN_NARGS=2; fSuse_fast_links(Cnil,sym); */
568
/* tem = getf(sym->s.s_plist,sStraced,Cnil); */
569
/* if (sSAinhibit_macro_specialA && sSAinhibit_macro_specialA->s.s_dbind != Cnil) */
570
/* (void)ifuncall2(sSclear_compiler_properties, sym,code); */
571
/* if (tem != Cnil) return tem; */
576
DEF_ORDINARY("CLEAR-COMPILER-PROPERTIES",sSclear_compiler_properties,SI,"");
578
DEFUN_NEW("CLEAR-COMPILER-PROPERTIES",object,fSclear_compiler_properties,SI
579
,2,2,NONE,OO,OO,OO,OO,(object x0,object x1),"")
586
DEF_ORDINARY("AREF",sLaref,LISP,"");
587
DEF_ORDINARY("CAR",sLcar,LISP,"");
588
DEF_ORDINARY("CDR",sLcdr,LISP,"");
589
DEF_ORDINARY("CHAR",sLchar,LISP,"");
590
DEF_ORDINARY("DECF",sLdecf,LISP,"");
591
DEF_ORDINARY("ELT",sLelt,LISP,"");
592
DEF_ORDINARY("FILL-POINTER",sLfill_pointer,LISP,"");
593
DEF_ORDINARY("GET",sLget,LISP,"");
594
DEF_ORDINARY("GETF",sLgetf,LISP,"");
595
DEF_ORDINARY("GETHASH",sLgethash,LISP,"");
596
DEF_ORDINARY("INCF",sLincf,LISP,"");
597
DEF_ORDINARY("POP",sLpop,LISP,"");
598
DEF_ORDINARY("PUSH",sLpush,LISP,"");
599
DEF_ORDINARY("SCHAR",sLschar,LISP,"");
600
DEF_ORDINARY("SETF",sLsetf,LISP,"");
601
DEF_ORDINARY("SETF-LAMBDA",sSsetf_lambda,SI,"");
602
DEF_ORDINARY("STRUCTURE-ACCESS",sSstructure_access,SI,"");
603
DEF_ORDINARY("SVREF",sLsvref,LISP,"");
604
DEF_ORDINARY("TRACED",sStraced,SI,"");
605
DEF_ORDINARY("VECTOR",sLvector,LISP,"");
608
gcl_init_assignment(void)
610
make_special_form("SETQ", Fsetq);
611
make_special_form("PSETQ", Fpsetq);
612
make_special_form("MULTIPLE-VALUE-SETQ", Fmultiple_value_setq);
613
sLsetf=make_special_form("SETF", Fsetf);
614
sLpush=make_special_form("PUSH", Fpush);
615
sLpop=make_special_form("POP", Fpop);
616
sLincf=make_special_form("INCF", Fincf);
617
sLdecf=make_special_form("DECF", Fdecf);