diff CbC-examples/tmp2.c @ 78:365b84b6fe04

more examples
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Tue, 20 Sep 2011 17:32:20 +0900
parents
children 5d30d517ebed
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/CbC-examples/tmp2.c	Tue Sep 20 17:32:20 2011 +0900
@@ -0,0 +1,44 @@
+#define __environment _CbC_environment
+#define __return _CbC_return
+
+#include "stdio.h"
+
+int
+main(ac,av)
+int ac;
+char *av[];
+{
+    int i;
+    i=main0(ac,av);
+    fprintf(stdout,"#0012:1: %s %d\n",av[0],i);
+    return 0;
+}
+
+int
+main0(ac,av)
+int ac;
+char *av[];
+{
+    fprintf(stdout,"#0021:2: %s\n",av[0]);
+    goto code0(av,__return,__environment);
+}
+
+__code code0(av,ret,retenv)
+char *av[];
+__code (*ret)();
+void *retenv;
+{
+    char *p;
+    p = av[0];
+    fprintf(stdout,"#0032:3: %s\n",p);
+    goto code1(av,ret,retenv);
+}
+
+__code code1(av,ret,retenv)
+char *av[];
+__code (*ret)();
+void *retenv;
+{
+    fprintf(stdout,"#0041:4: %s\n",av[0]);
+    goto (*ret)(1234,retenv);
+}