annotate test/test1.c @ 691:25115b50d033

*** empty log message ***
author kono
date Wed, 10 Oct 2007 17:58:15 +0900
parents 682c8ec38d45
children 6b7372e17970
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
449
c55363eff5e5 parallel assignment (modify not completed)
kono
parents: 427
diff changeset
1 /*
622
682c8ec38d45 _code へ
kono
parents: 573
diff changeset
2 test for CbC converted __code from C
449
c55363eff5e5 parallel assignment (modify not completed)
kono
parents: 427
diff changeset
3 */
c55363eff5e5 parallel assignment (modify not completed)
kono
parents: 427
diff changeset
4
17
fdbf2fbc8140 *** empty log message ***
kono
parents:
diff changeset
5 #include "stdio.h"
fdbf2fbc8140 *** empty log message ***
kono
parents:
diff changeset
6
172
096559f07a70 some check
kono
parents: 17
diff changeset
7 typedef void *stack;
17
fdbf2fbc8140 *** empty log message ***
kono
parents:
diff changeset
8
449
c55363eff5e5 parallel assignment (modify not completed)
kono
parents: 427
diff changeset
9 void *stack0; /* size of void* == 1 */
c55363eff5e5 parallel assignment (modify not completed)
kono
parents: 427
diff changeset
10
172
096559f07a70 some check
kono
parents: 17
diff changeset
11 struct cont_save { /* General Return Continuation */
622
682c8ec38d45 _code へ
kono
parents: 573
diff changeset
12 __code (*ret)();
172
096559f07a70 some check
kono
parents: 17
diff changeset
13 };
17
fdbf2fbc8140 *** empty log message ***
kono
parents:
diff changeset
14
fdbf2fbc8140 *** empty log message ***
kono
parents:
diff changeset
15 /*
622
682c8ec38d45 _code へ
kono
parents: 573
diff changeset
16 __code g(int,void *);
682c8ec38d45 _code へ
kono
parents: 573
diff changeset
17 __code f_g0(int ,int ,void *);
682c8ec38d45 _code へ
kono
parents: 573
diff changeset
18 __code f_g1(int,void *);
172
096559f07a70 some check
kono
parents: 17
diff changeset
19 */
17
fdbf2fbc8140 *** empty log message ***
kono
parents:
diff changeset
20
172
096559f07a70 some check
kono
parents: 17
diff changeset
21 struct f_g0_save { /* Specialized Return Continuation */
622
682c8ec38d45 _code へ
kono
parents: 573
diff changeset
22 __code (*ret)();
172
096559f07a70 some check
kono
parents: 17
diff changeset
23 int ii,kk,jj;
096559f07a70 some check
kono
parents: 17
diff changeset
24 };
17
fdbf2fbc8140 *** empty log message ***
kono
parents:
diff changeset
25
622
682c8ec38d45 _code へ
kono
parents: 573
diff changeset
26 __code g(int i,void *sp) {
172
096559f07a70 some check
kono
parents: 17
diff changeset
27 goto (* ((struct cont_save *)sp)->ret)(i+4,sp);
096559f07a70 some check
kono
parents: 17
diff changeset
28 }
17
fdbf2fbc8140 *** empty log message ***
kono
parents:
diff changeset
29
622
682c8ec38d45 _code へ
kono
parents: 573
diff changeset
30 __code f_g1(int j,void *sp) { /* Continuation */
172
096559f07a70 some check
kono
parents: 17
diff changeset
31 int k;
096559f07a70 some check
kono
parents: 17
diff changeset
32 struct f_g0_save *c;
17
fdbf2fbc8140 *** empty log message ***
kono
parents:
diff changeset
33
172
096559f07a70 some check
kono
parents: 17
diff changeset
34 c = sp;
096559f07a70 some check
kono
parents: 17
diff changeset
35 k = c->kk;
096559f07a70 some check
kono
parents: 17
diff changeset
36 sp += sizeof(struct f_g0_save);
096559f07a70 some check
kono
parents: 17
diff changeset
37 goto (* ((struct cont_save *)sp)->ret)(k+4+j,sp);
096559f07a70 some check
kono
parents: 17
diff changeset
38 }
17
fdbf2fbc8140 *** empty log message ***
kono
parents:
diff changeset
39
622
682c8ec38d45 _code へ
kono
parents: 573
diff changeset
40 __code f(int i,void *sp) {
172
096559f07a70 some check
kono
parents: 17
diff changeset
41 int k,j;
096559f07a70 some check
kono
parents: 17
diff changeset
42 struct f_g0_save *c;
491
a379da780856 cond signed/unsigned
kono
parents: 449
diff changeset
43 printf("#0042:f 0 sp: %x\n",sp-stack0);
17
fdbf2fbc8140 *** empty log message ***
kono
parents:
diff changeset
44
172
096559f07a70 some check
kono
parents: 17
diff changeset
45 k = 3+i;
17
fdbf2fbc8140 *** empty log message ***
kono
parents:
diff changeset
46
491
a379da780856 cond signed/unsigned
kono
parents: 449
diff changeset
47 printf("#0046:f 1 sp: %x\n",sp-stack0);
172
096559f07a70 some check
kono
parents: 17
diff changeset
48 sp -= sizeof(struct f_g0_save);
491
a379da780856 cond signed/unsigned
kono
parents: 449
diff changeset
49 printf("#0048:f 2 sp: %x\n",sp-stack0);
172
096559f07a70 some check
kono
parents: 17
diff changeset
50 c = sp;
096559f07a70 some check
kono
parents: 17
diff changeset
51 c->kk = k;
096559f07a70 some check
kono
parents: 17
diff changeset
52 c->ii = i;
096559f07a70 some check
kono
parents: 17
diff changeset
53 c->jj = j;
096559f07a70 some check
kono
parents: 17
diff changeset
54 c->ret = f_g1;
096559f07a70 some check
kono
parents: 17
diff changeset
55 goto g(i,sp);
096559f07a70 some check
kono
parents: 17
diff changeset
56 }
17
fdbf2fbc8140 *** empty log message ***
kono
parents:
diff changeset
57
fdbf2fbc8140 *** empty log message ***
kono
parents:
diff changeset
58
fdbf2fbc8140 *** empty log message ***
kono
parents:
diff changeset
59
fdbf2fbc8140 *** empty log message ***
kono
parents:
diff changeset
60 struct f0_save { /* Specialized Return Continuation */
622
682c8ec38d45 _code へ
kono
parents: 573
diff changeset
61 __code (*ret)();
682c8ec38d45 _code へ
kono
parents: 573
diff changeset
62 __code (*exit1)();
17
fdbf2fbc8140 *** empty log message ***
kono
parents:
diff changeset
63 void *exit1env;
fdbf2fbc8140 *** empty log message ***
kono
parents:
diff changeset
64 int jj;
fdbf2fbc8140 *** empty log message ***
kono
parents:
diff changeset
65 };
fdbf2fbc8140 *** empty log message ***
kono
parents:
diff changeset
66
622
682c8ec38d45 _code へ
kono
parents: 573
diff changeset
67 __code f1(int i,void *sp) ;
682c8ec38d45 _code へ
kono
parents: 573
diff changeset
68 __code f0(int i,int j,__code(*exit2)(), void *exit2env,void *sp)
17
fdbf2fbc8140 *** empty log message ***
kono
parents:
diff changeset
69 {
fdbf2fbc8140 *** empty log message ***
kono
parents:
diff changeset
70 struct f0_save *c;
573
3de2ae36c7e5 *** empty log message ***
kono
parents: 572
diff changeset
71 printf("#0070:f0 1 sp: %x\n",sp-stack0);
17
fdbf2fbc8140 *** empty log message ***
kono
parents:
diff changeset
72 sp -= sizeof(struct f0_save);
573
3de2ae36c7e5 *** empty log message ***
kono
parents: 572
diff changeset
73 printf("#0072:f0 2 sp: %x\n",sp-stack0);
17
fdbf2fbc8140 *** empty log message ***
kono
parents:
diff changeset
74 c = sp;
fdbf2fbc8140 *** empty log message ***
kono
parents:
diff changeset
75 c->jj = j;
fdbf2fbc8140 *** empty log message ***
kono
parents:
diff changeset
76 c->exit1 = exit2;
fdbf2fbc8140 *** empty log message ***
kono
parents:
diff changeset
77 c->exit1env = exit2env;
fdbf2fbc8140 *** empty log message ***
kono
parents:
diff changeset
78 c->ret = f1;
573
3de2ae36c7e5 *** empty log message ***
kono
parents: 572
diff changeset
79 printf("#0078:f0 3 sp: %x\n",sp-stack0);
17
fdbf2fbc8140 *** empty log message ***
kono
parents:
diff changeset
80 goto f(i,sp);
fdbf2fbc8140 *** empty log message ***
kono
parents:
diff changeset
81 }
fdbf2fbc8140 *** empty log message ***
kono
parents:
diff changeset
82
622
682c8ec38d45 _code へ
kono
parents: 573
diff changeset
83 __code f1(int i,void *sp) {
17
fdbf2fbc8140 *** empty log message ***
kono
parents:
diff changeset
84 int j;
fdbf2fbc8140 *** empty log message ***
kono
parents:
diff changeset
85 int *exit2env;
622
682c8ec38d45 _code へ
kono
parents: 573
diff changeset
86 __code (*exit2)();
17
fdbf2fbc8140 *** empty log message ***
kono
parents:
diff changeset
87 struct f0_save *c;
fdbf2fbc8140 *** empty log message ***
kono
parents:
diff changeset
88
fdbf2fbc8140 *** empty log message ***
kono
parents:
diff changeset
89 c = sp;
fdbf2fbc8140 *** empty log message ***
kono
parents:
diff changeset
90 j = c->jj;
fdbf2fbc8140 *** empty log message ***
kono
parents:
diff changeset
91 exit2 = c->exit1;
fdbf2fbc8140 *** empty log message ***
kono
parents:
diff changeset
92 exit2env = c->exit1env;
fdbf2fbc8140 *** empty log message ***
kono
parents:
diff changeset
93
fdbf2fbc8140 *** empty log message ***
kono
parents:
diff changeset
94 sp += sizeof(struct f0_save);
fdbf2fbc8140 *** empty log message ***
kono
parents:
diff changeset
95 goto print(i,j,exit2,exit2env);
fdbf2fbc8140 *** empty log message ***
kono
parents:
diff changeset
96 }
fdbf2fbc8140 *** empty log message ***
kono
parents:
diff changeset
97
fdbf2fbc8140 *** empty log message ***
kono
parents:
diff changeset
98 int main( int ac, char *av[])
fdbf2fbc8140 *** empty log message ***
kono
parents:
diff changeset
99 {
fdbf2fbc8140 *** empty log message ***
kono
parents:
diff changeset
100 int i,j;
fdbf2fbc8140 *** empty log message ***
kono
parents:
diff changeset
101 int *sp;
fdbf2fbc8140 *** empty log message ***
kono
parents:
diff changeset
102
172
096559f07a70 some check
kono
parents: 17
diff changeset
103 // i = atoi(av[1]);
096559f07a70 some check
kono
parents: 17
diff changeset
104 i = 1;
17
fdbf2fbc8140 *** empty log message ***
kono
parents:
diff changeset
105 stack0 = ((char *)malloc(1024)+1024);
fdbf2fbc8140 *** empty log message ***
kono
parents:
diff changeset
106 sp = stack0;
fdbf2fbc8140 *** empty log message ***
kono
parents:
diff changeset
107 j = i;
fdbf2fbc8140 *** empty log message ***
kono
parents:
diff changeset
108
573
3de2ae36c7e5 *** empty log message ***
kono
parents: 572
diff changeset
109 printf("#0108:sp: %x %x\n",sp-(int*)stack0,sizeof(*stack0));
17
fdbf2fbc8140 *** empty log message ***
kono
parents:
diff changeset
110 goto f0(i,j,return,environment,sp);
fdbf2fbc8140 *** empty log message ***
kono
parents:
diff changeset
111 }
fdbf2fbc8140 *** empty log message ***
kono
parents:
diff changeset
112
622
682c8ec38d45 _code へ
kono
parents: 573
diff changeset
113 __code print(int i,int j,(*exit1)(),void*exit1env)
17
fdbf2fbc8140 *** empty log message ***
kono
parents:
diff changeset
114 {
573
3de2ae36c7e5 *** empty log message ***
kono
parents: 572
diff changeset
115 printf("#0114:%d %d\n",i,j);
172
096559f07a70 some check
kono
parents: 17
diff changeset
116 goto (*exit1)(0),exit1env;
17
fdbf2fbc8140 *** empty log message ***
kono
parents:
diff changeset
117 }
fdbf2fbc8140 *** empty log message ***
kono
parents:
diff changeset
118