Mercurial > hg > CbC > CbC_gcc
changeset 128:fe568345ddd5
fix CbC-example
author | mir3636 |
---|---|
date | Wed, 11 Apr 2018 19:32:28 +0900 |
parents | 4c56639505ff |
children | e108057fa461 |
files | CbC-examples/Makefile CbC-examples/tmp1.c CbC-examples/tmp2.c gcc/calls.c |
diffstat | 4 files changed, 29 insertions(+), 22 deletions(-) [+] |
line wrap: on
line diff
--- a/CbC-examples/Makefile Wed Apr 11 18:46:58 2018 +0900 +++ b/CbC-examples/Makefile Wed Apr 11 19:32:28 2018 +0900 @@ -6,4 +6,6 @@ ${CBC_COMPILER} $(CFLAGS) -o $@ $< test : $(TEST) - for exe in ${TEST}; do; ./$${exe} ; done + for exe in ${TEST} ; do \ + ./$${exe} ; \ + done
--- a/CbC-examples/tmp1.c Wed Apr 11 18:46:58 2018 +0900 +++ b/CbC-examples/tmp1.c Wed Apr 11 19:32:28 2018 +0900 @@ -5,12 +5,16 @@ extern int printf(const char *,...); -__code code0(int ac,char *av[],__code (*ret)()); -__code code1(int ac,char *av[],__code (*exit)(int,void*)) +#if 0 //currently gcc version dose not support void type full continuation. -__code (*ret)(); +__code code0(int ac,char *av[],__code (*ret)(void*)); +__code code1(int ac,char *av[],__code (*exit)(void*)); +__code code3(char a,char b,int c,int d,int e,int f); +__code code4(char a,char b,int c,int d,int e,int f); + +__code (*ret)(void *); void *env; -__code exit1(int ac,void *); +__code exit1(void *); void main0(ac,av) int ac; @@ -26,7 +30,7 @@ printf("#0022:main0 %d end.\n",ac); } -__code exit1(int ac) +__code exit1(void *env) { // exit(0); goto code3(0,1,2,3,4,5); @@ -57,39 +61,40 @@ goto code3(b,c,a,e,f,d); else if(a<50) goto code4(a+i,b+j,c+i,d+3,e+3,f+3); - else goto ret(0,env); + else goto ret(env); } __code code0(ac,av,ret) int ac; char *av[]; -__code (*ret)(int); +__code (*ret)(void *env); { goto code1(ac,av,ret); } __code code1(ac,av,exit) int ac; -__code (*exit)(int,void*); +__code (*exit)(void*); char *av[]; { - __code (*f)(int,void *); + __code (*f)(void *); printf("#0073:code1: %d\n",ac); f = exit; if (ac>3) goto code1(ac,av,f); else if (ac>2) - goto code1(av,ac,f); + goto code1(ac,av,f); else - goto (*f)(ac,env); + goto (*f)(env); } -int -main(int ac,char *av[]) +#endif + +int main(int ac,char *av[]) { - main0(1,av); +// main0(1,av); printf("#0087:main continue.\n"); - main0(0,av); +// main0(0,av); printf("#0089:main end.\n"); return 0; }
--- a/CbC-examples/tmp2.c Wed Apr 11 18:46:58 2018 +0900 +++ b/CbC-examples/tmp2.c Wed Apr 11 19:32:28 2018 +0900 @@ -4,8 +4,8 @@ #include "stdio.h" int main0(int ac,char *av[]); -__code code0(char *av[],__code (*ret)(int),void *retenv); -__code code1(char *av[],__code (*ret)(int),void *retenv); +__code code0(char *av[],__code (*ret)(int, void*),void *retenv); +__code code1(char *av[],__code (*ret)(int, void*),void *retenv); int main(ac,av) @@ -29,7 +29,7 @@ __code code0(av,ret,retenv) char *av[]; -__code (*ret)(); +__code (*ret)(int, void*); void *retenv; { char *p; @@ -40,7 +40,7 @@ __code code1(av,ret,retenv) char *av[]; -__code (*ret)(); +__code (*ret)(int, void*); void *retenv; { fprintf(stdout,"#0041:4: %s\n",av[0]);
--- a/gcc/calls.c Wed Apr 11 18:46:58 2018 +0900 +++ b/gcc/calls.c Wed Apr 11 19:32:28 2018 +0900 @@ -3375,8 +3375,8 @@ #ifndef noCbC if ( fntype - //&& CbC_IS_CbC_GOTO (exp) // it's better? than CALL_EXPR_TAILCALL() - && CALL_EXPR_TAILCALL(exp) + && CbC_IS_CbC_GOTO (exp) // it's better? than CALL_EXPR_TAILCALL() + //&& CALL_EXPR_TAILCALL(exp) && CbC_IS_CODE_SEGMENT (TREE_TYPE (current_function_decl)) ) {