0
|
1 // to test a deep-nested struct
|
|
2 // this example tests a 2 nested struct
|
|
3 #define NULL ((void*)0)
|
|
4 struct nest1{
|
|
5 int i;
|
|
6 int j;
|
|
7 char k;
|
|
8 };
|
|
9 struct nest0{
|
|
10 int huga;
|
|
11 long hoge;
|
|
12 float aho;
|
|
13 struct nest1 n1;
|
|
14 };
|
|
15 struct nest{
|
|
16 char *str;
|
|
17 char *p;
|
|
18 void *env;
|
|
19 code (*ret)(int);
|
|
20 struct nest0 n0;
|
|
21 };
|
|
22 code
|
|
23 dmpn2(code(*ret)(int), void *env)
|
|
24 {
|
|
25 goto ret(0), env;
|
|
26 }
|
|
27 code
|
|
28 dmpn1(struct nest1 *test1, code(*ret)(int), void *env)
|
|
29 {
|
|
30 printf("dmpn1: %d %d %d\n",
|
|
31 test1->i,
|
|
32 test1->j,
|
|
33 test1->k);
|
|
34 goto dmpn2(ret,env);
|
|
35 }
|
|
36 code
|
|
37 dmpn0(struct nest0 *test0, code(*ret)(), void *env)
|
|
38 {
|
|
39 printf("dmpn0: %d %ld %f\n",
|
|
40 test0->huga,
|
|
41 test0->hoge,
|
|
42 test0->aho);
|
|
43 goto dmpn1(&(test0->n1), ret, env);
|
|
44 }
|
|
45 code
|
|
46 dmpn(struct nest *test)
|
|
47 {
|
|
48 printf("dmpn: %x %x\n", test->str, test->p);
|
|
49 goto dmpn0(&(test->n0), test->ret, test->env);
|
|
50 }
|
|
51 void
|
|
52 dmp(struct nest *n)
|
|
53 {
|
|
54 n->ret=return;
|
|
55 n->env=environment;
|
|
56 goto dmpn(n);
|
|
57 }
|
|
58 int
|
|
59 main()
|
|
60 {
|
|
61 struct nest test;
|
|
62 test.str=NULL;
|
|
63 test.p=NULL;
|
|
64 test.n0.huga=1;
|
|
65 test.n0.hoge=2;
|
|
66 test.n0.aho=3.0;
|
|
67 test.n0.n1.i=10;
|
|
68 test.n0.n1.j=20;
|
|
69 test.n0.n1.k=30;
|
|
70 // dmp(&test);
|
|
71 return(0);
|
|
72 }
|