Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 50 lines (38 sloc) 0.726 kb
02d1d62 Initial revision
Arnar Mar Hrafnkelsson authored
1 #include "stackmach.h"
2
3 double
b33c08f hide or rename any symbols that are likely to conflict with other
Tony Cook authored
4 i_op_run(int codes[], size_t code_size, double parms[], size_t parm_size) {
02d1d62 Initial revision
Arnar Mar Hrafnkelsson authored
5 double stack[100];
6 double *sp = stack;
7
8 while (code_size) {
9 switch (*codes++) {
10 case bcAdd:
11 sp[-2] += sp[-1];
12 --sp;
13 break;
14
15 case bcSubtract:
16 sp[-2] -= sp[-1];
17 --sp;
18 break;
19
20 case bcDiv:
21 sp[-2] /= sp[-1];
22 --sp;
23 break;
24
25 case bcMult:
26 sp[-2] *= sp[-1];
27 --sp;
28 break;
29
30 case bcParm:
31 *sp++ = parms[*codes++];
32 --code_size;
33 break;
34
35 case bcSin:
36 sp[-1] = sin(sp[-1]);
37 break;
38
39 case bcCos:
40 sp[-1] = cos(sp[-1]);
41 break;
42
43 }
44 --code_size;
45 }
46
47 return sp[-1];
48 }
49
Something went wrong with that request. Please try again.