diff CbC-examples/test_func2code.c @ 21:959d4c8c8abc

add conv.c conv1.c
author kent <kent@cr.ie.u-ryukyu.ac.jp>
date Tue, 29 Sep 2009 20:15:16 +0900
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/CbC-examples/test_func2code.c	Tue Sep 29 20:15:16 2009 +0900
@@ -0,0 +1,43 @@
+#include<stdio.h>
+#include<stdlib.h>
+
+#define DEBUG 1
+#ifdef DEBUG
+  #define log(f, args...) \
+	fprintf(stderr, "in %s: "f, __FUNCTION__, ## args)
+#else
+  #define log(f, args...) ;
+#endif
+
+__code
+exitter(int a)
+{
+	exit(0);
+}
+
+__code
+cs0(int x, int y)
+{
+	log("x = %d, y = %d.\n", x, y);
+	log("will exit with code %d.\n", x*y);
+	goto exitter(x*y);
+}
+
+void
+continuation(int a)
+{
+	log("go code segment cs0\n");
+	goto cs0(a, a*20);
+	log("Error: continuation reachs bad region.\n");
+}
+
+int
+main(int argc, char **argv)
+{
+	int a;
+	if (argc>2) {
+		a = atoi(argv[1]);
+	}
+
+	continuation(20);
+}