view test/goto.c @ 496:5640fb7a270d

more bugs...
author kono
date Thu, 22 Dec 2005 00:20:09 +0900
parents 0c256ea2a97e
children 388baa7d4bee
line wrap: on
line source



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());

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";
}

code (*exit0)(int);
void *env;

code
a2(int i,code conv())
{
    printf("#0028:a2 %d %s\n",i,print_conv(conv));
    goto conv(i+1,a4);
}

code
a3(int i,code (*conv)())
{
    printf("#0035:a3 %d %s\n",i,print_conv(conv));
    goto conv(i+1,a5);
}

code
a4(int i,code conv())
{
    printf("#0042:a4 %d %s\n",i,print_conv(conv));
    goto (*conv)(i+1,a6);
}

code
a5(int i,code (*conv)())
{
    printf("#0049: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("#0056: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("#0063: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("#0070: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("#0077: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);
}