view test/goto.c @ 585:a5b902b20300 ia32-no-rname

ia32 reconfigure end (correct?)
author kono
date Wed, 18 Jan 2006 12:26:48 +0900
parents 3de2ae36c7e5
children 682c8ec38d45
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());
code a6();
code a7();
code a8();
code a9();

char* print_conv(code conv());

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

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

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

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

code
a5(int i,code (*conv)())
{
    printf("#0041: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("#0048: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("#0055: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("#0062: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("#0069: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";
}