view test/tmp1.c @ 492:cc1a5f764782

*** empty log message ***
author kono
date Wed, 21 Dec 2005 12:10:43 +0900
parents a379da780856
children 388baa7d4bee
line wrap: on
line source

/* easy test */

code (*ret)();
void *env;

main0(ac,av)
int ac;
char *av[];
{
    ret = return;
    env = environment;
    printf("#0011:main0 %d start.\n",ac);
    if (ac>=1)
	goto code0(ac,av,return);
    goto code1(ac,av,exit1);
    // not reached. (warning?)
    printf("#0016:main0 %d end.\n",ac);
}

code exit1(int ac)
{
    // exit(0);
    goto code3(0,1,2,3,4,5);
}

code code3(a,b,c,d,e,f)
char a,b;
int c,d,e,f;
{
    printf("#0029:code3: %d %d %d %d %d %d\n",a,b,c,d,e,f);
    if(a<10)
	goto code3(a+1,b,c,d,e,f);
    else
	goto code4(a+3,b+3,c+3,d+3,e+3,f+3);
}

code code4(a,b,c,d,e,f)
char a,b;
int c,d,e,f;
{
    int i=1,j=2;
    printf("#0041:code4: %d %d %d %d %d %d\n",a,b,c,d,e,f);
    if(a<20)   // cyclic binary dependency
	goto code3(a+b,b+c,c+d,d+e,e+f,f+a);
    else if(a<30)
	goto code3(a,b,c,d,e,f);
    else if(a<40) // cyclic dependency
	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;
}

code code0(ac,av,ret)
int ac;
char *av[];
code ret();
{
    goto code1(ac,av,ret);
}

code code1(ac,av,exit)
int ac,exit;
char *av[];
{
    code (*f)(int);
    printf("#0066:code1: %d\n",ac);
    f = exit;
    if (ac>3)
	goto code1(ac,av,f);
    else if (ac>2)
	goto code1(av,ac,f);
    else
	goto (*f)(ac),env;
}

int
main(int ac,char *av[])
{
   main0(1,av);
   printf("#0080:main continue.\n");
   main0(0,av);
   printf("#0082:main end.\n");
}

/* end */