changeset 109:78d3881f2882

add CbC-example/rectype
author Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
date Thu, 14 Jun 2012 20:43:12 +0900
parents 7ad14f446135
children 76fdfee14d03
files CbC-examples/rectype/rectype.cbc CbC-examples/rectype/struct.cbc
diffstat 2 files changed, 52 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/CbC-examples/rectype/rectype.cbc	Thu Jun 14 20:43:12 2012 +0900
@@ -0,0 +1,22 @@
+#include <stdio.h>
+#include <stdlib.h>
+__code print(__rectype *p)
+{
+	printf("print\n");
+	exit(0);
+}
+__code csA(__rectype *p)
+{
+	goto p(csA);
+}
+
+void main1()
+{
+	goto csA(print);
+}
+
+int main()
+{
+	main1();
+	return 0;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/CbC-examples/rectype/struct.cbc	Thu Jun 14 20:43:12 2012 +0900
@@ -0,0 +1,30 @@
+#include <stdio.h>
+#include <stdlib.h>
+struct interface {
+	__code (*next)(struct interface);
+};
+
+__code print(struct interface p)
+{
+	printf("print\n");
+	exit(0);
+}
+__code csA(struct interface p)
+{
+	struct interface ds;
+	ds.next = csA;
+	goto p.next(ds);
+}
+
+void main1()
+{
+	struct interface ds;
+	ds.next = print;
+	goto csA(ds);
+}
+
+int main()
+{
+	main1();
+	return 0;
+}