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.
36
object *oldlex = lex_env;
51
for(x = form; !endp(x); x = MMcdr(x)) {
56
/* Just !endp(x) is replaced by x != Cnil. */
57
for(x = form; x != Cnil; x = MMcdr(x)) {
65
use of VS in Fdo and FdoA:
70
start -> |-------| where each bt is a bind_temp:
72
|-------| | var | -- name of DO variable
73
: | spp | -- T if special
75
| btn | | aux | -- step-form or var (if no
76
|-------| step-form is given)
78
old_top-> |-------| If 'spp' != T, it is NIL during
79
initialization, and is the pointer to
80
(var value) in lexical environment
91
for (is = var_list; !endp(is); is = MMcdr(is)) {
93
if (type_of(x)==t_symbol)
94
{vs_push(x);vs_push(Cnil);vs_push(Cnil);vs_push(x);
101
if (type_of(x) != t_cons)
102
FEinvalid_form("The index, ~S, is illegal.", x);
107
if (endp(MMcdr(x))) {
119
FEerror("Too many forms to the index ~S.",
131
object *oldlex = lex_env;
133
struct bind_temp *start, *end, *bt;
134
object end_test, body;
136
bds_ptr old_bds_top = bds_top;
138
if (endp(arg) || endp(MMcdr(arg)))
139
FEtoo_few_argumentsF(arg);
140
if (endp(MMcadr(arg)))
141
FEinvalid_form("The DO end-test, ~S, is illegal.",
144
end_test = MMcaadr(arg);
145
result = MMcdadr(arg);
154
start = (struct bind_temp *) vs_top;
156
do_var_list(MMcar(arg));
157
end = (struct bind_temp *)vs_top;
158
body = let_bind(MMcddr(arg), start, end);
161
for (bt = start; bt < end; bt++)
162
if ((enum stype)bt->bt_var->s.s_stype != stp_ordinary)
164
else if (bt->bt_spp == Cnil)
165
bt->bt_spp = assoc_eq(bt->bt_var, lex_env[0]);
169
LOOP: /* the main loop */
172
if (vs_base[0] != Cnil) {
173
/* RESULT evaluation */
175
vs_base = vs_top = old_top;
181
result = MMcdr(result);
182
} while (!endp(result));
191
for (bt = start; bt<end; bt++) {
192
if (bt->bt_aux != bt->bt_var) {
193
eval_assign(bt->bt_init, bt->bt_aux);
196
for (bt = start; bt<end; bt++) {
197
if (bt->bt_aux != bt->bt_var)
198
if (bt->bt_spp == Ct)
199
bt->bt_var->s.s_dbind = bt->bt_init;
201
MMcadr(bt->bt_spp) = bt->bt_init;
206
bds_unwind(old_bds_top);
216
object *oldlex = lex_env;
218
struct bind_temp *start, *end, *bt;
219
object end_test, body;
221
bds_ptr old_bds_top = bds_top;
223
if (endp(arg) || endp(MMcdr(arg)))
224
FEtoo_few_argumentsF(arg);
225
if (endp(MMcadr(arg)))
226
FEinvalid_form("The DO* end-test, ~S, is illegal.",
229
end_test = MMcaadr(arg);
230
result = MMcdadr(arg);
239
start = (struct bind_temp *)vs_top;
240
do_var_list(MMcar(arg));
241
end = (struct bind_temp *)vs_top;
242
body = letA_bind(MMcddr(arg), start, end);
245
for (bt = start; bt < end; bt++)
246
if ((enum stype)bt->bt_var->s.s_stype != stp_ordinary)
248
else if (bt->bt_spp == Cnil)
249
bt->bt_spp = assoc_eq(bt->bt_var, lex_env[0]);
253
LOOP: /* the main loop */
255
if (vs_base[0] != Cnil) {
256
/* RESULT evaluation */
258
vs_base = vs_top = old_top;
264
result = MMcdr(result);
265
} while (!endp(result));
274
for (bt = start; bt < end; bt++)
275
if (bt->bt_aux != bt->bt_var) {
276
if (bt->bt_spp == Ct) {
277
eval_assign(bt->bt_var->s.s_dbind, bt->bt_aux);
279
eval_assign(MMcadr(bt->bt_spp), bt->bt_aux);
285
bds_unwind(old_bds_top);
295
object *oldlex = lex_env;
297
struct bind_temp *start;
298
object x, listform, body;
300
bds_ptr old_bds_top = bds_top;
303
FEtoo_few_argumentsF(arg);
307
FEerror("No variable.", 0);
308
start = (struct bind_temp *)vs_top;
315
FEerror("No listform.", 0);
323
FEerror("Too many resultforms.", 0);
333
eval_assign(start->bt_init, listform);
334
body = find_special(MMcdr(arg), start, start+1);
336
bind_var(start->bt_var, Cnil, start->bt_spp);
337
if ((enum stype)start->bt_var->s.s_stype != stp_ordinary)
339
else if (start->bt_spp == Cnil)
340
start->bt_spp = assoc_eq(start->bt_var, lex_env[0]);
344
LOOP: /* the main loop */
345
if (endp(start->bt_init)) {
346
if (start->bt_spp == Ct)
347
start->bt_var->s.s_dbind = Cnil;
349
MMcadr(start->bt_spp) = Cnil;
354
if (start->bt_spp == Ct)
355
start->bt_var->s.s_dbind = MMcar(start->bt_init);
357
MMcadr(start->bt_spp) = MMcar(start->bt_init);
358
start->bt_init = MMcdr(start->bt_init);
367
bds_unwind(old_bds_top);
377
object *oldlex = lex_env;
379
struct bind_temp *start;
380
object x, countform, body;
382
bds_ptr old_bds_top = bds_top;
385
FEtoo_few_argumentsF(arg);
389
FEerror("No variable.", 0);
390
start = (struct bind_temp *)vs_top;
397
FEerror("No countform.", 0);
398
countform = MMcar(x);
405
FEerror("Too many resultforms.", 0);
415
eval_assign(start->bt_init, countform);
416
if (type_of(start->bt_init) != t_fixnum &&
417
type_of(start->bt_init) != t_bignum)
418
FEwrong_type_argument(sLinteger, start->bt_init);
419
body = find_special(MMcdr(arg), start, start+1);
421
bind_var(start->bt_var, make_fixnum(0), start->bt_spp);
422
if ((enum stype)start->bt_var->s.s_stype != stp_ordinary) {
424
x = start->bt_var->s.s_dbind;
425
} else if (start->bt_spp == Cnil) {
426
start->bt_spp = assoc_eq(start->bt_var, lex_env[0]);
427
x = MMcadr(start->bt_spp);
429
x = start->bt_var->s.s_dbind;
433
LOOP: /* the main loop */
434
if (number_compare(x, start->bt_init) >= 0) {
443
if (start->bt_spp == Ct)
444
x = start->bt_var->s.s_dbind = one_plus(x);
446
x = MMcadr(start->bt_spp) = one_plus(x);
451
bds_unwind(old_bds_top);
458
make_special_form("LOOP", Floop);
459
make_special_form("DO", Fdo);
460
make_special_form("DO*", FdoA);
461
make_special_form("DOLIST", Fdolist);
462
make_special_form("DOTIMES", Fdotimes);