annotate test/fact.c @ 7:e2c2c0fe0785

function type definition should be in global heap
author kono
date Fri, 14 Jan 2000 09:55:24 +0900
parents d35df41eac69
children 096559f07a70
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
1 #include "stdio.h"
d35df41eac69 Initial revision
kono
parents:
diff changeset
2
d35df41eac69 Initial revision
kono
parents:
diff changeset
3 int
d35df41eac69 Initial revision
kono
parents:
diff changeset
4 main(ac,av)
d35df41eac69 Initial revision
kono
parents:
diff changeset
5 int ac;
d35df41eac69 Initial revision
kono
parents:
diff changeset
6 char *av[];
d35df41eac69 Initial revision
kono
parents:
diff changeset
7 {
d35df41eac69 Initial revision
kono
parents:
diff changeset
8 int n;
d35df41eac69 Initial revision
kono
parents:
diff changeset
9 n = atoi(av[1]);
d35df41eac69 Initial revision
kono
parents:
diff changeset
10 goto factorial(n,1,n,print,return,environment);
d35df41eac69 Initial revision
kono
parents:
diff changeset
11 }
d35df41eac69 Initial revision
kono
parents:
diff changeset
12
d35df41eac69 Initial revision
kono
parents:
diff changeset
13 code print(n,result,orig,print,exit1,exit1env)
d35df41eac69 Initial revision
kono
parents:
diff changeset
14 int n,result,orig;
d35df41eac69 Initial revision
kono
parents:
diff changeset
15 code (*print)(),(*exit1)();
d35df41eac69 Initial revision
kono
parents:
diff changeset
16 void *exit1env;
d35df41eac69 Initial revision
kono
parents:
diff changeset
17 {
d35df41eac69 Initial revision
kono
parents:
diff changeset
18 printf("%d! = %d\n",n, result);
d35df41eac69 Initial revision
kono
parents:
diff changeset
19 goto (*exit1)(1),exit1env;
d35df41eac69 Initial revision
kono
parents:
diff changeset
20 }
d35df41eac69 Initial revision
kono
parents:
diff changeset
21
d35df41eac69 Initial revision
kono
parents:
diff changeset
22 code factorial(n,result,orig,print,exit1,exit1env)
d35df41eac69 Initial revision
kono
parents:
diff changeset
23 int n,result,orig;
d35df41eac69 Initial revision
kono
parents:
diff changeset
24 code (*print)();
d35df41eac69 Initial revision
kono
parents:
diff changeset
25 code (*exit1)();
d35df41eac69 Initial revision
kono
parents:
diff changeset
26 void *exit1env;
d35df41eac69 Initial revision
kono
parents:
diff changeset
27 {
d35df41eac69 Initial revision
kono
parents:
diff changeset
28 if (n<0) {
d35df41eac69 Initial revision
kono
parents:
diff changeset
29 printf("err %d!\n",n);
d35df41eac69 Initial revision
kono
parents:
diff changeset
30 goto (*exit1)(0),exit1env;
d35df41eac69 Initial revision
kono
parents:
diff changeset
31 }
d35df41eac69 Initial revision
kono
parents:
diff changeset
32 if (n==0)
7
e2c2c0fe0785 function type definition should be in global heap
kono
parents: 0
diff changeset
33 goto (*print)(n,result,orig,print,exit1,exit1env);
e2c2c0fe0785 function type definition should be in global heap
kono
parents: 0
diff changeset
34 /* goto print(n,result,orig,print,exit1,exit1env); */
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
35 else {
d35df41eac69 Initial revision
kono
parents:
diff changeset
36 result *= n;
d35df41eac69 Initial revision
kono
parents:
diff changeset
37 n--;
d35df41eac69 Initial revision
kono
parents:
diff changeset
38 goto factorial(n,result,orig,print,exit1,exit1env);
d35df41eac69 Initial revision
kono
parents:
diff changeset
39 }
d35df41eac69 Initial revision
kono
parents:
diff changeset
40 }