annotate CbC-examples/rectypeTest/struct.cbc @ 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
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
106
85047c4f1ca4 add CbC-examples/rectypeTest
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1 struct aaa {
85047c4f1ca4 add CbC-examples/rectypeTest
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2 __rectype *child;
85047c4f1ca4 add CbC-examples/rectypeTest
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3 };
85047c4f1ca4 add CbC-examples/rectypeTest
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
4 __code test() {
85047c4f1ca4 add CbC-examples/rectypeTest
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
5 struct aaa b;
85047c4f1ca4 add CbC-examples/rectypeTest
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
6 }
85047c4f1ca4 add CbC-examples/rectypeTest
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
7
85047c4f1ca4 add CbC-examples/rectypeTest
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
8 struct interface {
85047c4f1ca4 add CbC-examples/rectypeTest
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
9 __code (*next)(struct interface);
85047c4f1ca4 add CbC-examples/rectypeTest
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
10 };
85047c4f1ca4 add CbC-examples/rectypeTest
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
11
85047c4f1ca4 add CbC-examples/rectypeTest
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
12
85047c4f1ca4 add CbC-examples/rectypeTest
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
13 #include <stdio.h>
85047c4f1ca4 add CbC-examples/rectypeTest
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
14 #include <stdlib.h>
85047c4f1ca4 add CbC-examples/rectypeTest
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
15 __code csB() {
85047c4f1ca4 add CbC-examples/rectypeTest
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
16 exit(0);
85047c4f1ca4 add CbC-examples/rectypeTest
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
17 }
85047c4f1ca4 add CbC-examples/rectypeTest
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
18 __code print(struct interface p) {
85047c4f1ca4 add CbC-examples/rectypeTest
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
19 puts("hello");
85047c4f1ca4 add CbC-examples/rectypeTest
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
20 exit(0);
85047c4f1ca4 add CbC-examples/rectypeTest
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
21 }
85047c4f1ca4 add CbC-examples/rectypeTest
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
22
85047c4f1ca4 add CbC-examples/rectypeTest
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
23 __code csA(struct interface p) {
85047c4f1ca4 add CbC-examples/rectypeTest
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
24 struct interface ds = { csB };
85047c4f1ca4 add CbC-examples/rectypeTest
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
25 goto p.next(ds);
85047c4f1ca4 add CbC-examples/rectypeTest
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
26 // goto p.next(3); // error
85047c4f1ca4 add CbC-examples/rectypeTest
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
27 }
85047c4f1ca4 add CbC-examples/rectypeTest
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
28
85047c4f1ca4 add CbC-examples/rectypeTest
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
29 int main() {
85047c4f1ca4 add CbC-examples/rectypeTest
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
30 struct interface ds = { print };
85047c4f1ca4 add CbC-examples/rectypeTest
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
31 goto csA(ds);
85047c4f1ca4 add CbC-examples/rectypeTest
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
32 return 0;
85047c4f1ca4 add CbC-examples/rectypeTest
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
33 }