Mercurial > hg > CbC > CbC_examples
view goto.c @ 14:7d168c1829c9
modify makefile
author | Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp> |
---|---|
date | Fri, 17 Apr 2015 16:09:28 +0900 |
parents | bacef8675607 |
children | 586096c45873 |
line wrap: on
line source
#define __environment _CbC_environment #define __return _CbC_return extern int printf(const char *,...); __code (*conv)(int,__code (*)()); __code a2(int i,__code conv()); __code a3(int i,__code conv()); __code a4(int i,__code conv()); __code a5(int i,__code conv()); __code a6(); __code a7(); __code a8(); __code a9(); char* print_conv(__code conv()); __code (*exit0)(int,void*); void *env; __code a2(int i,__code conv()) { printf("#0023:a2 %d %s\n",i,print_conv(conv)); goto conv(i+1,a4); } __code a3(int i,__code (*conv)()) { printf("#0030:a3 %d %s\n",i,print_conv(conv)); goto conv(i+1,a5); } __code a4(int i,__code conv()) { printf("#0037:a4 %d %s\n",i,print_conv(conv)); goto (*conv)(i+1,a6); } __code a5(int i,__code (*conv)()) { printf("#0044:a5 %d %s\n",i,print_conv(conv)); goto (*conv)(i+1,i+2,i+3,a7); } __code a6(int i,int j,int k,__code conv()) { printf("#0051:a6 %d %s\n",i,print_conv(conv)); goto conv(i+1,j,k,a8); } __code a7(int i,int j,int k,__code (*conv)()) { printf("#0058:a7 %d %s\n",i,print_conv(conv)); goto conv(i+1,j,k,a9); } __code a8(int i,int j,int k,__code conv()) { printf("#0065:a8 %d %s\n",i,print_conv(conv)); goto (*conv)(i+1,j,k,exit0); } __code a9(int i,int j,int k,__code (*conv)()) { printf("#0072:a9 %d %s\n",i,print_conv(conv)); goto (*conv)(0,env); } main(int ac,char *av[]) { exit0 = __return; env = __environment; conv = a2; goto conv(1,a3); } char* print_conv(__code conv()) { if(conv==a2) return "a2"; if(conv==a3) return "a3"; if(conv==a4) return "a4"; if(conv==a5) return "a5"; if(conv==a6) return "a6"; if(conv==a7) return "a7"; if(conv==a8) return "a8"; if(conv==a9) return "a9"; else return "xx"; }