Mercurial > hg > CbC > CbC_gcc
comparison CbC-examples/conv1/conv1.c @ 106:85047c4f1ca4
add CbC-examples/rectypeTest
author | Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Wed, 13 Jun 2012 17:18:58 +0900 |
parents | 79124facde7c |
children |
comparison
equal
deleted
inserted
replaced
105:b3cfc7733d3f | 106:85047c4f1ca4 |
---|---|
9 | 9 |
10 typedef char *stack; | 10 typedef char *stack; |
11 #include "conv1.h" | 11 #include "conv1.h" |
12 | 12 |
13 /* classical function call case (0) */ | 13 /* classical function call case (0) */ |
14 | |
15 f0(int i) { | 14 f0(int i) { |
16 int k,j; | 15 int k,j; |
17 k = 3+i; | 16 k = 3+i; |
18 j = g0(i+3); | 17 j = g0(i+3); |
19 return k+4+j; | 18 return k+4+j; |
41 k = 3+i; | 40 k = 3+i; |
42 goto f_g0(i,k,sp); | 41 goto f_g0(i,k,sp); |
43 } | 42 } |
44 | 43 |
45 struct f_g0_interface { // Specialized Return Continuation | 44 struct f_g0_interface { // Specialized Return Continuation |
46 __code (*ret)(); | 45 __code (*ret)(int,stack); |
47 int i_,k_,j_; | 46 int i_,k_,j_; |
48 }; | 47 }; |
49 | 48 |
50 __code f_g1(int j,stack sp); | 49 __code f_g1(int j,stack sp); |
51 | 50 |
189 if (ac==2) sw = atoi(av[1]); | 188 if (ac==2) sw = atoi(av[1]); |
190 else sw=3; | 189 else sw=3; |
191 | 190 |
192 if (sw==0) { | 191 if (sw==0) { |
193 for(loop=0;loop<LOOP_COUNT;loop++) { | 192 for(loop=0;loop<LOOP_COUNT;loop++) { |
194 j = f0(233); | 193 j = f0(loop); |
195 } | 194 } |
196 printf("#0193:%d\n",j); | 195 printf("#0193:%d\n",j); |
197 #if !CC_ONLY | 196 #if !CC_ONLY |
198 } else if (sw==1) { | 197 } else if (sw==1) { |
199 loop = LOOP_COUNT; | 198 loop = LOOP_COUNT; |
200 sp -= sizeof(*cont); | 199 sp -= sizeof(*cont); |
201 cont = (struct main_continuation *)sp; | 200 cont = (struct main_continuation *)sp; |
202 cont->ret = main_return; | 201 cont->ret = main_return; |
203 cont->main_ret = _CbC_return; | 202 cont->main_ret = _CbC_return; |
204 cont->env = _CbC_environment; | 203 cont->env = _CbC_environment; |
205 goto f(233,sp); | 204 goto f(loop,sp); |
206 } else if (sw==2) { | 205 } else if (sw==2) { |
207 loop = LOOP_COUNT; | 206 loop = LOOP_COUNT; |
208 sp -= sizeof(*cont); | 207 sp -= sizeof(*cont); |
209 cont = (struct main_continuation *)sp; | 208 cont = (struct main_continuation *)sp; |
210 cont->ret = main_return2; | 209 cont->ret = main_return2; |
211 cont->main_ret = _CbC_return; | 210 cont->main_ret = _CbC_return; |
212 cont->env = _CbC_environment; | 211 cont->env = _CbC_environment; |
213 goto f2(233,sp); | 212 goto f2(loop,sp); |
214 } else if (sw==3) { | 213 } else if (sw==3) { |
215 loop = LOOP_COUNT; | 214 loop = LOOP_COUNT; |
216 sp -= sizeof(*cont); | 215 sp -= sizeof(*cont); |
217 cont = (struct main_continuation *)sp; | 216 cont = (struct main_continuation *)sp; |
218 cont->ret = main_return2_1; | 217 cont->ret = main_return2_1; |
219 cont->main_ret = _CbC_return; | 218 cont->main_ret = _CbC_return; |
220 cont->env = _CbC_environment; | 219 cont->env = _CbC_environment; |
221 goto f2_1(233,sp); | 220 goto f2_1(loop,sp); |
222 #endif | 221 #endif |
223 } | 222 } |
224 return 0; | 223 return 0; |
225 } | 224 } |
226 | 225 |