2008-08-10 03:01:00 +02:00
|
|
|
// 'sum' function
|
2006-10-06 20:28:26 +02:00
|
|
|
|
|
|
|
#include "stdafx.h"
|
|
|
|
#include "defs.h"
|
2004-03-03 21:24:06 +01:00
|
|
|
|
2008-08-10 03:01:00 +02:00
|
|
|
#define A p3
|
|
|
|
#define B p4
|
|
|
|
#define I p5
|
|
|
|
#define X p6
|
|
|
|
|
2004-03-03 21:24:06 +01:00
|
|
|
void
|
|
|
|
eval_sum(void)
|
|
|
|
{
|
2008-08-10 03:01:00 +02:00
|
|
|
int i, j, k;
|
2004-03-03 21:24:06 +01:00
|
|
|
|
2008-08-10 03:01:00 +02:00
|
|
|
// 1st arg (quoted)
|
2006-10-06 20:28:26 +02:00
|
|
|
|
2008-08-10 03:01:00 +02:00
|
|
|
X = cadr(p1);
|
2008-08-15 07:34:58 +02:00
|
|
|
if (!issymbol(X))
|
|
|
|
stop("sum: 1st arg?");
|
2004-03-03 21:24:06 +01:00
|
|
|
|
2008-08-10 03:01:00 +02:00
|
|
|
// 2nd arg
|
2004-03-03 21:24:06 +01:00
|
|
|
|
2008-08-10 03:01:00 +02:00
|
|
|
push(caddr(p1));
|
|
|
|
eval();
|
|
|
|
j = pop_integer();
|
2004-03-03 21:24:06 +01:00
|
|
|
if (j == (int) 0x80000000)
|
2008-08-10 03:01:00 +02:00
|
|
|
stop("sum: 2nd arg?");
|
|
|
|
|
|
|
|
// 3rd arg
|
2004-03-03 21:24:06 +01:00
|
|
|
|
2008-08-10 03:01:00 +02:00
|
|
|
push(cadddr(p1));
|
|
|
|
eval();
|
|
|
|
k = pop_integer();
|
2004-03-03 21:24:06 +01:00
|
|
|
if (k == (int) 0x80000000)
|
2008-08-10 03:01:00 +02:00
|
|
|
stop("sum: 3rd arg?");
|
|
|
|
|
|
|
|
// 4th arg
|
|
|
|
|
|
|
|
p1 = caddddr(p1);
|
2004-03-03 21:24:06 +01:00
|
|
|
|
2008-08-10 03:01:00 +02:00
|
|
|
B = get_binding(X);
|
|
|
|
A = get_arglist(X);
|
|
|
|
|
|
|
|
push_integer(0);
|
2004-03-03 21:24:06 +01:00
|
|
|
|
|
|
|
for (i = j; i <= k; i++) {
|
|
|
|
push_integer(i);
|
2008-08-10 03:01:00 +02:00
|
|
|
I = pop();
|
|
|
|
set_binding(X, I);
|
|
|
|
push(p1);
|
2006-10-06 20:28:26 +02:00
|
|
|
eval();
|
2008-08-10 03:01:00 +02:00
|
|
|
add();
|
2004-03-03 21:24:06 +01:00
|
|
|
}
|
2006-10-06 20:28:26 +02:00
|
|
|
|
2008-08-10 03:01:00 +02:00
|
|
|
set_binding_and_arglist(X, B, A);
|
2004-03-03 21:24:06 +01:00
|
|
|
}
|