annotate test/conv.c @ 449:c55363eff5e5

parallel assignment (modify not completed)
author kono
date Thu, 25 Nov 2004 16:56:26 +0900
parents 0c256ea2a97e
children 682c8ec38d45
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
170
6e0f67b7d200 test files
kono
parents:
diff changeset
1 #include "stdio.h"
6e0f67b7d200 test files
kono
parents:
diff changeset
2
6e0f67b7d200 test files
kono
parents:
diff changeset
3 f0(int i) {
6e0f67b7d200 test files
kono
parents:
diff changeset
4 int k,j;
6e0f67b7d200 test files
kono
parents:
diff changeset
5 k = 3+i;
6e0f67b7d200 test files
kono
parents:
diff changeset
6 j = g0(i+3);
6e0f67b7d200 test files
kono
parents:
diff changeset
7 return k+4+j;
6e0f67b7d200 test files
kono
parents:
diff changeset
8 }
6e0f67b7d200 test files
kono
parents:
diff changeset
9
6e0f67b7d200 test files
kono
parents:
diff changeset
10 g0(int i) {
6e0f67b7d200 test files
kono
parents:
diff changeset
11 return i+4;
6e0f67b7d200 test files
kono
parents:
diff changeset
12 }
6e0f67b7d200 test files
kono
parents:
diff changeset
13
6e0f67b7d200 test files
kono
parents:
diff changeset
14 typedef char *stack;
6e0f67b7d200 test files
kono
parents:
diff changeset
15
6e0f67b7d200 test files
kono
parents:
diff changeset
16 struct cont_interface { // General Return Continuation
6e0f67b7d200 test files
kono
parents:
diff changeset
17 code (*ret)();
6e0f67b7d200 test files
kono
parents:
diff changeset
18 };
6e0f67b7d200 test files
kono
parents:
diff changeset
19
6e0f67b7d200 test files
kono
parents:
diff changeset
20 code f(int i,stack sp) {
6e0f67b7d200 test files
kono
parents:
diff changeset
21 int k,j;
6e0f67b7d200 test files
kono
parents:
diff changeset
22 k = 3+i;
6e0f67b7d200 test files
kono
parents:
diff changeset
23 goto f_g0(i,k,sp);
6e0f67b7d200 test files
kono
parents:
diff changeset
24 }
6e0f67b7d200 test files
kono
parents:
diff changeset
25
6e0f67b7d200 test files
kono
parents:
diff changeset
26 struct f_g0_interface { // Specialized Return Continuation
6e0f67b7d200 test files
kono
parents:
diff changeset
27 code (*ret)();
6e0f67b7d200 test files
kono
parents:
diff changeset
28 int i_,k_,j_;
6e0f67b7d200 test files
kono
parents:
diff changeset
29 };
6e0f67b7d200 test files
kono
parents:
diff changeset
30
6e0f67b7d200 test files
kono
parents:
diff changeset
31 code f_g1(int j,stack sp);
6e0f67b7d200 test files
kono
parents:
diff changeset
32
6e0f67b7d200 test files
kono
parents:
diff changeset
33 code f_g0(int i,int k,stack sp) { // Caller
6e0f67b7d200 test files
kono
parents:
diff changeset
34 struct f_g0_interface *c =
6e0f67b7d200 test files
kono
parents:
diff changeset
35 (struct f_g0_interface *)(sp -= sizeof(struct f_g0_interface));
6e0f67b7d200 test files
kono
parents:
diff changeset
36
6e0f67b7d200 test files
kono
parents:
diff changeset
37 c->ret = f_g1;
6e0f67b7d200 test files
kono
parents:
diff changeset
38 c->k_ = k;
6e0f67b7d200 test files
kono
parents:
diff changeset
39 c->i_ = i;
6e0f67b7d200 test files
kono
parents:
diff changeset
40
6e0f67b7d200 test files
kono
parents:
diff changeset
41 goto g(i+3,sp);
6e0f67b7d200 test files
kono
parents:
diff changeset
42 }
6e0f67b7d200 test files
kono
parents:
diff changeset
43
6e0f67b7d200 test files
kono
parents:
diff changeset
44 code f_g1(int j,stack sp) { // Continuation
6e0f67b7d200 test files
kono
parents:
diff changeset
45 struct f_g0_interface *c = sp;
6e0f67b7d200 test files
kono
parents:
diff changeset
46 int k = c->k_;
6e0f67b7d200 test files
kono
parents:
diff changeset
47 sp += sizeof(struct f_g0_interface);
6e0f67b7d200 test files
kono
parents:
diff changeset
48 goto (( (struct cont_interface *)sp)->ret)(k+4+j,sp);
6e0f67b7d200 test files
kono
parents:
diff changeset
49 }
6e0f67b7d200 test files
kono
parents:
diff changeset
50
6e0f67b7d200 test files
kono
parents:
diff changeset
51 code g(int i,stack sp) {
6e0f67b7d200 test files
kono
parents:
diff changeset
52 goto (( (struct cont_interface *)sp)->ret)(i+4,sp);
6e0f67b7d200 test files
kono
parents:
diff changeset
53 }
6e0f67b7d200 test files
kono
parents:
diff changeset
54
6e0f67b7d200 test files
kono
parents:
diff changeset
55 struct main_continuation { // General Return Continuation
6e0f67b7d200 test files
kono
parents:
diff changeset
56 code (*ret)();
6e0f67b7d200 test files
kono
parents:
diff changeset
57 code (*main_ret)();
6e0f67b7d200 test files
kono
parents:
diff changeset
58 void *env;
6e0f67b7d200 test files
kono
parents:
diff changeset
59 };
6e0f67b7d200 test files
kono
parents:
diff changeset
60
6e0f67b7d200 test files
kono
parents:
diff changeset
61 code main_return(int i,stack sp) {
427
0c256ea2a97e Bitfield left value for ia32
kono
parents: 170
diff changeset
62 printf("#0061:%d\n",i);
170
6e0f67b7d200 test files
kono
parents:
diff changeset
63 goto (( (struct main_continuation *)sp)->main_ret)(0),
6e0f67b7d200 test files
kono
parents:
diff changeset
64 ((struct main_continuation *)sp)->env;
6e0f67b7d200 test files
kono
parents:
diff changeset
65 }
6e0f67b7d200 test files
kono
parents:
diff changeset
66
6e0f67b7d200 test files
kono
parents:
diff changeset
67 #define STACK_SIZE 2048
6e0f67b7d200 test files
kono
parents:
diff changeset
68 stack main_stack[STACK_SIZE];
6e0f67b7d200 test files
kono
parents:
diff changeset
69 #define stack_last (&main_stack[STACK_SIZE])
6e0f67b7d200 test files
kono
parents:
diff changeset
70
6e0f67b7d200 test files
kono
parents:
diff changeset
71 main()
6e0f67b7d200 test files
kono
parents:
diff changeset
72 {
6e0f67b7d200 test files
kono
parents:
diff changeset
73 struct main_continuation *cont;
6e0f67b7d200 test files
kono
parents:
diff changeset
74 stack sp = stack_last;
6e0f67b7d200 test files
kono
parents:
diff changeset
75
427
0c256ea2a97e Bitfield left value for ia32
kono
parents: 170
diff changeset
76 printf("#0075:%d\n",f0(233));
170
6e0f67b7d200 test files
kono
parents:
diff changeset
77
6e0f67b7d200 test files
kono
parents:
diff changeset
78 sp -= sizeof(*cont);
6e0f67b7d200 test files
kono
parents:
diff changeset
79 cont = (struct main_continuation *)sp;
6e0f67b7d200 test files
kono
parents:
diff changeset
80 cont->ret = main_return;
6e0f67b7d200 test files
kono
parents:
diff changeset
81 cont->main_ret = return;
6e0f67b7d200 test files
kono
parents:
diff changeset
82 cont->env = environment;
6e0f67b7d200 test files
kono
parents:
diff changeset
83 goto f(233,sp);
6e0f67b7d200 test files
kono
parents:
diff changeset
84 }
6e0f67b7d200 test files
kono
parents:
diff changeset
85
6e0f67b7d200 test files
kono
parents:
diff changeset
86 /* end */