0
|
1 struct env_segment1 {
|
|
2 void *fp;
|
|
3 void *sp;
|
|
4 }
|
|
5
|
|
6 struct cont_segment1 {
|
|
7 int value;
|
|
8 *return();
|
|
9 }
|
|
10
|
|
11 segment1(env_segment1 e,
|
|
12 cont_segment1 c) {
|
|
13 cont_segment1 c1 =
|
|
14 new_continuation(c,e);
|
|
15 c.return = segment2;
|
|
16 call_segment(e,c1);
|
|
17 }
|
|
18
|
|
19 call_segment(env_segment1 e,
|
|
20 cont_segment1 c) {
|
|
21 c.value = 1;
|
|
22 c.return();
|
|
23 }
|
|
24
|
|
25 segment2(env_segment2 e,
|
|
26 cont_segment1 c) {
|
|
27 cont_segment1 c1 =
|
|
28 old_continuation(e);
|
|
29 halt(e,c);
|
|
30 }
|
|
31
|
|
32 inline type new_continuation(c,e) {
|
|
33 e.fp -= sizeof(type);
|
|
34 return (type)e.fp;
|
|
35 }
|
|
36
|
|
37 inline type old_continuation(c,e) {
|
|
38 e.fp += sizeof(c);
|
|
39 return (type)e.fp;
|
|
40 }
|
|
41
|