-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfor.cpp
64 lines (47 loc) · 796 Bytes
/
for.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
// 'for' function
#include "stdafx.h"
#include "defs.h"
#define A p3
#define B p4
#define I p5
#define X p6
void
eval_for(void)
{
int i, j, k;
// 1st arg (quoted)
X = cadr(p1);
if (!issymbol(X))
stop("for: 1st arg?");
// 2nd arg
push(caddr(p1));
eval();
j = pop_integer();
if (j == (int) 0x80000000)
stop("for: 2nd arg?");
// 3rd arg
push(cadddr(p1));
eval();
k = pop_integer();
if (k == (int) 0x80000000)
stop("for: 3rd arg?");
// remaining args
p1 = cddddr(p1);
B = get_binding(X);
A = get_arglist(X);
for (i = j; i <= k; i++) {
push_integer(i);
I = pop();
set_binding(X, I);
p2 = p1;
while (iscons(p2)) {
push(car(p2));
eval();
pop();
p2 = cdr(p2);
}
}
set_binding_and_arglist(X, B, A);
// return value
push_symbol(NIL);
}